diff --git a/plugins/l4d2_hideandseek.smx b/plugins/l4d2_hideandseek.smx index 37d714a..3998320 100644 Binary files a/plugins/l4d2_hideandseek.smx and b/plugins/l4d2_hideandseek.smx differ diff --git a/scripting/include/hideandseek/hscmds.inc b/scripting/include/hideandseek/hscmds.inc index 0c8f336..1153bc5 100644 --- a/scripting/include/hideandseek/hscmds.inc +++ b/scripting/include/hideandseek/hscmds.inc @@ -3,11 +3,11 @@ public Action Command_HideAndSeek(int client, int args) { char subcmd[16]; GetCmdArg(1, subcmd, sizeof(subcmd)); if(StrEqual(subcmd, "r") || StrEqual(subcmd, "reload", false)) { - GetCurrentMap(currentMap, sizeof(currentMap)); + GetCurrentMap(g_currentMap, sizeof(g_currentMap)); char arg[16]; GetCmdArg(2, arg, sizeof(arg)); if(ReloadMapDB()) { - if(!LoadConfigForMap(currentMap)) { + if(!LoadConfigForMap(g_currentMap)) { ReplyToCommand(client, "Warn: Map has no config file"); } Cleanup(); @@ -22,7 +22,7 @@ public Action Command_HideAndSeek(int client, int args) { } else if(StrEqual(subcmd, "set", false)) { char set[16]; if(args == 1) { - ReplyToCommand(client, "Current Map Set: \"%s\" (Specify with /hs set )", currentSet); + ReplyToCommand(client, "Current Map Set: \"%s\" (Specify with /hs set )", g_currentSet); if(validSets.Length == 0) ReplyToCommand(client, "Available Sets: (no map config found)"); else { ReplyToCommand(client, "Available Sets: "); @@ -32,16 +32,16 @@ public Action Command_HideAndSeek(int client, int args) { } } } else { - GetCmdArg(2, currentSet, sizeof(currentSet)); + GetCmdArg(2, g_currentSet, sizeof(g_currentSet)); for(int i = 0; i < validSets.Length; i++) { validSets.GetString(i, set, sizeof(set)); - if(StrEqual(set, currentSet)) { - if(!LoadConfigForMap(currentMap)) { + if(StrEqual(set, g_currentSet)) { + if(!LoadConfigForMap(g_currentMap)) { ReplyToCommand(client, "Warn: Map has no config file"); } Cleanup(); SetupEntities(isNavBlockersEnabled, isPropsEnabled, isPortalsEnabled); - PrintToChatAll("[H&S] Map set has been changed to \"%s\"", currentSet); + PrintToChatAll("[H&S] Map set has been changed to \"%s\"", g_currentSet); return Plugin_Handled; } } @@ -135,7 +135,7 @@ public Action Command_HideAndSeek(int client, int args) { do { int mapIndex = GetURandomInt() % validMaps.Length; validMaps.GetString(mapIndex, map, sizeof(map)); - if(!StrEqual(currentMap, map, false)) { + if(!StrEqual(g_currentMap, map, false)) { foundMap = true; } } while(!foundMap); @@ -262,7 +262,7 @@ public Action Command_HideAndSeek(int client, int args) { ReplyToCommand(client, "State: %d | Tick: %d", view_as(GetState()), GetTick()); ReplyToCommand(client, "- Map Info -"); - ReplyToCommand(client, "Map: %s (set %s)", currentMap, currentSet); + ReplyToCommand(client, "Map: %s (set %s)", g_currentMap, g_currentSet); if(mapConfig.hasSpawnpoint) ReplyToCommand(client, "Has Spawnpoint: yes (%f %f %f)", mapConfig.spawnpoint[0], mapConfig.spawnpoint[1], mapConfig.spawnpoint[2]); else diff --git a/scripting/include/hideandseek/hscore.inc b/scripting/include/hideandseek/hscore.inc index 9b661b4..4045d48 100644 --- a/scripting/include/hideandseek/hscore.inc +++ b/scripting/include/hideandseek/hscore.inc @@ -44,10 +44,10 @@ bool LoadConfigForMap(const char[] map) { validSets.Clear(); static char buffer[64]; - if(StrEqual(currentSet, "default") && kv.GetString("defaultset", buffer, sizeof(buffer)) && buffer[0] != '\0') { - strcopy(currentSet, sizeof(currentSet), buffer); + if(StrEqual(g_currentSet, "default") && kv.GetString("defaultset", buffer, sizeof(buffer)) && buffer[0] != '\0') { + strcopy(g_currentSet, sizeof(g_currentSet), buffer); } - PrintToServer("[H&S] Loading config data for set %s on %s", currentSet, map); + PrintToServer("[H&S] Loading config data for set %s on %s", g_currentSet, map); if(kv.JumpToKey("ents")) { kv.GotoFirstSubKey(); @@ -65,7 +65,7 @@ bool LoadConfigForMap(const char[] map) { if(validSets.FindString(buffer) == -1) { validSets.PushString(buffer); } - if(StrEqual(buffer, "default") || StrEqual(currentSet, buffer, false)) { + if(StrEqual(buffer, "default") || StrEqual(g_currentSet, buffer, false)) { config.entities.PushArray(entCfg); } else { @@ -94,7 +94,7 @@ bool LoadConfigForMap(const char[] map) { config.hasSpawnpoint = false; config.canClimb = true; config.pressButtons = true; - if(!StrEqual(currentSet, "default") && kv.JumpToKey("sets")) { + if(!StrEqual(g_currentSet, "default") && kv.JumpToKey("sets")) { char set[16]; kv.GotoFirstSubKey(true); do { @@ -102,10 +102,10 @@ bool LoadConfigForMap(const char[] map) { if(validSets.FindString(set) == -1) { validSets.PushString(set); } - if(StrEqual(currentSet, set, false)) { + if(StrEqual(g_currentSet, set, false)) { kv.GetVector("spawnpoint", config.spawnpoint); if(config.spawnpoint[0] != 0.0 && config.spawnpoint[1] != 0.0 && config.spawnpoint[2] != 0.0) { - PrintToServer("[H&S] Using provided custom spawnpoint for set %s at %0.1f, %0.1f, %0.1f", currentSet, config.spawnpoint[0], config.spawnpoint[1], config.spawnpoint[2]); + PrintToServer("[H&S] Using provided custom spawnpoint for set %s at %0.1f, %0.1f, %0.1f", g_currentSet, config.spawnpoint[0], config.spawnpoint[1], config.spawnpoint[2]); config.hasSpawnpoint = true; } char buf[8]; diff --git a/scripting/include/hideandseek/hsents.inc b/scripting/include/hideandseek/hsents.inc index 63a7c19..5445eea 100644 --- a/scripting/include/hideandseek/hsents.inc +++ b/scripting/include/hideandseek/hsents.inc @@ -237,7 +237,7 @@ void SetupEntities(bool blockers = true, bool props = true, bool portals = true) } #endif if(mapConfig.entities != null) { - PrintToServer("[H&S] Deploying %d custom entities (Set: %s) (blockers:%b props:%b portals:%b)", mapConfig.entities.Length, currentSet, blockers, props, portals); + PrintToServer("[H&S] Deploying %d custom entities (Set: %s) (blockers:%b props:%b portals:%b)", mapConfig.entities.Length, g_currentSet, blockers, props, portals); for(int i = 0; i < mapConfig.entities.Length; i++) { EntityConfig config; mapConfig.entities.GetArray(i, config); diff --git a/scripting/l4d2_hideandseek.sp b/scripting/l4d2_hideandseek.sp index 8a384c0..74dd033 100644 --- a/scripting/l4d2_hideandseek.sp +++ b/scripting/l4d2_hideandseek.sp @@ -12,7 +12,6 @@ #include #include #include -#include #include #if defined DEBUG_BLOCKERS #include @@ -78,8 +77,11 @@ ConVar cvar_peekCam; ConVar cvar_seekerBalance; ConVar cvar_abm_autohard; +BaseGame Game; +#include #include + public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { lateLoaded = late; return APLRes_Success; @@ -91,6 +93,8 @@ public void OnPluginStart() { SetFailState("This plugin is for L4D2 only."); } + Game.Init("Hide&Seek", "H&S"); + validMaps = new ArrayList(ByteCountToCells(64)); validSets = new ArrayList(ByteCountToCells(16)); mapConfigs = new StringMap(); @@ -153,13 +157,13 @@ public void OnMapStart() { char map[64]; GetCurrentMap(map, sizeof(map)); - if(!StrEqual(currentMap, map)) { + if(!StrEqual(g_currentMap, map)) { PrintToServer("[H&S] Map changed, loading fresh config"); - strcopy(currentMap, sizeof(currentMap), map); + strcopy(g_currentMap, sizeof(g_currentMap), map); if(!mapConfigs.GetArray(map, mapConfig, sizeof(MapConfig))) { LoadConfigForMap(map); } - strcopy(currentSet, sizeof(currentSet), "default"); + strcopy(g_currentSet, sizeof(g_currentSet), "default"); if(IsGameSoloOrPlayersLoading()) { Handle timer = CreateTimer(10.0, Timer_KeepWaiting, _, TIMER_REPEAT); TriggerTimer(timer);