General: Clear knife slot entirely instead of once.

Since the taser would remain, and would break shit. :P
This commit is contained in:
zaCade 2018-07-29 15:13:31 +02:00
parent 870ef51197
commit f5245b0920
2 changed files with 19 additions and 23 deletions

View File

@ -784,10 +784,6 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
InfectUpdateScore(attacker, client); InfectUpdateScore(attacker, client);
} }
// Get a list of all client's weapon indexes.
new weapons[WeaponsSlot];
WeaponsGetClientWeapons(client, weapons);
// Check if weapons drop is enabled. // Check if weapons drop is enabled.
new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]); new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]);
@ -878,14 +874,11 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
RoundEndOnClientInfected(); RoundEndOnClientInfected();
ZTele_OnClientInfected(client); ZTele_OnClientInfected(client);
// Remove all knifes.
WeaponsClearClientWeaponSlot(client, Slot_Melee);
// Give human a new knife. (If you leave the old one there will be glitches with the knife positioning) // Give human a new knife. (If you leave the old one there will be glitches with the knife positioning)
new knife = GetPlayerWeaponSlot(client, _:Slot_Melee);
if (knife != -1)
{
RemovePlayerItem(client, knife);
AcceptEntityInput(knife, "Kill");
GivePlayerItem(client, "weapon_knife"); GivePlayerItem(client, "weapon_knife");
}
// Check if we should respawn the client. // Check if we should respawn the client.
if (respawn) if (respawn)

View File

@ -779,26 +779,26 @@ stock WeaponsForceClientDrop(client, weapon)
* @param client The client index. * @param client The client index.
* @param weaponsdrop True to force drop on all weapons, false to strip. * @param weaponsdrop True to force drop on all weapons, false to strip.
*/ */
stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop) stock WeaponsClearClientWeaponSlot(client, WeaponsSlot:slot, bool:weaponsdrop)
{ {
// This while-structure is a stupid sloppy annoying workaround to stop the "unintended assignment" warning. I hate those. // 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. // While GetPlayerWeaponSlot returns a valid weapon, remove it and then test again.
new grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile); new weapon = GetPlayerWeaponSlot(client, _:slot);
while (grenade != -1) while (weapon != -1)
{ {
// Check if we drop or strip the grenade. // Check if we drop or strip the weapon.
if (weaponsdrop) if (weaponsdrop)
{ {
WeaponsForceClientDrop(client, grenade); WeaponsForceClientDrop(client, weapon);
} }
else else
{ {
RemovePlayerItem(client, grenade); RemovePlayerItem(client, weapon);
AcceptEntityInput(grenade, "Kill"); AcceptEntityInput(weapon, "Kill");
} }
// Find next grenade. // Find next weapon.
grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile); weapon = GetPlayerWeaponSlot(client, _:slot);
} }
} }
@ -872,8 +872,11 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
} }
} }
// Remove left-over knifes.
WeaponsClearClientWeaponSlot(client, Slot_Melee, false);
// Remove left-over projectiles. // Remove left-over projectiles.
WeaponsRemoveClientGrenades(client, weaponsdrop); WeaponsClearClientWeaponSlot(client, Slot_Projectile, weaponsdrop);
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning) // Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
GivePlayerItem(client, "weapon_knife"); GivePlayerItem(client, "weapon_knife");