zombie_plague40.sma:
On drop:
PHP Code:
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)
}
}
}
On pickup:
PHP Code:
public fw_AddPlayerItem(id, weapon_ent)
{
// HACK: Retrieve our custom extra ammo from the weapon
static extra_ammo
extra_ammo = pev(weapon_ent, PEV_ADDITIONAL_AMMO)
// If present
if (extra_ammo)
{
// Get weapon's id
static weaponid
weaponid = cs_get_weapon_id(weapon_ent)
// Add to player's bpammo
ExecuteHamB(Ham_GiveAmmo, id, extra_ammo, AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, 0)
I told you to store fuel in pev_iuser2 (since pev_iuser1 is used by ZP to store BP ammo) on drop and restore on pickup, just like in code above. But instead of giving ammo, set fuel.
Read ZP plugin source code for more information.
__________________