plugins/clientprefs.sp
branchrefac-jit
changeset 2168 c24a6fa957db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/clientprefs.sp	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,156 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod Map Management Plugin
     1.8 + * Provides all map related functionality, including map changing, map voting,
     1.9 + * and nextmap.
    1.10 + *
    1.11 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
    1.12 + * =============================================================================
    1.13 + *
    1.14 + * This program is free software; you can redistribute it and/or modify it under
    1.15 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.16 + * Free Software Foundation.
    1.17 + * 
    1.18 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.20 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.21 + * details.
    1.22 + *
    1.23 + * You should have received a copy of the GNU General Public License along with
    1.24 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.25 + *
    1.26 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.27 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.28 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.29 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.30 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.31 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.32 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.33 + * or <http://www.sourcemod.net/license.php>.
    1.34 + *
    1.35 + * Version: $Id$
    1.36 + */
    1.37 + 
    1.38 +
    1.39 +#pragma semicolon 1
    1.40 +#include <sourcemod>
    1.41 +#include <clientprefs>
    1.42 +
    1.43 +public Plugin:myinfo =
    1.44 +{
    1.45 +	name = "Client Preferences",
    1.46 +	author = "AlliedModders LLC",
    1.47 +	description = "Client peferences and settings menu",
    1.48 +	version = SOURCEMOD_VERSION,
    1.49 +	url = "http://www.sourcemod.net/"
    1.50 +};
    1.51 +
    1.52 +public OnPluginStart()
    1.53 +{
    1.54 +	LoadTranslations("clientprefs.phrases");
    1.55 +	
    1.56 +	RegConsoleCmd("sm_cookies", Command_Cookie, "sm_cookies <name> [value]");
    1.57 +	RegConsoleCmd("sm_settings", Command_Settings);	
    1.58 +}
    1.59 +
    1.60 +public Action:Command_Cookie(client, args)
    1.61 +{
    1.62 +	if (args == 0)
    1.63 +	{
    1.64 +		ReplyToCommand(client, "[SM] Usage: sm_cookie <name> [value]");
    1.65 +		ReplyToCommand(client, "[SM] %t", "Printing Cookie List");
    1.66 +		
    1.67 +		/* Show list of cookies */
    1.68 +		new Handle:iter = GetCookieIterator();
    1.69 +		
    1.70 +		decl String:name[30];
    1.71 +		name[0] = '\0';
    1.72 +		decl String:description[255];
    1.73 +		description[0] = '\0';
    1.74 +		
    1.75 +		PrintToConsole(client, "%t:", "Cookie List");
    1.76 +		
    1.77 +		new CookieAccess:access;
    1.78 +		
    1.79 +		while (ReadCookieIterator(iter, 
    1.80 +								name, 
    1.81 +								sizeof(name),
    1.82 +								access, 
    1.83 +								description, 
    1.84 +								sizeof(description)) != false)
    1.85 +		{
    1.86 +			if (access < CookieAccess_Private)
    1.87 +			{
    1.88 +				PrintToConsole(client, "%s - %s", name, description);
    1.89 +			}
    1.90 +		}
    1.91 +		
    1.92 +		return Plugin_Handled;
    1.93 +	}
    1.94 +	
    1.95 +	if (client == 0)
    1.96 +	{
    1.97 +		PrintToServer("%T", "No Console", LANG_SERVER);
    1.98 +		return Plugin_Handled;	
    1.99 +	}
   1.100 +	
   1.101 +	decl String:name[30];
   1.102 +	name[0] = '\0';
   1.103 +	GetCmdArg(1, name, sizeof(name));
   1.104 +	
   1.105 +	new Handle:cookie = FindClientCookie(name);
   1.106 +	
   1.107 +	if (cookie == INVALID_HANDLE)
   1.108 +	{
   1.109 +		ReplyToCommand(client, "[SM] %t", "Cookie not Found", name);
   1.110 +		return Plugin_Handled;
   1.111 +	}
   1.112 +	
   1.113 +	new CookieAccess:access = GetCookieAccess(cookie);
   1.114 +	
   1.115 +	if (access == CookieAccess_Private)
   1.116 +	{
   1.117 +		ReplyToCommand(client, "[SM] %t", "Cookie not Found", name);
   1.118 +		return Plugin_Handled;
   1.119 +	}
   1.120 +	
   1.121 +	decl String:value[100];
   1.122 +	value[0] = '\0';
   1.123 +	
   1.124 +	if (args == 1)
   1.125 +	{
   1.126 +		GetClientCookie(client, cookie, value, sizeof(value));
   1.127 +		ReplyToCommand(client, "[SM] %t", "Cookie Value", name, value);
   1.128 +		
   1.129 +		return Plugin_Handled;
   1.130 +	}
   1.131 +	
   1.132 +	if (access == CookieAccess_Protected)
   1.133 +	{
   1.134 +		ReplyToCommand(client, "[SM] %t", "Protected Cookie", name);
   1.135 +		return Plugin_Handled;
   1.136 +	}
   1.137 +	
   1.138 +	/* Set the new value of the cookie */
   1.139 +	
   1.140 +	GetCmdArg(2, value, sizeof(value));
   1.141 +	
   1.142 +	SetClientCookie(client, cookie, value);
   1.143 +	ReplyToCommand(client, "[SM] %t", "Cookie Changed Value", name, value);
   1.144 +	
   1.145 +	return Plugin_Handled;
   1.146 +}
   1.147 +
   1.148 +public Action:Command_Settings(client, args)
   1.149 +{
   1.150 +	if (client == 0)
   1.151 +	{
   1.152 +		PrintToServer("%T", "No Console", LANG_SERVER);
   1.153 +		return Plugin_Handled;	
   1.154 +	}
   1.155 +	
   1.156 +	ShowCookieMenu(client);
   1.157 +	
   1.158 +	return Plugin_Handled;
   1.159 +}
   1.160 \ No newline at end of file