From a7e88cdeab750c2023884c1be9a7453ac1e436af Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 1 Jul 2018 20:11:24 +0200 Subject: [PATCH] ExtraCommands: Fix GivePlayerItem on CS:GO. Giving certain weapons that used to exist on CS:S to players on CS:GO, causes the server to crash. Good shit volvo :^) --- ExtraCommands/scripting/ExtraCommands.sp | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ExtraCommands/scripting/ExtraCommands.sp b/ExtraCommands/scripting/ExtraCommands.sp index 85e43311..f429a338 100644 --- a/ExtraCommands/scripting/ExtraCommands.sp +++ b/ExtraCommands/scripting/ExtraCommands.sp @@ -412,7 +412,7 @@ public Action Command_Weapon(int client, int argc) { for(int i = 0; i < iTargetCount; i++) { - int ent = GivePlayerItem(iTargets[i], sWeapon); + int ent = GivePlayerItemFixed(iTargets[i], sWeapon); if(ent == -1) { ReplyToCommand(client, "[SM] Invalid Weapon"); @@ -1348,3 +1348,30 @@ stock any clamp(any input, any min, any max) return retval > max ? max : retval; } + +stock int GivePlayerItemFixed(int client, const char[] item) +{ + static bool bEngineVersionIsCSGO; + + // These weapons 'exist' on csgo, but attempting to give them causes a crash. + if (bEngineVersionIsCSGO || GetEngineVersion() == Engine_CSGO) + { + bEngineVersionIsCSGO = true; + + if (StrEqual(item, "weapon_galil", false) || + StrEqual(item, "weapon_m3", false) || + StrEqual(item, "weapon_mp5navy", false) || + StrEqual(item, "weapon_p228", false) || + StrEqual(item, "weapon_scout", false) || + StrEqual(item, "weapon_sg550", false) || + StrEqual(item, "weapon_sg552", false) || + StrEqual(item, "weapon_tmp", false) || + StrEqual(item, "weapon_usp", false)) + { + LogError("Prevented giving ent: %s", item); + return -1; + } + } + + return GivePlayerItem(client, item); +}