Skip to content

Commit

Permalink
Fix Engineer able to build multiple dispensers (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Oct 25, 2024
1 parent 563d185 commit 412dc72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/superzombiefortress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions addons/sourcemod/scripting/szf/console.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 16 additions & 0 deletions addons/sourcemod/scripting/szf/stocks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TFObjectType>(GetEntProp(iBuilding, Prop_Send, "m_iObjectType")) == nType
&& view_as<TFObjectMode>(GetEntProp(iBuilding, Prop_Send, "m_iObjectMode")) == nMode)
{
return iBuilding;
}
}

return INVALID_ENT_REFERENCE;
}

////////////////
// Cookie
////////////////
Expand Down

0 comments on commit 412dc72

Please sign in to comment.