AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Tutorial] ClientPrefs (https://forums.alliedmods.net/showthread.php?t=228244)

Root_ 01-20-2014 11:05

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Mitchell (Post 2088534)
Should also mention that cookies should not be used to store stats, as in time played. It makes it nearly impossible to reset all the players in that cookie back to 0, etc. Should only be used as preferences.

But why? Clientprefs is fine to store simple stats with time stamps. It's also have simply database structure, so you can do simply queries (see this).

Powerlord 01-20-2014 12:08

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Root_ (Post 2088556)
But why? Clientprefs is fine to store simple stats with time stamps. It's also have simply database structure, so you can do simply queries (see this).

If you're manually running queries against the ClientPrefs database, you're (by definition) doing it wrong.

(Actually, your plugin already covers the one exception to that rule)

Chdata 01-23-2014 14:24

Re: [Tutorial] ClientPrefs
 
I tend to avoid making cookies for FakeClients because well... they'll never use them.

Arkarr 04-03-2014 15:22

Re: [Tutorial] ClientPrefs
 
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 ?

ddhoward 04-03-2014 15:27

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Arkarr (Post 2119721)
Should I give you my code ?

Yes.

KyleS 04-03-2014 21:52

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Arkarr (Post 2119721)
NOTE: I don't think it's a "late load", because I have put the GetClientCookie() code when OnClientCookiesCached().

Can you confirm this forward is called? To my recollection, it is not called on late load.

Arkarr 04-04-2014 07:06

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by ddhoward (Post 2119723)
Yes.

Here : https://forums.alliedmods.net/showthread.php?t=236670
I already made a post for this, but it seems none saw it, or was able to fix it (or just wasn't interested).


Quote:

Originally Posted by KyleS (Post 2119874)
Can you confirm this forward is called? To my recollection, it is not called on late load.

I don't get it... (damn, my english restrained me again)
Not sure if it's what you are asking for but, yes, it's called. I have print some debug text on OnClientCookiesCached() and GetClientCookies work for my other cookies.

EDIT: Really ? No one wanna give me a hint ? Damn it !

Bacardi 04-05-2014 15:14

Re: [Tutorial] ClientPrefs
 
I think this example have little mistake,
in cookie menu handler
- CookieMenuAction_SelectOption action happens when you pick option "TestCookie" from cookie menu.
So, you are picking old cookie value on OnClientCookiesCached(),
So so, cookie OnOff integer value get change and saved AFTER you have choose menu option "On/Off".
So so so, you need choose twice "on/off" option from menu to update rigth value in global variable g_bClientPreference[client].

how ever, I do have SourceMod Version: 1.5.2, has this feature changed for now ??

*edit
could problem be SetCookiePrefabMenu ? bad timing

8guawong 02-07-2015 01:25

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Bacardi (Post 2120596)
So so so, you need choose twice "on/off" option from menu to update rigth value in global variable g_bClientPreference[client].

hi i notice this problem as well!!

Chdata 02-07-2015 01:29

Re: [Tutorial] ClientPrefs
 
Quote:

Originally Posted by Arkarr (Post 2119721)
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;




All times are GMT -4. The time now is 22:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.