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 :^)
This commit is contained in:
zaCade 2018-07-01 20:11:24 +02:00
parent d1395ffd42
commit a7e88cdeab

View File

@ -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);
}