From 51ae6cec1a9c4ff38348834197ca03cd55257729 Mon Sep 17 00:00:00 2001 From: BotoX Date: Wed, 21 Mar 2018 21:49:19 +0100 Subject: [PATCH] WeaponCleaner: fix server crash --- WeaponCleaner/scripting/WeaponCleaner.sp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/WeaponCleaner/scripting/WeaponCleaner.sp b/WeaponCleaner/scripting/WeaponCleaner.sp index c3b95349..be4aca6c 100644 --- a/WeaponCleaner/scripting/WeaponCleaner.sp +++ b/WeaponCleaner/scripting/WeaponCleaner.sp @@ -33,7 +33,7 @@ public Plugin myinfo = public void OnPluginStart() { g_bEnableCSGOFix = view_as(GetEngineVersion() == Engine_CSGO); - + g_CVar_MaxWeapons = CreateConVar("sm_weaponcleaner_max", "5", "The maximum amount of weapons allowed in the game.", 0, true, 0.0, true, MAX_WEAPONS - 1.0); g_MaxWeapons = g_CVar_MaxWeapons.IntValue; g_CVar_MaxWeapons.AddChangeHook(OnConVarChanged); @@ -191,7 +191,8 @@ public Action OnWeaponDrop(int client, int entity) return; // Kill all dropped weapons during mp_freezetime - if(GetTime() < g_RealRoundStartedTime) + // or if no weapons are allowed at all + if(GetTime() < g_RealRoundStartedTime || !g_MaxWeapons) { // Kill it AcceptEntityInput(entity, "Kill"); @@ -204,6 +205,9 @@ public Action OnWeaponDrop(int client, int entity) bool InsertWeapon(int entity) { + if(!g_MaxWeapons) + return false; + int entref = EntIndexToEntRef(entity); // Try to find a free slot