cs_set_weapon_ammo doesn't work that way. Index is the weapon entity's index.
Fakemeta way:
Code:
stock fm_get_weapon_id(index, const weapon[])
{
new ent = -1;
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", weapon)) != 0)
{
if(index == pev(ent, pev_owner))
return ent;
}
return 0;
}
Engine way:
Code:
stock get_weapon_id(id, const weapon[])
{
new ent = -1
while((ent = find_ent_by_class(ent, weapon)) != 0)
{
if(id == entity_get_edict(ent, EV_ENT_owner))
return ent
}
return 0
}
Fakemeta: cs_set_weapon_ammo( fm_get_weapon_id( player, "weapon_*" ), ammo )
Engine: cs_set_weapon_ammo( get_weapon_id( player, "weapon_*" ), ammo )
Also you must skip dead players in spawn event.
__________________