Skip to content

Commit 90cca4c

Browse files
Fix error from multiple users taking damage at same time
1 parent 0fa98ea commit 90cca4c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

scripting/randomizer.sp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#pragma newdecls required
1717

18-
#define PLUGIN_VERSION "1.11.1"
18+
#define PLUGIN_VERSION "1.11.2"
1919
#define PLUGIN_VERSION_REVISION "manual"
2020

2121
#define CONFIG_MAXCHAR 64
@@ -354,13 +354,13 @@ bool g_bClientRefresh[MAXPLAYERS];
354354

355355
TFClassType g_iClientCurrentClass[MAXPLAYERS + 1][4];
356356
ClientClassDebug g_ClientClassDebug[MAXPLAYERS + 1][10];
357+
bool g_bOnTakeDamageClass[MAXPLAYERS + 1];
357358
bool g_bFeignDeath[MAXPLAYERS + 1];
358359
int g_iHypeMeterLoaded[MAXPLAYERS + 1] = {INVALID_ENT_REFERENCE, ...};
359360
bool g_bWeaponDecap[MAXPLAYERS + 1];
360361
Handle g_hTimerClientHud[MAXPLAYERS + 1];
361362

362363
bool g_bOnTakeDamage;
363-
bool g_bOnTakeDamageClass;
364364
int g_iGainingRageWeapon = INVALID_ENT_REFERENCE;
365365
int g_iTouchItem = INVALID_ENT_REFERENCE;
366366
int g_iTouchToucher = INVALID_ENT_REFERENCE;

scripting/randomizer/event.sp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ public void Event_WeaponJump(Event event, const char[] sName, bool bDontBroadcas
203203
return;
204204

205205
//Class check should be done by this point, revert class so pain sound can be played as actual class
206-
if (g_bOnTakeDamage)
206+
int iClient = GetClientOfUserId(event.GetInt("userid"));
207+
if (g_bOnTakeDamageClass[iClient])
207208
{
208-
RevertClientClass(GetClientOfUserId(event.GetInt("userid")));
209-
g_bOnTakeDamageClass = false;
209+
RevertClientClass(iClient);
210+
g_bOnTakeDamageClass[iClient] = false;
210211
}
211212
}

scripting/randomizer/sdkhook.sp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Action Client_OnTakeDamage(int iVictim, int &iAttacker, int &iInflictor,
6262
// IsPlayerClass not always called on linux,
6363
// and some class checks don't even use IsPlayerClass.
6464
SetClientClass(iAttacker, TF2_GetDefaultClassFromItem(iWeapon));
65-
g_bOnTakeDamageClass = true;
65+
g_bOnTakeDamageClass[iAttacker] = true;
6666

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

87-
if (g_bOnTakeDamageClass)
87+
if (g_bOnTakeDamageClass[iAttacker])
8888
{
8989
RevertClientClass(iAttacker);
90-
g_bOnTakeDamageClass = false;
90+
g_bOnTakeDamageClass[iAttacker] = false;
9191
}
9292

9393
if (0 < iAttacker <= MaxClients)

0 commit comments

Comments
 (0)