Fixed cookies being reset on some occasions and admin-dependant classes are saved properly as well.
This commit is contained in:
parent
4776bf4e04
commit
21c41688d7
@ -20,3 +20,5 @@ echo Starting compiler:
|
|||||||
%SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp
|
%SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp
|
||||||
|
|
||||||
pause
|
pause
|
||||||
|
|
||||||
|
compile.bat
|
@ -55,6 +55,7 @@ ZR
|
|||||||
..\src\zr\commands.inc
|
..\src\zr\commands.inc
|
||||||
..\src\zr\config.inc
|
..\src\zr\config.inc
|
||||||
..\src\zr\cookies.inc
|
..\src\zr\cookies.inc
|
||||||
|
..\src\zr\credits.inc
|
||||||
..\src\zr\cvars.inc
|
..\src\zr\cvars.inc
|
||||||
..\src\zr\damage.inc
|
..\src\zr\damage.inc
|
||||||
..\src\zr\debugtools.inc
|
..\src\zr\debugtools.inc
|
||||||
|
@ -223,6 +223,15 @@ public OnConfigsExecuted()
|
|||||||
ClassOnModulesLoaded();
|
ClassOnModulesLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client has just connected to the server.
|
||||||
|
*/
|
||||||
|
public OnClientConnected(client)
|
||||||
|
{
|
||||||
|
// Forward event to modules.
|
||||||
|
ClassOnClientConnected(client);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* 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.
|
* @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.
|
||||||
|
*
|
||||||
|
* This callback is gauranteed to occur on all clients, and always
|
||||||
|
* after each OnClientPutInServer() call.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
public OnClientPostAdminCheck(client)
|
public OnClientPostAdminCheck(client)
|
||||||
{
|
{
|
||||||
// Forward authorized event to modules that depend on client admin info.
|
// Forward authorized event to modules that depend on client admin info.
|
||||||
ClassOnClientAuthorized(client);
|
ClassOnClientPostAdminCheck(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps track of if a client has been authorized as an admin.
|
||||||
|
*/
|
||||||
|
new bool:g_bAdminChecked[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/* ------------------------------------
|
/* ------------------------------------
|
||||||
*
|
*
|
||||||
* GAME EVENTS
|
* GAME EVENTS
|
||||||
@ -62,32 +67,71 @@ ClassOnMapStart()
|
|||||||
ClassHealthRegenInit();
|
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).
|
* Called when a client connects to the server (OnClientPutInServer).
|
||||||
*/
|
*/
|
||||||
ClassClientInit(client)
|
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.
|
// Reset spawn flag.
|
||||||
ClassPlayerSpawned[client] = false;
|
ClassPlayerSpawned[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event callback for authorized clients when they're connecting.
|
* Called once a client is authorized and fully in-game, and
|
||||||
* (OnClientPostAdminCheck)
|
* after all post-connection authorizations have been performed.
|
||||||
|
*
|
||||||
|
* This callback is gauranteed to occur on all clients, and always
|
||||||
|
* after each OnClientPutInServer() call.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// 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.
|
* @param client Client index.
|
||||||
*/
|
*/
|
||||||
ClassOnClientAuthorized(client)
|
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.
|
// Check if classes are loaded successfully and the client is valid.
|
||||||
if (ClassValidated && ZRIsClientValid(client))
|
if (ClassValidated)
|
||||||
{
|
{
|
||||||
// Set default class indexes on the player.
|
// Set default class indexes on the player.
|
||||||
ClassClientSetDefaultIndexes(client);
|
ClassClientSetDefaultIndexes(client);
|
||||||
|
@ -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.
|
// Get overlay toggle cvar values.
|
||||||
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
||||||
|
@ -318,6 +318,17 @@ WeaponsClientInit(client)
|
|||||||
ZMarketClientInit(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.
|
* Client is leaving the server.
|
||||||
*
|
*
|
||||||
|
@ -109,7 +109,15 @@ ZMarketClientInit(client)
|
|||||||
|
|
||||||
// Create a new array handle to store purchase count data for client.
|
// Create a new array handle to store purchase count data for client.
|
||||||
g_hZMarketPurchaseCount[client] = CreateTrie();
|
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.
|
// Initialize auto-rebuy data.
|
||||||
decl String:zmarketautorebuy[8];
|
decl String:zmarketautorebuy[8];
|
||||||
GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy));
|
GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy));
|
||||||
|
@ -67,6 +67,17 @@ ZHPOnCookiesCreate()
|
|||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
ZHPClientInit(client)
|
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.
|
// Get default client setting from cvar.
|
||||||
new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP_DEFAULT]);
|
new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP_DEFAULT]);
|
||||||
@ -81,9 +92,6 @@ ZHPClientInit(client)
|
|||||||
// Set cookie to default value from cvar.
|
// Set cookie to default value from cvar.
|
||||||
CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, zhp);
|
CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, zhp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer handle.
|
|
||||||
tZHP[client] = INVALID_HANDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user