diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index bd5ecf8..09d1b25 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -239,6 +239,10 @@ zr_weapons "1" // Default: "1" zr_weapons_restrict "1" +// Restricts zombies from picking up weapons after the round has ended but before the next round has begun. +// Default: "1" +zr_weapons_restrict_endequip "1" + // ZMarket // Allow player to buy from a list of weapons in the weapons config. diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 73ac8ba..9c8af73 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -72,6 +72,7 @@ enum CvarsList Handle:CVAR_CLASSES_ADMIN_SELECT, Handle:CVAR_WEAPONS, Handle:CVAR_WEAPONS_RESTRICT, + Handle:CVAR_WEAPONS_RESTRICT_ENDEQUIP, Handle:CVAR_WEAPONS_ZMARKET, Handle:CVAR_WEAPONS_ZMARKET_BUYZONE, Handle:CVAR_WEAPONS_ZMARKET_REBUY, @@ -288,6 +289,7 @@ CvarsCreate() // Restrict g_hCvarsList[CVAR_WEAPONS_RESTRICT] = CreateConVar("zr_weapons_restrict", "1", "Enable weapon restriction module, disabling this will disable weapon restriction commands."); + g_hCvarsList[CVAR_WEAPONS_RESTRICT_ENDEQUIP] = CreateConVar("zr_weapons_restrict_endequip", "1", "Restricts zombies from picking up weapons after the round has ended but before the next round has begun."); // ZMarket g_hCvarsList[CVAR_WEAPONS_ZMARKET] = CreateConVar("zr_weapons_zmarket", "1", "Allow player to buy from a list of weapons in the weapons config."); diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index a6417bb..2d477b5 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -214,6 +214,12 @@ RestrictOnClientSpawn(client) */ RestrictOnRoundEnd() { + new bool:restrictzombieequip = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT_ENDEQUIP]); + if (!restrictzombieequip) + { + return; + } + // x = Client index. for (new x = 1; x <= MaxClients; x++) { diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index e3e4a76..dbb6a95 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -343,6 +343,9 @@ WeaponsOnClientSpawn(client) */ WeaponsOnClientSpawnPost(client) { + // Refresh all weapons on clients to cleanup any rendering errors. + WeaponsRefreshAllClientWeapons(client); + // Forward event to sub-modules. ZMarketOnClientSpawnPost(client); } @@ -805,6 +808,31 @@ stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop) } } +/** + * Refresh a weapon by taking it and giving it back. + * + * @param client The client index. + * @param slot The weapon slot to refresh. (see enum WeaponsSlot) + */ +stock WeaponsRefreshClientWeapon(client, WeaponsSlot:slot) +{ + new weaponindex = GetPlayerWeaponSlot(client, _:slot); + + // If weapon is invalid, then stop. + if (weaponindex == -1) + { + return; + } + + // Get the classname of the weapon to re-give. + decl String:entityname[WEAPONS_MAX_LENGTH]; + GetEdictClassname(weaponindex, entityname, sizeof(entityname)); + + // Refresh weapon. + RemovePlayerItem(client, weaponindex); + GivePlayerItem(client, entityname); +} + /** * Remove all weapons, except knife, on a client, with options. * @@ -853,3 +881,28 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop) // Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning) GivePlayerItem(client, "weapon_knife"); } + +/** + * Refresh a weapon by taking it and giving it back. + * + * @param client The client index. + */ +stock WeaponsRefreshAllClientWeapons(client) +{ + // 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; + } + + WeaponsRefreshClientWeapon(client, WeaponsSlot:x); + } +}