AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   shop problem (https://forums.alliedmods.net/showthread.php?t=105748)

DoviuX 10-08-2009 01:11

shop problem
 
When i buy from my shop stuff money stays what it is but i get what i buyied.
And can help make that stays till next map or restart ? becouse it's for 1 round.

Code:

PHP Code:

    //Shop
    
new price1
    
new price2
    
new price3

 
    
new const gBuy[][] =
    {
    
"Cod4/Buy/Item1.wav",
    
"Cod4/Buy/Item2.wav"
    
};
    public 
plugin_precache() 
    {
        for ( 
0sizeof gBuyi++ )
        {   
            
precache_soundgBuy] );
    }

    public 
plugin_init()
    {
    
register_clcmd("say /shop""WarShop")
    
register_clcmd("say_team /shop""WarShop")
    
    
price1 register_cvar("price_healthrecover""2000")
    
price2 register_cvar("price_armor""2000")
    
price3 register_cvar("price_morestats""16000")
    }

    public 
WarShop(id)
    {
    new 
menu menu_create("\yCod4 Shop!""menu_handler")
    
    
menu_additem(menu"Health""1"0)
    
menu_additem(menu"Armor""2"0)
    
menu_additem(menu"StatUgrade""3"0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
    }

    public 
menu_handler(idmenuitem)
    {
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1
        {
            new 
Money cs_get_user_money(id)
            new 
Pcvar get_pcvar_num(price1)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money!")
                return 
PLUGIN_HANDLED
            

            else 
            {
                
set_user_health(id100)
                
client_print(idprint_chat"You Recovered Health!")
                        
client_cmd0"spk %s"gBuyrandomsizeof gBuy ) ] );    
            
            }
        }
        case 
2
        {
            new 
Money cs_get_user_money(id)
            new 
Pcvar get_pcvar_num(price2)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money!")
                return 
PLUGIN_HANDLED
            

            else 
            {
                
set_user_armor(id100)
                
client_print(idprint_chat"You Gained Armor!")
                        
client_cmd0"spk %s"gBuyrandomsizeof gBuy ) ] );    
                
            }
        }
        case 
3
        {
            new 
Money cs_get_user_money(id)
            new 
Pcvar get_pcvar_num(price3)
            
            if (
Money Pcvar)
            {
                
client_print(idprint_chat"You don't have enough money!")
                return 
PLUGIN_HANDLED
            

            else 
            {
                
set_user_health(id245)
                
set_user_armor(id100)
                
set_user_gravity(id0.7)

                
client_print(idprint_chat"You Gained More Stats!")
                        
client_cmd0"spk %s"gBuyrandomsizeof gBuy ) ] );    
                
            }
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED;
    } 


hzqst 10-08-2009 01:42

Re: shop problem
 
PHP Code:

            else  
            { 
                
set_user_health(id100
                
client_print(idprint_chat"You Recovered Health!"
                        
client_cmd0"spk %s"gBuyrandomsizeof gBuy ) ] );     
 
            }
            
cs_set_user_money(idMoney Pcvar)//You didn't do it ,right? 


vitorrd 10-08-2009 02:51

Re: shop problem
 
Make Money and Pcvar visible to the outside of your switch and then use cs_set_user_money.

Hint: A little indentation wouldn't hurt there.


All times are GMT -4. The time now is 22:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.