Point shop doesn't work
So point shop doesn't work, when i buy something it doesn't minus points and buy, I can't find the problem.
PHP Code:
public shop(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
new menu = menu_create("\rPoint Shop" , "Shop_Handler");
menu_additem(menu ,"\wAmmo \d(100 Points)", "1" , 0);
if(HeTry[id] < 3)
{
menu_additem(menu ,"\wHe Grenade \d(50 Points)", "2" , 0);
}
else if(HeTry[id] == 3)
{
menu_additem(menu ,"\dHe Grenade (You bought it already 3 times)", "2" , 0);
}
menu_setprop(menu , MPROP_EXIT , MEXIT_ALL);
menu_display(id , menu , 0);
return PLUGIN_CONTINUE;
}
public Shop_Handler(id, menu, item, player)
{
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)
new Point = gPoints[id];
switch(key)
{
case 1:
{
if (Point < get_pcvar_num(cvar_ammocost))
{
client_printcolor(id, "/y[/ctrCorp/y]:: You don't have enough points!");
return PLUGIN_HANDLED;
}
client_printcolor(id, "/y[/ctrCorp/y]:: You bought ammo!");
gPoints[id] -= get_pcvar_num(cvar_ammocost);
}
case 2:
{
if(Point < get_pcvar_num(cvar_hecost))
{
client_printcolor(id, "/y[/ctrCorp/y]:: You don't have enough points!");
return PLUGIN_HANDLED;
}
if(HeTry[id] < 3)
{
HeTry[id]++
give_item(id, "weapon_hegrenade")
}
client_printcolor(id, "/y[/ctrCorp/y]:: You bought He grenade!");
gPoints[id] -= get_pcvar_num(cvar_hecost);
}
}
menu_destroy(menu)
return PLUGIN_HANDLED;
}
|