Raised This Month: $32 Target: $400
 8% 

[INC] Client Preferences Stocks


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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, 190 views)
__________________
Plugins|Profile
Requests closed

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
 



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 01:31.


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