From 013ff290ee64d28ca3a29f91f570a9244c80c61e Mon Sep 17 00:00:00 2001 From: zaCade Date: Sat, 8 Dec 2018 17:46:50 +0100 Subject: [PATCH] VScripts: Clean code slightly, and remove 'version' check. --- ...ze_dreamin_v2.sp => vscript_ze_dreamin.sp} | 44 +++++-------------- 1 file changed, 12 insertions(+), 32 deletions(-) rename VScripts/scripting/{vscript_ze_dreamin_v2.sp => vscript_ze_dreamin.sp} (98%) diff --git a/VScripts/scripting/vscript_ze_dreamin_v2.sp b/VScripts/scripting/vscript_ze_dreamin.sp similarity index 98% rename from VScripts/scripting/vscript_ze_dreamin_v2.sp rename to VScripts/scripting/vscript_ze_dreamin.sp index b8d966a2..a70737ec 100644 --- a/VScripts/scripting/vscript_ze_dreamin_v2.sp +++ b/VScripts/scripting/vscript_ze_dreamin.sp @@ -1,26 +1,10 @@ -#pragma semicolon 1 - #include #include #include +#pragma semicolon 1 #pragma newdecls required -#define MAXTIMERS 128 - -/* STRINGS */ - -/* CONVARS */ - -/* HANDLES */ -Handle g_hTimers[MAXTIMERS] = {INVALID_HANDLE, ...}; - -/* BOOLS */ - -/* INTEGERS */ -int g_iTimerCount = 0; - - //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -54,12 +38,14 @@ public void OnMapStart() //---------------------------------------------------------------------------------------------------- public void VerifyMap() { - char currentMap[64]; - GetCurrentMap(currentMap, sizeof(currentMap)); - if (strcmp(currentMap, "ze_dreamin_v2_1s_fix3", false) != 0) + char sCurrentMap[64]; + GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); + + if (strncmp(sCurrentMap, "ze_dreamin_", 11, false) != 0) { char sFilename[256]; GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); + ServerCommand("sm plugins unload %s", sFilename); } } @@ -69,15 +55,6 @@ public void VerifyMap() //---------------------------------------------------------------------------------------------------- public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) { - - for (int i = 0; i <= (MAXTIMERS - 1); i++) - { - if (g_hTimers[i] != INVALID_HANDLE && CloseHandle(g_hTimers[i])) - g_hTimers[i] = INVALID_HANDLE; - } - g_iTimerCount = 0; - - int iEntity = INVALID_ENT_REFERENCE; iEntity = FindEntityByTargetName("reflect_logic"); @@ -629,13 +606,14 @@ public void Display(int amount) for (int j = 0; j <= amount; j++) { - iBackup --; + iBackup--; DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message %d,%d,-1", iBackup, j); - DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,Display,,%d,-1",j); DispatchKeyFormat(iRelay, "OnTrigger", "seconds_left,Display,,%d,-1",j); + DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,Display,,%d,-1",j); } - DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message ,%d,-1",amount + 1); + DispatchKeyFormat(iRelay, "OnTrigger", "seconds_left,AddOutput,message ,%d,-1",amount + 1); + DispatchKeyFormat(iRelay, "OnTrigger", "text_sec,AddOutput,message ,%d,-1",amount + 1); DispatchKeyFormat(iRelay, "OnTrigger", "!self,Kill,,%d,-1",amount + 2); SpawnAndActivate(iRelay); @@ -658,6 +636,7 @@ public int FindEntityByTargetName(const char[] sTargetnameToFind) return iEntity; } } + PrintToChatAll("[VScripts] Error! Could not find entity: %s", sTargetnameToFind); return INVALID_ENT_REFERENCE; } @@ -675,6 +654,7 @@ public int FindEntityByHammerID(int iHammerID) return iEntity; } } + PrintToChatAll("[VScripts] Error! Could not find entity: #%d", iHammerID); return INVALID_ENT_REFERENCE; }