Raised This Month: $12 Target: $400
 3% 

[Tutorial] ClientPrefs


Post New Thread Reply   
 
Thread Tools Display Modes
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 08-01-2016 , 17:28   Re: [Tutorial] ClientPrefs
Reply With Quote #31

It should be documented somewhere that the maximum length of a cookie is 100 characters. I'd like to see it in the API documentation, but here would be good also.
__________________
ddhoward is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 10-07-2017 , 12:27   Re: [Tutorial] ClientPrefs
Reply With Quote #32

Sorry, but

is this part optional?

Code:
g_bClientPreference[client] = (sValue[0] != '\0' && StringToInt(sValue));
or I need it to make the cookies work properly?
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 10-07-2017 at 12:28.
Papero is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 10-07-2017 , 13:24   Re: [Tutorial] ClientPrefs
Reply With Quote #33

Quote:
Originally Posted by Papero View Post
Sorry, but

is this part optional?

Code:
g_bClientPreference[client] = (sValue[0] != '\0' && StringToInt(sValue));
or I need it to make the cookies work properly?
All that does is make sure the string isn't empty
Addicted. is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 10-07-2017 , 13:35   Re: [Tutorial] ClientPrefs
Reply With Quote #34

Quote:
Originally Posted by Addicted. View Post
All that does is make sure the string isn't empty
Yeah, but if the string is empty StringToInt will return anyway 0/false
Doc:
Quote:
Integer conversion of string, or 0 on failure
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 10-07-2017 at 13:37.
Papero is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 10-07-2017 , 13:36   Re: [Tutorial] ClientPrefs
Reply With Quote #35

Quote:
Originally Posted by Papero View Post
Yeah, but if the string is empty StringToInt will return anyway 0/false(From doc: Integer conversion of string, or 0 on failure.)
So there is your answer
Addicted. is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-10-2018 , 04:19   Re: [Tutorial] ClientPrefs
Reply With Quote #36

Why do you use Private cookies when it clearly looks like you're trying to make the cookie available for all? Why not Public cookie?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-10-2018 , 05:29   Re: [Tutorial] ClientPrefs
Reply With Quote #37

Quote:
Originally Posted by eyal282 View Post
Why do you use Private cookies when it clearly looks like you're trying to make the cookie available for all? Why not Public cookie?
https://sm.alliedmods.net/new-api/cl...s/CookieAccess

This selection configures whether the user can change the cookie value manually, or whether they can even see the current value via sm_cookies.

CookieAccess_Public means that the user can insert any string into the cookie by using sm_cookies.

CookieAccess_Restricted means that the user can use sm_cookies to view the raw value of the cookie as stored in the database, but cannot change it.

CookieAccess_Private means that the cookie will not show up in the sm_cookies list, and cannot be viewed or changed. The value of the cookie is instead exclusively changed through other means, such as a menu or something.

The vast majority of cookies will be private. There is almost no reason to do anything else. Any cookie that takes a user-defined string would probably be better off having a separate, dedicated command to changing it and reading it. I really can't think of any valid reason to use anything other than CookieAccess_Private.
__________________

Last edited by ddhoward; 07-10-2018 at 06:20.
ddhoward is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-11-2018 , 05:28   Re: [Tutorial] ClientPrefs
Reply With Quote #38

Quote:
Originally Posted by ddhoward View Post
https://sm.alliedmods.net/new-api/cl...s/CookieAccess

This selection configures whether the user can change the cookie value manually, or whether they can even see the current value via sm_cookies.

CookieAccess_Public means that the user can insert any string into the cookie by using sm_cookies.

CookieAccess_Restricted means that the user can use sm_cookies to view the raw value of the cookie as stored in the database, but cannot change it.

CookieAccess_Private means that the cookie will not show up in the sm_cookies list, and cannot be viewed or changed. The value of the cookie is instead exclusively changed through other means, such as a menu or something.

The vast majority of cookies will be private. There is almost no reason to do anything else. Any cookie that takes a user-defined string would probably be better off having a separate, dedicated command to changing it and reading it. I really can't think of any valid reason to use anything other than CookieAccess_Private.
I am using cookies to determine which guns you'll have in a gun menu. If you found the cookie in sm_cookies, you should be able to change one gun with a keybind without returning to menu
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-16-2018 , 17:58   Re: [Tutorial] ClientPrefs
Reply With Quote #39

Quote:
Originally Posted by eyal282 View Post
I am using cookies to determine which guns you'll have in a gun menu. If you found the cookie in sm_cookies, you should be able to change one gun with a keybind without returning to menu
This has nothing to do with a Cookie's CookieAccess setting. This can be accomplished with any of the three settings. You'd just use a command other than sm_cookies.
__________________
ddhoward is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-08-2018 , 17:34   Re: [Tutorial] ClientPrefs
Reply With Quote #40

https://forums.alliedmods.net/showthread.php?t=309777

General thoughts about using ClientPrefs for saving EXP or score a.k.a progress in a server?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 08-08-2018 at 17:34.
eyal282 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 12:06.


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