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 ( i = 0; i < sizeof gBuy; i++ )
{
precache_sound( gBuy[ i ] );
}
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(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
public menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
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(id, print_chat, "You don't have enough money!")
return PLUGIN_HANDLED
}
else
{
set_user_health(id, 100)
client_print(id, print_chat, "You Recovered Health!")
client_cmd( 0, "spk %s", gBuy[ random( sizeof gBuy ) ] );
}
}
case 2:
{
new Money = cs_get_user_money(id)
new Pcvar = get_pcvar_num(price2)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money!")
return PLUGIN_HANDLED
}
else
{
set_user_armor(id, 100)
client_print(id, print_chat, "You Gained Armor!")
client_cmd( 0, "spk %s", gBuy[ random( sizeof gBuy ) ] );
}
}
case 3:
{
new Money = cs_get_user_money(id)
new Pcvar = get_pcvar_num(price3)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money!")
return PLUGIN_HANDLED
}
else
{
set_user_health(id, 245)
set_user_armor(id, 100)
set_user_gravity(id, 0.7)
client_print(id, print_chat, "You Gained More Stats!")
client_cmd( 0, "spk %s", gBuy[ random( sizeof gBuy ) ] );
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED;
}
|