View Single Post
SergiCruz
Senior Member
Join Date: Mar 2012
Location: Andalucía, España
Old 04-18-2015 , 05:00   Re: [REQ] Jump-Grenade with limit per round
Reply With Quote #4

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=1id<=g_maxplayersid++)
        
g_bombs_bought[id] = // At the beginning of the round the number of bombs bought is zero
}

public 
zp_extra_item_selected(iditemid)
{
    if(
itemid == g_itemid)
    {
        if(
g_bombs_bought == LIMIT_PER_ROUND_PLAYER// If the limit is reached...
        
{
            
client_print(idprint_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

__________________
PodBot waypointer. Feel free to ask for waypoints for zm_ maps.
SergiCruz is offline
Send a message via MSN to SergiCruz