Raised This Month: $ Target: $400
 0% 

shop problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 10-08-2009 , 01:11   shop problem
Reply With Quote #1

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;
    } 

Last edited by DoviuX; 10-08-2009 at 01:16.
DoviuX is offline
Send a message via Skype™ to DoviuX
hzqst
Senior Member
Join Date: Jul 2008
Old 10-08-2009 , 01:42   Re: shop problem
Reply With Quote #2

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? 
hzqst is offline
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-08-2009 , 02:51   Re: shop problem
Reply With Quote #3

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.
vitorrd is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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