WeaponCleaner: fix server crash

This commit is contained in:
BotoX 2018-03-21 21:49:19 +01:00
parent 3d24fb83e0
commit 51ae6cec1a

View File

@ -33,7 +33,7 @@ public Plugin myinfo =
public void OnPluginStart() public void OnPluginStart()
{ {
g_bEnableCSGOFix = view_as<bool>(GetEngineVersion() == Engine_CSGO); g_bEnableCSGOFix = view_as<bool>(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_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_MaxWeapons = g_CVar_MaxWeapons.IntValue;
g_CVar_MaxWeapons.AddChangeHook(OnConVarChanged); g_CVar_MaxWeapons.AddChangeHook(OnConVarChanged);
@ -191,7 +191,8 @@ public Action OnWeaponDrop(int client, int entity)
return; return;
// Kill all dropped weapons during mp_freezetime // 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 // Kill it
AcceptEntityInput(entity, "Kill"); AcceptEntityInput(entity, "Kill");
@ -204,6 +205,9 @@ public Action OnWeaponDrop(int client, int entity)
bool InsertWeapon(int entity) bool InsertWeapon(int entity)
{ {
if(!g_MaxWeapons)
return false;
int entref = EntIndexToEntRef(entity); int entref = EntIndexToEntRef(entity);
// Try to find a free slot // Try to find a free slot