AFAIK, give_item return the entity index if it was actually given.
PHP Code:
new iWeapon = give_item(id, "weapon_m4a1")
if( iWeapon )
{
cs_set_weapon_ammp(iWeapon, 30) // but should already be 30 when you receive it
}
cs_set_user_bpammo(id, CSW_M4A1, 90)
If you need to retrieve player weapon entity index, then use my stock :
http://forums.alliedmods.net/showthread.php?t=85962
PHP Code:
new iM4A1 = ham_get_user_weaponent(id, CSW_M4A1, 1)
//new iM4A1 = ham_get_user_weaponent2(id, CSW_M4A1) // 1st one is faster, but this one is fine too.
if( iM4A1 )
{
cs_set_weapon_ammo(iM4A1, 30)
}
__________________