I put a limit on an item so I can't abuse it but when I want to buy the same item I keep deducting from ammo packs why?
Code:
#include <amxmodx>
#include <fun>
#include <zp_apocalypse>
new const item_name[] = "Buy 1000 HP!"
new g_itemid_buyhp
new hpamount
new g_bComprado[ 33 ];
new cvar_limit
public plugin_init()
{
register_plugin("[ZP] Buy Health Points", "1.0", "T[h]E Dis[as]teR")
hpamount = register_cvar("zp_buyhp_amount", "1000")
cvar_limit = register_cvar("zp_buyhp_limit", "1")
g_itemid_buyhp = zp_register_extra_item(item_name, 5, ZP_TEAM_ZOMBIE & ZP_TEAM_HUMAN)
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public event_round_start()
{
arrayset( g_bComprado, 33, 0 );
}
public zp_extra_item_selected(id,itemid)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
if(itemid==g_itemid_buyhp)
{
if(zp_get_user_ammo_packs(id) < 20)
{
client_print(id, print_chat,"[ZP] Not enough Ammopacks!");
return PLUGIN_HANDLED;
}
else
{
if( g_bComprado[ id ] < get_pcvar_num(cvar_limit))
{
g_bComprado[ id ] ++;
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - 5);
client_print(id, print_chat,"[ZP] You Bought HP!");
}
else
{
client_print(id, print_chat,"[ZP] poti cumpara acest item daar odata pe runda");
}
}
}
return PLUGIN_CONTINUE;
}