diff --git a/compile.bat b/compile.bat index acad502..fb5d1a1 100644 --- a/compile.bat +++ b/compile.bat @@ -19,4 +19,6 @@ if not exist "%BUILDDIR%" ( echo Starting compiler: %SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp -pause \ No newline at end of file +pause + +compile.bat \ No newline at end of file diff --git a/pspad/PSPad.ppr b/pspad/PSPad.ppr index b963371..7847e29 100644 --- a/pspad/PSPad.ppr +++ b/pspad/PSPad.ppr @@ -55,6 +55,7 @@ ZR ..\src\zr\commands.inc ..\src\zr\config.inc ..\src\zr\cookies.inc + ..\src\zr\credits.inc ..\src\zr\cvars.inc ..\src\zr\damage.inc ..\src\zr\debugtools.inc diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index a365fb1..ec2c3dc 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -223,6 +223,15 @@ public OnConfigsExecuted() ClassOnModulesLoaded(); } +/** + * Client has just connected to the server. + */ +public OnClientConnected(client) +{ + // Forward event to modules. + ClassOnClientConnected(client); +} + /** * Client is joining the server. * @@ -245,14 +254,32 @@ public OnClientPutInServer(client) } /** - * Client is authorized and fully in-game. + * Called once a client's saved cookies have been loaded from the database. + * + * @param client Client index. + */ +public OnClientCookiesCached(client) +{ + // Forward "OnCookiesCached" event to modules. + ClassOnCookiesCached(client); + WeaponsOnCookiesCached(client); + ZHPOnCookiesCached(client); +} + +/** + * Called once a client is authorized and fully in-game, and + * after all post-connection authorizations have been performed. * - * @param client Client index. + * This callback is gauranteed to occur on all clients, and always + * after each OnClientPutInServer() call. + * + * @param client Client index. + * @noreturn */ public OnClientPostAdminCheck(client) { // Forward authorized event to modules that depend on client admin info. - ClassOnClientAuthorized(client); + ClassOnClientPostAdminCheck(client); } /** diff --git a/src/zr/playerclasses/classevents.inc b/src/zr/playerclasses/classevents.inc index f093a5f..4bc8124 100644 --- a/src/zr/playerclasses/classevents.inc +++ b/src/zr/playerclasses/classevents.inc @@ -10,6 +10,11 @@ * ============================================================================ */ +/** + * Keeps track of if a client has been authorized as an admin. + */ +new bool:g_bAdminChecked[MAXPLAYERS + 1]; + /* ------------------------------------ * * GAME EVENTS @@ -62,32 +67,71 @@ ClassOnMapStart() ClassHealthRegenInit(); } +/** + * Client has just connected to the server. + */ +ClassOnClientConnected(client) +{ + // Initialize the admin checked variable. + g_bAdminChecked[client] = false; +} + /** * Called when a client connects to the server (OnClientPutInServer). */ ClassClientInit(client) { - // Check if classes are loaded successfully and the client is valid. - if (ClassValidated && ZRIsClientValid(client)) - { - // Forward event to sub-modules. - ClassOverlayClientInit(client); - } - // Reset spawn flag. ClassPlayerSpawned[client] = false; } /** - * Event callback for authorized clients when they're connecting. - * (OnClientPostAdminCheck) + * Called once a client is authorized and fully in-game, and + * after all post-connection authorizations have been performed. * - * @param client Client index. + * This callback is gauranteed to occur on all clients, and always + * after each OnClientPutInServer() call. + * + * @param client Client index. + * @noreturn */ -ClassOnClientAuthorized(client) +ClassOnClientPostAdminCheck(client) { + // Client has been checked. + g_bAdminChecked[client] = true; + + // Below this depends on client cookies. + if (!AreClientCookiesCached(client)) + return; + // Check if classes are loaded successfully and the client is valid. - if (ClassValidated && ZRIsClientValid(client)) + if (ClassValidated) + { + // Set default class indexes on the player. + ClassClientSetDefaultIndexes(client); + } +} + +/** + * Called once a client's saved cookies have been loaded from the database. + * + * @param client Client index. + */ +ClassOnCookiesCached(client) +{ + // Check if classes are loaded successfully. + if (ClassValidated) + { + // Forward event to sub-modules. + ClassOverlayOnCookiesCached(client); + } + + // Below this depends on client authorization. + if (!g_bAdminChecked[client]) + return; + + // Check if classes are loaded successfully and the client is valid. + if (ClassValidated) { // Set default class indexes on the player. ClassClientSetDefaultIndexes(client); diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index 97f7a87..ee3d595 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -79,11 +79,11 @@ ClassOverlayOnCookiesCreate() } /** - * Client is joining the server. + * Called once a client's saved cookies have been loaded from the database. * - * @param client The client index. + * @param client Client index. */ -ClassOverlayClientInit(client) +ClassOverlayOnCookiesCached(client) { // Get overlay toggle cvar values. new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index 015afb4..7bad287 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -318,6 +318,17 @@ WeaponsClientInit(client) ZMarketClientInit(client); } +/** + * Called once a client's saved cookies have been loaded from the database. + * + * @param client Client index. + */ +WeaponsOnCookiesCached(client) +{ + // Forward event to sub-modules. + ZMarketOnCookiesCached(client); +} + /** * Client is leaving the server. * diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 7888ab4..ffa0f17 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -109,7 +109,15 @@ ZMarketClientInit(client) // Create a new array handle to store purchase count data for client. g_hZMarketPurchaseCount[client] = CreateTrie(); - +} + +/** + * Called once a client's saved cookies have been loaded from the database. + * + * @param client Client index. + */ +ZMarketOnCookiesCached(client) +{ // Initialize auto-rebuy data. decl String:zmarketautorebuy[8]; GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy)); diff --git a/src/zr/zhp.inc b/src/zr/zhp.inc index c03da0d..b58b560 100644 --- a/src/zr/zhp.inc +++ b/src/zr/zhp.inc @@ -67,6 +67,17 @@ ZHPOnCookiesCreate() * @param client The client index. */ ZHPClientInit(client) +{ + // Reset timer handle. + tZHP[client] = INVALID_HANDLE; +} + +/** + * Called once a client's saved cookies have been loaded from the database. + * + * @param client Client index. + */ +ZHPOnCookiesCached(client) { // Get default client setting from cvar. new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP_DEFAULT]); @@ -81,9 +92,6 @@ ZHPClientInit(client) // Set cookie to default value from cvar. CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, zhp); } - - // Reset timer handle. - tZHP[client] = INVALID_HANDLE; } /**