複製程式
stock drop_weapons(id, dropwhat)
{
// Get user weapons
static weapons[32], num, i, weaponid
num = 0 // reset passed weapons count (bugfix)
get_user_weapons(id, weapons, num)
// Loop through them and drop primaries or secondaries
for (i = 0; i < num; i++)
{
// Prevent re-indexing the array
weaponid = weapons[i]
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
// Get weapon entity
static wname[32], weapon_ent
get_weaponname(weaponid, wname, charsmax(wname))
weapon_ent = fm_find_ent_by_owner(-1, wname, id)
// Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
// Player drops the weapon and looses his bpammo
engclient_cmd(id, "drop", wname)
cs_set_user_bpammo(id, weaponid, 0)
}
}
}
drop_weapons(id, 1) -掉主槍
drop_weapons(id, 2) - 掉手槍