From 436399702f077f3d4280b4da2c8f235df6a09d29 Mon Sep 17 00:00:00 2001 From: Riccardo H Date: Sun, 18 Aug 2019 18:56:38 +0200 Subject: [PATCH] added auto-reset command --- CHANGELOG.md | 4 ++++ README.md | 2 +- addons/sourcemod/scripting/SurfTimer.sp | 6 +++++- .../sourcemod/scripting/surftimer/commands.sp | 12 +++++++++++ addons/sourcemod/scripting/surftimer/misc.sp | 13 +++++++++++- .../translations/surftimer.phrases.txt | 20 +++++++++++++++++++ 6 files changed, 54 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c853030..5caf211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +[2019-08-18 - Version 274] +--- +* **[NEW]** added `sm_autoreset` command + [2019-08-16 - Version 273] --- * **[REQUEST/FIX]** Finally fixed maxvelocity bug ._. diff --git a/README.md b/README.md index bc65ff0..fa1dff7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# z4lab-SurfTimer 273 for CS:GO +# z4lab-SurfTimer 274 for CS:GO ## Installation and requirements [SourceMod 1.9](https://www.sourcemod.net/downloads.php?branch=stable), [MetaMod 1.10](https://www.sourcemm.net/downloads.php/?branch=stable) and a working MySQL instance is required for this plugin diff --git a/addons/sourcemod/scripting/SurfTimer.sp b/addons/sourcemod/scripting/SurfTimer.sp index 5235092..facde5a 100644 --- a/addons/sourcemod/scripting/SurfTimer.sp +++ b/addons/sourcemod/scripting/SurfTimer.sp @@ -38,7 +38,7 @@ #pragma semicolon 1 // Plugin Info -#define VERSION "273" +#define VERSION "274" // Database Definitions #define MYSQL 0 @@ -769,6 +769,10 @@ bool g_iHasEnforcedTitle[MAXPLAYERS + 1]; // disable noclip triggers toggle bool g_iDisableTriggers[MAXPLAYERS + 1]; + +// auto reset +bool g_iAutoReset[MAXPLAYERS + 1]; + /*---------- Run Variables ----------*/ // Clients personal record in map diff --git a/addons/sourcemod/scripting/surftimer/commands.sp b/addons/sourcemod/scripting/surftimer/commands.sp index a0cb9dc..4b1f202 100644 --- a/addons/sourcemod/scripting/surftimer/commands.sp +++ b/addons/sourcemod/scripting/surftimer/commands.sp @@ -203,6 +203,7 @@ void CreateCommands() RegConsoleCmd("sm_speedmode", Command_ChangeSpeedMode, "[SurfTimer] [settings] xy/xyz/z - change speed mode"); RegConsoleCmd("sm_centerspeed", Command_CenterSpeed, "[SurfTimer] [settings] on/off - toggle center speed display"); RegConsoleCmd("sm_nctriggers", Command_ToggleNcTriggers, "[SurfTimer] [settings] on/off - toggle triggers while noclipping"); + RegConsoleCmd("sm_autoreset", Command_ToggleAutoReset, "[SurfTimer] [settings] on/off - toggle auto reset for your current map/bonus run if your above your pb"); // Trails RegConsoleCmd("sm_trail", Command_Trail, "Opens the 'Trail Selection' menu."); @@ -212,6 +213,17 @@ void CreateCommands() } +public Action Command_ToggleAutoReset(int client, int args) { + if (g_iAutoReset[client]) { + g_iAutoReset[client] = false; + CPrintToChat(client, "%t", "AutoResetDisabled", g_szChatPrefix); + } else { + g_iAutoReset[client] = true; + CPrintToChat(client, "%t", "AutoResetEnabled", g_szChatPrefix); + } + return Plugin_Handled; +} + public Action Command_ToggleNcTriggers(int client, int args) { if (g_iDisableTriggers[client]) { g_iDisableTriggers[client] = false; diff --git a/addons/sourcemod/scripting/surftimer/misc.sp b/addons/sourcemod/scripting/surftimer/misc.sp index 6f19877..5ab92c8 100644 --- a/addons/sourcemod/scripting/surftimer/misc.sp +++ b/addons/sourcemod/scripting/surftimer/misc.sp @@ -2752,8 +2752,14 @@ public void CheckRun(int client) if (g_fCurrentRunTime[client] > g_fPersonalRecord[client] && !g_bMissedMapBest[client] && !g_bPause[client] && g_iClientInZone[client][2] == 0) { g_bMissedMapBest[client] = true; - if (g_fPersonalRecord[client] > 0.0) + if (g_fPersonalRecord[client] > 0.0) { CPrintToChat(client, "%t", "MissedMapBest", g_szChatPrefix, g_szPersonalRecord[client]); + if (g_iAutoReset[client]) { + Command_Restart(client, 1); + CPrintToChat(client, "%t", "AutoResetMessage1", g_szChatPrefix); + CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix); + } + } EmitSoundToClient(client, "buttons/button18.wav", client); } else @@ -2764,6 +2770,11 @@ public void CheckRun(int client) { g_bMissedBonusBest[client] = true; CPrintToChat(client, "%t", "Misc29", g_szChatPrefix, g_szPersonalRecordBonus[g_iClientInZone[client][2]][client]); + if (g_iAutoReset[client]) { + Command_Teleport(client, 0); + CPrintToChat(client, "%t", "AutoResetMessage1", g_szChatPrefix); + CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix); + } EmitSoundToClient(client, "buttons/button18.wav", client); } } diff --git a/addons/sourcemod/translations/surftimer.phrases.txt b/addons/sourcemod/translations/surftimer.phrases.txt index 4fff0b1..45d820c 100644 --- a/addons/sourcemod/translations/surftimer.phrases.txt +++ b/addons/sourcemod/translations/surftimer.phrases.txt @@ -1618,4 +1618,24 @@ "#format" "{1:s}" "en" "{1} Triggers are now {red}disabled {default}while noclipping" } + "AutoResetDisabled" + { + "#format" "{1:s}" + "en" "{1} Your timer {green}won't reset {default}if you've missed your PB" + } + "AutoResetEnabled" + { + "#format" "{1:s}" + "en" "{1} Your timer will {red}reset {default}if you've missed your PB" + } + "AutoResetMessage1" + { + "#format" "{1:s}" + "en" "{1} You got teleported to the start because auto-reset is enabled" + } + "AutoResetMessage2" + { + "#format" "{1:s}" + "en" "{1} Use {blue}sm_autoreset {default}to disable it" + } }