Quote:
Originally Posted by Arkarr
Well, my cookies are restored when I'm on my server and I manually reload the plugin (sm plugins reload XXXX or sm plugins unload XXXX + sm plugins load XXXX) BUT are not restored when I join the server.
NOTE: I don't think it's a "late load", because I have put the GetClientCookie() code when OnClientCookiesCached(). Also, my cookies are saved when player leave server (they are saved OnPluginEnd() too.).
Can someone explain me what I have done wrong ? Should I give you my code ?
|
Like the tutorial says, did you
OnPluginStart -> For 1 < i <= MaxClients > IsClientInGame(i) && AreClientCookiesCached(i) > OnClientCookiesCached(i)
Here's another 'gotcha' the plugin tutorial forgot.
BAD
PHP Code:
#define COOKIES_NOTLOADEDYET -1
#define COOKIES_ARELOADEDNOW 1
static g_iCookieSetting[MAXPLAYERS+1];
public OnClientPostAdminCheck(iClient) // OnClientPutInServer(iClient)
{
g_iCookieSetting[iClient] = COOKIE_NOTLOADEDYET;
}
public OnClientCookiesCached(iClient)
{
g_iCookieSetting[iClient] = COOKIES_ARELOADEDNOW;
}
Every time OnClientCookiesCached fires before OnClientPostAdminCheck, you are now saying their cookies were never loaded, when they were. You just undid your own logic for them.
GOOD
PHP Code:
#define COOKIES_NOTLOADEDYET -1
#define COOKIES_ARELOADEDNOW 1
static g_iCookieSetting[MAXPLAYERS+1];
public OnClientPostAdminCheck(iClient)
{
if (!AreClientCookiesCached(iClient))
{
g_iCookieSetting[iClient] = COOKIE_NOTLOADEDYET;
}
}
public OnClientCookiesCached(iClient)
{
g_iCookieSetting[iClient] = COOKIES_ARELOADEDNOW;
}
__________________