Better with cs_set_bpammo.
Example for all weapons, and max ammo for each weapon.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#define PLUGIN "Give Weapon"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"
new const g_iMaxBpAmmo[] = { -1, 52, -1, 90, -1, 32, 1, 100, 90, -1, 120, 100, 100, 90, 90, 90, 100, 100,
30, 120, 200, 32, 90, 120, 60, -1, 35, 90, 90, -1, 100 }
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd( "say", "ClientCommand_GiveWeapon" )
register_clcmd( "say_team", "ClientCommand_GiveWeapon" )
}
public ClientCommand_GiveWeapon(id)
{
new szArg1[14] // smokegrenade
read_argv(1, szArg1, charsmax(szArg1))
if( szArg1[0] == '/' )
{
new szWeaponName[20] = "weapon_" // weapon_smokegrenade
new iWeaponId
add(szWeaponName, charsmax(szWeaponName), szArg1[1])
if( ( iWeaponId = get_weaponid(szWeaponName) ) )
{
give_item(id, szWeaponName)
cs_set_user_bpammo(id, iWeaponId, g_iMaxBpAmmo[iWeaponId])
return PLUGIN_HANDLED_MAIN
}
}
return PLUGIN_CONTINUE
}
__________________