Fixed not all grenades being stripped when infected.
This commit is contained in:
parent
c2a40196eb
commit
1f09e1d0c7
@ -609,39 +609,8 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
|
|||||||
new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]);
|
new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]);
|
||||||
|
|
||||||
// This must be after the event forwarding because it fixes a problem caused by changing models in ClassOnClientInfected.
|
// This must be after the event forwarding because it fixes a problem caused by changing models in ClassOnClientInfected.
|
||||||
// Loop through array slots and force drop.
|
// Remove all weapons but knife.
|
||||||
// x = weapon slot.
|
WeaponsRemoveAllClientWeapons(client, weaponsdrop);
|
||||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
|
||||||
{
|
|
||||||
// If weapon is invalid, then stop.
|
|
||||||
if (weapons[x] == -1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (weaponsdrop)
|
|
||||||
{
|
|
||||||
// If this is the knife slot, then stop.
|
|
||||||
if (WeaponsSlot:x == Slot_Melee)
|
|
||||||
{
|
|
||||||
// Strip knife.
|
|
||||||
RemovePlayerItem(client, weapons[x]);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force client to drop weapon.
|
|
||||||
WeaponsForceClientDrop(client, weapons[x]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Strip weapon.
|
|
||||||
RemovePlayerItem(client, weapons[x]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
|
|
||||||
GivePlayerItem(client, "weapon_knife");
|
|
||||||
|
|
||||||
// Switch the player to terrorists.
|
// Switch the player to terrorists.
|
||||||
// TODO: A solution to stop confusing bots? Respawn and teleport?
|
// TODO: A solution to stop confusing bots? Respawn and teleport?
|
||||||
@ -1191,4 +1160,4 @@ public Action:InfectHumanCommand(client, argc)
|
|||||||
InfectManualHuman(client, targets, result, respawn, protect);
|
InfectManualHuman(client, targets, result, respawn, protect);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
@ -778,3 +778,80 @@ stock WeaponsForceClientDrop(client, weapon)
|
|||||||
// Force client to drop weapon.
|
// Force client to drop weapon.
|
||||||
SDKCall(g_hToolsCSWeaponDrop, client, weapon, true, false);
|
SDKCall(g_hToolsCSWeaponDrop, client, weapon, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to explicitly remove projectile weapons from a client.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weaponsdrop True to force drop on all weapons, false to strip.
|
||||||
|
*/
|
||||||
|
stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop)
|
||||||
|
{
|
||||||
|
// This while-structure is a stupid sloppy annoying workaround to stop the "unintended assignment" warning. I hate those.
|
||||||
|
// While GetPlayerWeaponSlot returns a valid projectile, remove it and then test again.
|
||||||
|
new grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile);
|
||||||
|
while (grenade != -1)
|
||||||
|
{
|
||||||
|
// Check if we drop or strip the grenade.
|
||||||
|
if (weaponsdrop)
|
||||||
|
{
|
||||||
|
WeaponsForceClientDrop(client, grenade);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemovePlayerItem(client, grenade);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find next grenade.
|
||||||
|
grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all weapons, except knife, on a client, with options.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weaponsdrop True to force drop on all weapons, false to strip.
|
||||||
|
*/
|
||||||
|
stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
|
||||||
|
{
|
||||||
|
// Get a list of all client's weapon indexes.
|
||||||
|
new weapons[WeaponsSlot];
|
||||||
|
WeaponsGetClientWeapons(client, weapons);
|
||||||
|
|
||||||
|
// Loop through array slots and force drop.
|
||||||
|
// x = weapon slot.
|
||||||
|
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||||
|
{
|
||||||
|
// If weapon is invalid, then stop.
|
||||||
|
if (weapons[x] == -1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is the knife slot, then strip it and stop.
|
||||||
|
if (WeaponsSlot:x == Slot_Melee)
|
||||||
|
{
|
||||||
|
// Strip knife.
|
||||||
|
RemovePlayerItem(client, weapons[x]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weaponsdrop)
|
||||||
|
{
|
||||||
|
// Force client to drop weapon.
|
||||||
|
WeaponsForceClientDrop(client, weapons[x]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Strip weapon.
|
||||||
|
RemovePlayerItem(client, weapons[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove left-over projectiles.
|
||||||
|
WeaponsRemoveClientGrenades(client, weaponsdrop);
|
||||||
|
|
||||||
|
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
|
||||||
|
GivePlayerItem(client, "weapon_knife");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user