plugins/testsuite/clientprefstest.sp
changeset 2048 2454ff4d6afb
parent 2009 1a1236dfdbb1
child 2207 3a97a56ded62
     1.1 --- a/plugins/testsuite/clientprefstest.sp	Mon May 12 02:05:57 2008 +0000
     1.2 +++ b/plugins/testsuite/clientprefstest.sp	Mon May 12 08:06:47 2008 +0000
     1.3 @@ -1,26 +1,59 @@
     1.4  #include <sourcemod>
     1.5 -#include "../include/clientprefs.inc"
     1.6 +#include <clientprefs.inc>
     1.7  
     1.8  new Handle:g_Cookie;
     1.9 +new Handle:g_Cookie2;
    1.10 +new Handle:g_Cookie3;
    1.11 +new Handle:g_Cookie4;
    1.12 +new Handle:g_Cookie5;
    1.13  
    1.14  public OnPluginStart()
    1.15  {
    1.16 -		g_Cookie = RegClientPrefCookie("test-cookie", "A basic testing cookie");
    1.17 +	g_Cookie = RegClientCookie("test-cookie", "A basic testing cookie", CookieAccess_Public);
    1.18 +	g_Cookie2 = RegClientCookie("test-cookie2", "A basic testing cookie", CookieAccess_Protected);
    1.19 +	g_Cookie3 = RegClientCookie("test-cookie3", "A basic testing cookie", CookieAccess_Public);
    1.20 +	g_Cookie4 = RegClientCookie("test-cookie4", "A basic testing cookie", CookieAccess_Private);
    1.21 +	
    1.22 +	g_Cookie5 = RegClientCookie("test-cookie5", "A basic testing cookie", CookieAccess_Public);
    1.23 +	
    1.24 +	SetCookiePrefabMenu(g_Cookie, CookieMenu_YesNo, "Cookie 1", CookieSelected, any:g_Cookie);
    1.25 +	SetCookiePrefabMenu(g_Cookie2, CookieMenu_YesNo_Int, "Cookie 2");
    1.26 +	SetCookiePrefabMenu(g_Cookie3, CookieMenu_OnOff, "Cookie 3");
    1.27 +	SetCookiePrefabMenu(g_Cookie4, CookieMenu_OnOff_Int, "Cookie 4");
    1.28 +	
    1.29 +	SetCookieMenuItem(CookieSelected, g_Cookie5, "Get Cookie 5 value");	
    1.30  }
    1.31  
    1.32 -public  bool:OnClientConnect(client, String:rejectmsg[], maxlen)
    1.33 +public CookieSelected(client, CookieMenuAction:action, any:info, String:buffer[], maxlen)
    1.34 +{
    1.35 +	if (action == CookieMenuAction_DisplayOption)
    1.36 +	{
    1.37 +		PrintToChat(client, "About to draw item. Current text is : %s", buffer);
    1.38 +		Format(buffer, maxlen, "HELLLLLLLLLLO");
    1.39 +	}
    1.40 +	else
    1.41 +	{
    1.42 +		LogMessage("SELECTED!");
    1.43 +	
    1.44 +		new String:value[100];
    1.45 +		GetClientCookie(client, info, value, sizeof(value));
    1.46 +		PrintToChat(client, "Value is : %s", value);
    1.47 +	}
    1.48 +}
    1.49 +
    1.50 +public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
    1.51  {
    1.52  	LogMessage("Connect Cookie state: %s", AreClientCookiesCached(client) ? "YES" : "NO");
    1.53  }
    1.54  
    1.55 -public OnClientCookiesLoaded(client)
    1.56 +public OnClientCookiesCached(client)
    1.57  {
    1.58  	LogMessage("Loaded Cookie state: %s", AreClientCookiesCached(client) ? "YES" : "NO");
    1.59  	
    1.60  	new String:hi[100];
    1.61 -	GetClientPrefCookie(client, g_Cookie, hi, sizeof(hi));
    1.62 +	GetClientCookie(client, g_Cookie, hi, sizeof(hi));
    1.63  	LogMessage("Test: %s",hi);
    1.64 -	SetClientPrefCookie(client, g_Cookie, "somethingsomething");
    1.65 -	GetClientPrefCookie(client, g_Cookie, hi, sizeof(hi));
    1.66 +	SetClientCookie(client, g_Cookie, "somethingsomething");
    1.67 +	GetClientCookie(client, g_Cookie, hi, sizeof(hi));
    1.68  	LogMessage("Test: %s",hi);	
    1.69 -}
    1.70 \ No newline at end of file
    1.71 +}