diff --git a/WeaponCleaner/scripting/WeaponCleaner.sp b/WeaponCleaner/scripting/WeaponCleaner.sp index cdc2be6..c3b9534 100644 --- a/WeaponCleaner/scripting/WeaponCleaner.sp +++ b/WeaponCleaner/scripting/WeaponCleaner.sp @@ -15,6 +15,8 @@ int g_RealRoundStartedTime; int g_MaxWeapons; int g_MaxWeaponLifetime; +bool g_bEnableCSGOFix; + #define MAX_WEAPONS MAXPLAYERS int G_WeaponArray[MAX_WEAPONS][2]; @@ -30,6 +32,8 @@ 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); @@ -138,7 +142,19 @@ public void OnEntityDestroyed(int entity) public void OnWeaponSpawned(int entity) { - //SDKUnhook(entity, SDKHook_Spawn, OnWeaponSpawned); + if (g_bEnableCSGOFix) + { + SDKUnhook(entity, SDKHook_Spawn, OnWeaponSpawned); + + RequestFrame(OnWeaponSpawnedPost, entity); + } + else OnWeaponSpawnedPost(entity); +} + +public void OnWeaponSpawnedPost(int entity) +{ + if(!IsValidEntity(entity)) + return; int HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID"); // Should not be cleaned since it's a map spawned weapon