Slight optimization
PHP Code:
public giveheifnothas(id)
{
if ( !user_has_weapon( id , CSW_HEGRENADE ) )
give_item( id , "weapon_hegrenade" );
cs_set_user_bpammo(id, CSW_HEGRENADE, NADEAMOUNT);
}
Do not use what phoenix120 posted. This can be done much more efficiently.
This is the simplest way that requires little\no scripting knowledge. The only requirement is that the player needs to be given or purchase the first grenade (which can be done @ spawn)
PHP Code:
#include <csx>
public grenade_throw( id , greindex , wId )
{
if ( wId == CSW_HEGRENADE )
cs_set_user_bpammo( id , CSW_HEGRENADE, NADEAMOUNT);
}
Here's a full unlimited he-grenade plugin; the user is given a grenade when spawned so no purchase necessary. Since grenades are unlimited, the variable g_GrenadeNum simply is just the number that will display as the ammo amount for he-grenades (though, must be > 0).
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <csx>
#include <fun>
const g_GrenadeNum = 5;
public plugin_init()
{
register_plugin( "unlimited hegrenades" , "1.0" , "bugsy" );
RegisterHam( Ham_Spawn , "player" , "fw_HamSpawn_Post" , 1 );
}
public fw_HamSpawn_Post( id )
{
if ( is_user_alive( id ) )
{
give_item( id , "weapon_hegrenade" );
cs_set_user_bpammo( id , CSW_HEGRENADE , g_GrenadeNum );
}
}
public grenade_throw( id , greindex , wId )
{
if ( wId == CSW_HEGRENADE )
cs_set_user_bpammo( id , CSW_HEGRENADE , g_GrenadeNum + 1 );
}
__________________