Skip to content

Commit

Permalink
Fix error from multiple users taking damage at same time
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Jun 20, 2024
1 parent 0fa98ea commit 90cca4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions scripting/randomizer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma newdecls required

#define PLUGIN_VERSION "1.11.1"
#define PLUGIN_VERSION "1.11.2"
#define PLUGIN_VERSION_REVISION "manual"

#define CONFIG_MAXCHAR 64
Expand Down Expand Up @@ -354,13 +354,13 @@ bool g_bClientRefresh[MAXPLAYERS];

TFClassType g_iClientCurrentClass[MAXPLAYERS + 1][4];
ClientClassDebug g_ClientClassDebug[MAXPLAYERS + 1][10];
bool g_bOnTakeDamageClass[MAXPLAYERS + 1];
bool g_bFeignDeath[MAXPLAYERS + 1];
int g_iHypeMeterLoaded[MAXPLAYERS + 1] = {INVALID_ENT_REFERENCE, ...};
bool g_bWeaponDecap[MAXPLAYERS + 1];
Handle g_hTimerClientHud[MAXPLAYERS + 1];

bool g_bOnTakeDamage;
bool g_bOnTakeDamageClass;
int g_iGainingRageWeapon = INVALID_ENT_REFERENCE;
int g_iTouchItem = INVALID_ENT_REFERENCE;
int g_iTouchToucher = INVALID_ENT_REFERENCE;
Expand Down
7 changes: 4 additions & 3 deletions scripting/randomizer/event.sp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ public void Event_WeaponJump(Event event, const char[] sName, bool bDontBroadcas
return;

//Class check should be done by this point, revert class so pain sound can be played as actual class
if (g_bOnTakeDamage)
int iClient = GetClientOfUserId(event.GetInt("userid"));
if (g_bOnTakeDamageClass[iClient])
{
RevertClientClass(GetClientOfUserId(event.GetInt("userid")));
g_bOnTakeDamageClass = false;
RevertClientClass(iClient);
g_bOnTakeDamageClass[iClient] = false;
}
}
6 changes: 3 additions & 3 deletions scripting/randomizer/sdkhook.sp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Action Client_OnTakeDamage(int iVictim, int &iAttacker, int &iInflictor,
// IsPlayerClass not always called on linux,
// and some class checks don't even use IsPlayerClass.
SetClientClass(iAttacker, TF2_GetDefaultClassFromItem(iWeapon));
g_bOnTakeDamageClass = true;
g_bOnTakeDamageClass[iAttacker] = true;

Properties_LoadWeaponPropInt(iAttacker, iWeapon, "m_iDecapitations");
g_bWeaponDecap[iAttacker] = true;
Expand All @@ -84,10 +84,10 @@ public void Client_OnTakeDamagePost(int iVictim, int iAttacker, int iInflictor,
g_bOnTakeDamage = false;
g_bFeignDeath[iVictim] = false;

if (g_bOnTakeDamageClass)
if (g_bOnTakeDamageClass[iAttacker])
{
RevertClientClass(iAttacker);
g_bOnTakeDamageClass = false;
g_bOnTakeDamageClass[iAttacker] = false;
}

if (0 < iAttacker <= MaxClients)
Expand Down

0 comments on commit 90cca4c

Please sign in to comment.