From 393044aa87acd51560c8c5bb7bbfb5d2639dbf1a Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Wed, 22 Aug 2012 12:42:30 +0200 Subject: [PATCH] Added game detection. --- src/zombiereloaded.sp | 2 ++ src/zr/zombiereloaded.inc | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 3443a0d..26061af 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -150,6 +150,8 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) */ public OnPluginStart() { + UpdateGameFolder(); + // Forward event to modules. LogInit(); // Doesn't depend on CVARs. TranslationInit(); diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 854a543..1407fc7 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -54,6 +54,46 @@ enum EligibleCondition */ new bool:g_bZombieSpawned; +/** + * Supported games. + */ +enum Game +{ + Game_Unknown = -1, + Game_CSS, + Game_CSGO +} + +/** + * Current game. + */ +new Game:g_game = Game_Unknown; + +/** + * Updates g_game. Will log a warning if a unsupported game is detected. + */ +UpdateGameFolder() +{ + new String:gameFolder[PLATFORM_MAX_PATH]; + GetGameFolderName(gameFolder, sizeof(gameFolder)); + + if (StrEqual(gameFolder, "cstrike", false)) + { + g_game = Game_CSS; + PrintToServer("Game detected: cstrike"); + return; + } + else if (StrEqual(gameFolder, "csgo", false)) + { + g_game = Game_CSGO; + PrintToServer("Game detected: csgo"); + return; + } + + LogError("Warning: Zombie:Reloaded doesn't support this game: %s", gameFolder); + g_game = Game_Unknown; +} + /** * Function to convert numbers to defined units. *