From 10fce68e462458cffd70ed3dbec70f9c140ad344 Mon Sep 17 00:00:00 2001 From: Steven P Date: Sun, 14 Jun 2020 18:44:53 +0100 Subject: [PATCH] Removing maxspeed hooks for now for v4 release --- src/scripting/Header.sp | 5 +++++ src/scripting/Hooks.sp | 12 +++++++++++- src/scripting/Stocks.sp | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/scripting/Header.sp b/src/scripting/Header.sp index 959231e5..08694811 100644 --- a/src/scripting/Header.sp +++ b/src/scripting/Header.sp @@ -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 @@ -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 diff --git a/src/scripting/Hooks.sp b/src/scripting/Hooks.sp index 6c955bed..c0801e50 100644 --- a/src/scripting/Hooks.sp +++ b/src/scripting/Hooks.sp @@ -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) @@ -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) @@ -60,4 +69,5 @@ public void Hooks_OnPreThink(int client) // { // MaxSpeedDefaults // } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/scripting/Stocks.sp b/src/scripting/Stocks.sp index 9ca36f5b..e8bb8a82 100644 --- a/src/scripting/Stocks.sp +++ b/src/scripting/Stocks.sp @@ -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; } \ No newline at end of file