View Single Post
Author Message
xXDeathreusXx
Veteran Member
Join Date: Mar 2013
Location: *pPlayer->GetOrigin();
Old 04-07-2018 , 15:34   [INC] Client Preferences Stocks
Reply With Quote #1

A simple little include that extends functionality of the cookie system with stocks that set or get specific data types from a cookie's string value. Also includes a Cookie methodmap for you object lovers out there. All of these will error out if given an invalid handle or the given clients cookies are not cached. I provide no guarantees everything will work as intended or at all!

If you are including this, don't include clientprefs, this already includes it!

Contents:

Cookie methods:
Code:
methodmap Cookie < Handle
{
	public Cookie(const char[] name, const char[] description, CookieAccess access)
	{
		if(name[0] == 0) // If we were somehow given no name, don't try to register the cookie
			return view_as<Cookie>(INVALID_HANDLE);
		return view_as<Cookie>(RegClientCookie(name, description, access)); // Register the cookie and return it as an object
	}
	
	property bool IsValid
	{
		public get()  // Are we null?
	}

	public bool HasValue(int iClient)

	public void SetPrefabMenu(CookieMenu type, const char[] display, CookieMenuHandler handler=INVALID_FUNCTION, any info=0)
	
	public void SetValue(int iClient, const char[] sValue="")
	public void GetValue(int iClient, char[] sValue, int iMaxLen)
	
	public void SetInt(int iClient, int iNum=0)
	public int GetInt(int iClient)
	
	public void SetFloat(int iClient, float fFloat=0.0)
	public float GetFloat(int iClient)
	
	public void SetBool(int iClient, bool bEnabled=false)
	public bool GetBool(int iClient)
}
Stocks:
  • SetClientCookieInt(client, cookieHandle, int)
  • GetClientCookieInt(client, cookieHandle)
  • SetClientCookieFloat(client, cooieHandle, float)
  • GetClientCookieFloat(client, cookieHandle)
  • SetClientCookieBool(client, cookieHandle, bool)
  • GetClientCookieBool(client, cookieHandle)
Attached Files
File Type: inc clientprefs_stocks.inc (9.3 KB, 44 views)
__________________
Plugins|Steam Group|Profile
I can do coding and even take requests, but I don't do a bit of modeling

I'm a smartass by nature, get used to it

Last edited by xXDeathreusXx; 08-21-2019 at 21:31. Reason: New methods
xXDeathreusXx is offline
Send a message via Skype™ to xXDeathreusXx