Raised This Month: $71 Target: $400
 17% 

[Tutorial] ClientPrefs


Post New Thread Reply   
 
Thread Tools Display Modes
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 11-26-2013 , 11:50   Re: [Tutorial] ClientPrefs
Reply With Quote #11

Quote:
Originally Posted by Arkarr View Post
Yep, I did, but cookies still lost.
Can you show your more up to date code?
KyleS is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-26-2013 , 13:31   Re: [Tutorial] ClientPrefs
Reply With Quote #12

(plugin bugged. removed.)
__________________

Last edited by Arkarr; 01-17-2014 at 08:09.
Arkarr is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 11-26-2013 , 18:19   Re: [Tutorial] ClientPrefs
Reply With Quote #13

Because when the plugins load, it doesn't get the clients' cookie. What it does is check that the clients have their cookie loaded (but not in your plugin's memory) using OnClientCookiesCached ==> why even do this ?.

Try to simply run OnClientPutInServer() for every InGame client OnPluginStart() rather than L33-37.


EDIT nvm; misread code; didn't notice at 2 places you were getting client cookies
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 11-26-2013 at 22:55.
RedSword is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 11-26-2013 , 20:04   Re: [Tutorial] ClientPrefs
Reply With Quote #14

Quote:
Originally Posted by RedSword View Post
Because when the plugins load, it doesn't get the clients' cookie. What it does is check that the clients have their cookie loaded (but not in your plugin's memory) using OnClientCookiesCached ==> why even do this ?.

Try to simply run OnClientPutInServer() for every InGame client OnPluginStart() rather than L33-37.


Quote:
Originally Posted by Arkarr View Post
Here is it.
It looks like you've preserved the load code in OnClientPutInServer, which is horribly incorrect. It also looks like you only store the client data when they disconnect, which would reproduce the plugin reload bug. If you're worried about the overhead of updating your cookie data over and over again in your timer, you can use OnPluginEnd; but that's a thing.


EDIT: Unrelated to ClientPrefs, you should return Plugin_Stop in your Timer, otherwise you're leaking timers. Your plugin will eventually auto-unload after enough clients connect, from running out of Handles. You should also pass the flag TIMER_FLAG_NO_MAPCHANGE, as all of your timers should die then anyways.

Last edited by KyleS; 11-26-2013 at 20:07.
KyleS is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-27-2013 , 04:57   Re: [Tutorial] ClientPrefs
Reply With Quote #15

...
Ok

Mabye you are writing over them. Are you by chance using onclientputinserver to initialize stuff! Because careclientcookiescached can happen before or after that. You may want to use onclientdonnected instead, to pre-initialize vars while you wait for cookies to load in. It may be that they are loading, but you are overwriting them with junk data later.

Edit:didnt see this second page, but looks like is still probly relevant.
__________________
Profile - Steam Group - Plugins - Blog - Donate
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 11-27-2013 at 04:59.
friagram is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-27-2013 , 13:44   Re: [Tutorial] ClientPrefs
Reply With Quote #16

Oka, thanks for help. I updated this plugin.
__________________
Arkarr is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-16-2014 , 17:34   Re: [Tutorial] ClientPrefs
Reply With Quote #17

Does clientprefs keep track of which plugin assigned which cookie? Or should plugin authors be careful to ensure that the cookie name is unique?
__________________
ddhoward is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 01-16-2014 , 18:33   Re: [Tutorial] ClientPrefs
Reply With Quote #18

Quote:
Originally Posted by ddhoward View Post
Does clientprefs keep track of which plugin assigned which cookie?
Not really.
Quote:
Originally Posted by ddhoward View Post
Or should plugin authors be careful to ensure that the cookie name is unique?
This. For example, in some of my plugins I retrieve quake sounds client preferences this way.
Code:
new bool:QPreferences[MAXPLAYERS + 1]; public OnClientCookiesCached(client) {     if (AreClientCookiesCached(client))     {         decl String:value[5], Handle:preferences;         preferences = FindClientCookie("Quake Sound Pref");         GetClientCookie(client, preferences, value, sizeof(value));         CloseHandle(preferences);         QPreferences[client] = bool:!StringToInt(value);     } }
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-18-2014 , 20:06   Re: [Tutorial] ClientPrefs
Reply With Quote #19

Good to know. I recently saw a plugin (not on this site) that named its cookie "cookie." Was wondering if this might conflict with any other plugin with the same non-descriptive cookie name. Now I know it will lol
__________________
ddhoward is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-20-2014 , 11:47   Re: [Tutorial] ClientPrefs
Reply With Quote #20

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.
__________________
Mitchell 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 11:47.


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