diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 4e6b29f..a8055ad 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -784,10 +784,6 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa InfectUpdateScore(attacker, client); } - // Get a list of all client's weapon indexes. - new weapons[WeaponsSlot]; - WeaponsGetClientWeapons(client, weapons); - // Check if weapons drop is enabled. new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]); @@ -878,14 +874,11 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false) RoundEndOnClientInfected(); 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) - 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. if (respawn) diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index 1e56307..fcd57d7 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -779,26 +779,26 @@ stock WeaponsForceClientDrop(client, weapon) * @param client The client index. * @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. - // While GetPlayerWeaponSlot returns a valid projectile, remove it and then test again. - new grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile); - while (grenade != -1) + // This while-structure is a stupid sloppy annoying workaround to stop the "unintended assignment" warning. I hate those. + // While GetPlayerWeaponSlot returns a valid weapon, remove it and then test again. + new weapon = GetPlayerWeaponSlot(client, _:slot); + while (weapon != -1) { - // Check if we drop or strip the grenade. + // Check if we drop or strip the weapon. if (weaponsdrop) { - WeaponsForceClientDrop(client, grenade); + WeaponsForceClientDrop(client, weapon); } else { - RemovePlayerItem(client, grenade); - AcceptEntityInput(grenade, "Kill"); + RemovePlayerItem(client, weapon); + AcceptEntityInput(weapon, "Kill"); } - // Find next grenade. - grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile); + // Find next weapon. + 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. - 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) GivePlayerItem(client, "weapon_knife");