Per round & player
PHP Code:
#define LIMIT_PER_ROUND_PLAYER 10 // Limit per round and player value.
new g_bombs_bought[33] // Global variable that indicates the number of bombs that have been bought in a round by a given player
new g_itemid // This should appear anywhere. Look for it
new g_maxplayers // Most of codes already has this variable
public plugin_init()
{
// If not registered...
register_event("HLTV", "event_newround", "a", "1=0", "2=0")
// This should also appear
g_itemid = zp_register_extra_item("blablabla")
g_maxplayers = get_maxplayers() // If there was already a g_maxplayers variable, this should appear here
}
public event_newround()
{
new id
for(new id=1; id<=g_maxplayers; id++)
g_bombs_bought[id] = 0 // At the beginning of the round the number of bombs bought is zero
}
public zp_extra_item_selected(id, itemid)
{
if(itemid == g_itemid)
{
if(g_bombs_bought == LIMIT_PER_ROUND_PLAYER) // If the limit is reached...
{
client_print(id, print_chat, "Limit reached. Can't buy a jump bomb") // We send a message
return PLUGIN_HANDLED // and refund the user
}
else // In other case...
{
// Blablaba...
g_bombs_bought[id]++ // The number of bought bombs by this user should increase by one.
}
}
return PLUGIN_CONTINUE
}
__________________