Skip to content

Commit

Permalink
Removing maxspeed hooks for now for v4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Jun 14, 2020
1 parent e3ce6b1 commit 10fce68
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/scripting/Header.sp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ int g_iAnnotationEventId = 0;
*/

float SpeedLevel = 1.0;
#if defined USE_MAXSPEED_HOOK
float MaxSpeedDefaults[MAXPLAYERS+1] = 0.0;
float MaxSpeedOverride[MAXPLAYERS+1] = 0.0;
#endif

/**
* Booleans
Expand All @@ -66,7 +68,10 @@ bool IsPlayerWinner[MAXPLAYERS+1] = false;
bool HideHudGamemodeText = false;
bool AllowCosmetics = false;
bool ForceCalculationCritical = false;

#if defined USE_MAXSPEED_HOOK
bool ApplyMaxSpeedOverrides = false;
#endif

/**
* Enums
Expand Down
12 changes: 11 additions & 1 deletion src/scripting/Hooks.sp
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
//#define USE_MAXSPEED_HOOK

public void AttachPlayerHooks(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, Hooks_OnTakeDamage);

#if defined USE_MAXSPEED_HOOK
SDKHook(client, SDKHook_PreThink, Hooks_OnPreThink);
#endif
}

public void DetachPlayerHooks(int client)
{
SDKUnhook(client, SDKHook_OnTakeDamage, Hooks_OnTakeDamage);

#if defined USE_MAXSPEED_HOOK
SDKUnhook(client, SDKHook_PreThink, Hooks_OnPreThink);
#endif
}

public Action Hooks_OnTakeDamage(int victim, int &attackerId, int &inflictor, float &damage, int &damagetype)
Expand Down Expand Up @@ -43,6 +51,7 @@ public Action Hooks_OnTakeDamage(int victim, int &attackerId, int &inflictor, fl
return Plugin_Continue;
}

#if defined USE_MAXSPEED_HOOK
public void Hooks_OnPreThink(int client)
{
if (!IsPluginEnabled)
Expand All @@ -60,4 +69,5 @@ public void Hooks_OnPreThink(int client)
// {
// MaxSpeedDefaults
// }
}
}
#endif
19 changes: 19 additions & 0 deletions src/scripting/Stocks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,23 @@ stock float NormalizeAngle(float angle)
}

return angle;
}

stock int GetRandomParticipatingPlayerId()
{
int loop = 0;

while (loop < 32)
{
loop++;

Player player = new Player(GetRandomInt(1, MaxClients));

if (player.IsValid && player.IsParticipating)
{
return player.ClientId;
}
}

return -1;
}

0 comments on commit 10fce68

Please sign in to comment.