From 412dc7255783afa8b9134bf518f6c1badc91ab07 Mon Sep 17 00:00:00 2001 From: FortyTwoFortyTwo Date: Fri, 25 Oct 2024 17:27:03 +0100 Subject: [PATCH] Fix Engineer able to build multiple dispensers (#167) --- .../sourcemod/scripting/superzombiefortress.sp | 2 +- addons/sourcemod/scripting/szf/console.sp | 4 ++++ addons/sourcemod/scripting/szf/stocks.sp | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/superzombiefortress.sp b/addons/sourcemod/scripting/superzombiefortress.sp index 4f2686e7..e45ce6ef 100644 --- a/addons/sourcemod/scripting/superzombiefortress.sp +++ b/addons/sourcemod/scripting/superzombiefortress.sp @@ -19,7 +19,7 @@ #include "include/superzombiefortress.inc" -#define PLUGIN_VERSION "4.6.6" +#define PLUGIN_VERSION "4.6.7" #define PLUGIN_VERSION_REVISION "manual" #define MAX_CONTROL_POINTS 8 diff --git a/addons/sourcemod/scripting/szf/console.sp b/addons/sourcemod/scripting/szf/console.sp index 6a2da9b0..9f404988 100644 --- a/addons/sourcemod/scripting/szf/console.sp +++ b/addons/sourcemod/scripting/szf/console.sp @@ -310,5 +310,9 @@ public Action Console_Build(int iClient, const char[] sCommand, int iArgs) if (nObjectType != TFObject_Dispenser && nObjectType != TFObject_Sentry) return Plugin_Handled; + // Dispenser have m_bCarried set to 1 to disable healing, but also allowed to build multiples, which we want to prevent that + if (TF2_GetBuilding(iClient, nObjectType) != INVALID_ENT_REFERENCE) + return Plugin_Handled; + return Plugin_Continue; } \ No newline at end of file diff --git a/addons/sourcemod/scripting/szf/stocks.sp b/addons/sourcemod/scripting/szf/stocks.sp index fcd1a9c0..6f7bcbd8 100644 --- a/addons/sourcemod/scripting/szf/stocks.sp +++ b/addons/sourcemod/scripting/szf/stocks.sp @@ -812,6 +812,22 @@ stock void CheckClientWeapons(int iClient) } } +stock int TF2_GetBuilding(int iClient, TFObjectType nType, TFObjectMode nMode = TFObjectMode_None) +{ + int iBuilding = MaxClients+1; + while ((iBuilding = FindEntityByClassname(iBuilding, "obj_*")) > MaxClients) + { + if (GetEntPropEnt(iBuilding, Prop_Send, "m_hBuilder") == iClient + && view_as(GetEntProp(iBuilding, Prop_Send, "m_iObjectType")) == nType + && view_as(GetEntProp(iBuilding, Prop_Send, "m_iObjectMode")) == nMode) + { + return iBuilding; + } + } + + return INVALID_ENT_REFERENCE; +} + //////////////// // Cookie ////////////////