Raised This Month: $7 Target: $400
 1% 

[Tutorial] ClientPrefs


Post New Thread Reply   
 
Thread Tools Display Modes
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 01-20-2014 , 11:05   Re: [Tutorial] ClientPrefs
Reply With Quote #21

Quote:
Originally Posted by Mitchell View Post
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).
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-20-2014 , 12:08   Re: [Tutorial] ClientPrefs
Reply With Quote #22

Quote:
Originally Posted by Root_ View Post
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)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 01-20-2014 at 12:31.
Powerlord is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-23-2014 , 14:24   Re: [Tutorial] ClientPrefs
Reply With Quote #23

I tend to avoid making cookies for FakeClients because well... they'll never use them.
__________________
Chdata is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 04-03-2014 , 15:22   Re: [Tutorial] ClientPrefs
Reply With Quote #24

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 ?
__________________

Last edited by Arkarr; 04-03-2014 at 15:22.
Arkarr is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-03-2014 , 15:27   Re: [Tutorial] ClientPrefs
Reply With Quote #25

Quote:
Originally Posted by Arkarr View Post
Should I give you my code ?
Yes.
__________________
ddhoward is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 04-03-2014 , 21:52   Re: [Tutorial] ClientPrefs
Reply With Quote #26

Quote:
Originally Posted by Arkarr View Post
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.
KyleS is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 04-04-2014 , 07:06   Re: [Tutorial] ClientPrefs
Reply With Quote #27

Quote:
Originally Posted by ddhoward View Post
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 View Post
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 !
__________________

Last edited by Arkarr; 04-05-2014 at 08:21.
Arkarr is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-05-2014 , 15:14   Re: [Tutorial] ClientPrefs
Reply With Quote #28

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

Last edited by Bacardi; 04-05-2014 at 15:28.
Bacardi is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-07-2015 , 01:25   Re: [Tutorial] ClientPrefs
Reply With Quote #29

Quote:
Originally Posted by Bacardi View Post
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!!
8guawong is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-07-2015 , 01:29   Re: [Tutorial] ClientPrefs
Reply With Quote #30

Quote:
Originally Posted by Arkarr View Post
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;

__________________

Last edited by Chdata; 02-07-2015 at 01:38.
Chdata is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:20.


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