pred@2048: /**
pred@2048: * vim: set ts=4 :
pred@2048: * =============================================================================
pred@2048: * SourceMod Map Management Plugin
pred@2048: * Provides all map related functionality, including map changing, map voting,
pred@2048: * and nextmap.
pred@2048: *
pred@2048: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
pred@2048: * =============================================================================
pred@2048: *
pred@2048: * This program is free software; you can redistribute it and/or modify it under
pred@2048: * the terms of the GNU General Public License, version 3.0, as published by the
pred@2048: * Free Software Foundation.
pred@2048: *
pred@2048: * This program is distributed in the hope that it will be useful, but WITHOUT
pred@2048: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
pred@2048: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
pred@2048: * details.
pred@2048: *
pred@2048: * You should have received a copy of the GNU General Public License along with
pred@2048: * this program. If not, see .
pred@2048: *
pred@2048: * As a special exception, AlliedModders LLC gives you permission to link the
pred@2048: * code of this program (as well as its derivative works) to "Half-Life 2," the
pred@2048: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
pred@2048: * by the Valve Corporation. You must obey the GNU General Public License in
pred@2048: * all respects for all other code used. Additionally, AlliedModders LLC grants
pred@2048: * this exception to all derivative works. AlliedModders LLC defines further
pred@2048: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
pred@2048: * or .
pred@2048: *
pred@2048: * Version: $Id$
pred@2048: */
pred@2048:
pred@2048:
pred@2048: #pragma semicolon 1
pred@2048: #include
pred@2048: #include
pred@2048:
pred@2048: public Plugin:myinfo =
pred@2048: {
pred@2048: name = "Client Preferences",
pred@2048: author = "AlliedModders LLC",
pred@2048: description = "Client peferences and settings menu",
pred@2048: version = SOURCEMOD_VERSION,
pred@2048: url = "http://www.sourcemod.net/"
pred@2048: };
pred@2048:
pred@2048: public OnPluginStart()
pred@2048: {
pred@2048: LoadTranslations("clientprefs.phrases");
pred@2048:
pred@2049: RegConsoleCmd("sm_cookies", Command_Cookie, "sm_cookies [value]");
pred@2048: RegConsoleCmd("sm_settings", Command_Settings);
pred@2048: }
pred@2048:
pred@2048: public Action:Command_Cookie(client, args)
pred@2048: {
pred@2048: if (args == 0)
pred@2048: {
pred@2207: ReplyToCommand(client, "[SM] Usage: sm_cookies [value]");
pred@2048: ReplyToCommand(client, "[SM] %t", "Printing Cookie List");
pred@2048:
pred@2048: /* Show list of cookies */
pred@2048: new Handle:iter = GetCookieIterator();
pred@2048:
pred@2048: decl String:name[30];
pred@2048: name[0] = '\0';
pred@2048: decl String:description[255];
pred@2048: description[0] = '\0';
pred@2048:
pred@2048: PrintToConsole(client, "%t:", "Cookie List");
pred@2048:
pred@2048: new CookieAccess:access;
pred@2048:
pred@2048: while (ReadCookieIterator(iter,
pred@2048: name,
pred@2048: sizeof(name),
pred@2048: access,
pred@2048: description,
pred@2048: sizeof(description)) != false)
pred@2048: {
pred@2048: if (access < CookieAccess_Private)
pred@2048: {
pred@2048: PrintToConsole(client, "%s - %s", name, description);
pred@2048: }
pred@2048: }
pred@2048:
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2076: if (client == 0)
pred@2076: {
pred@2076: PrintToServer("%T", "No Console", LANG_SERVER);
pred@2076: return Plugin_Handled;
pred@2076: }
pred@2076:
pred@2048: decl String:name[30];
pred@2048: name[0] = '\0';
pred@2048: GetCmdArg(1, name, sizeof(name));
pred@2048:
pred@2048: new Handle:cookie = FindClientCookie(name);
pred@2048:
pred@2048: if (cookie == INVALID_HANDLE)
pred@2048: {
pred@2048: ReplyToCommand(client, "[SM] %t", "Cookie not Found", name);
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: new CookieAccess:access = GetCookieAccess(cookie);
pred@2048:
pred@2048: if (access == CookieAccess_Private)
pred@2048: {
pred@2048: ReplyToCommand(client, "[SM] %t", "Cookie not Found", name);
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: decl String:value[100];
pred@2048: value[0] = '\0';
pred@2048:
pred@2048: if (args == 1)
pred@2048: {
pred@2048: GetClientCookie(client, cookie, value, sizeof(value));
pred@2048: ReplyToCommand(client, "[SM] %t", "Cookie Value", name, value);
pred@2048:
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: if (access == CookieAccess_Protected)
pred@2048: {
pred@2048: ReplyToCommand(client, "[SM] %t", "Protected Cookie", name);
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: /* Set the new value of the cookie */
pred@2048:
pred@2048: GetCmdArg(2, value, sizeof(value));
pred@2048:
pred@2048: SetClientCookie(client, cookie, value);
pred@2048: ReplyToCommand(client, "[SM] %t", "Cookie Changed Value", name, value);
pred@2048:
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: public Action:Command_Settings(client, args)
pred@2048: {
pred@2048: if (client == 0)
pred@2048: {
pred@2048: PrintToServer("%T", "No Console", LANG_SERVER);
pred@2048: return Plugin_Handled;
pred@2048: }
pred@2048:
pred@2048: ShowCookieMenu(client);
pred@2048:
pred@2048: return Plugin_Handled;
pred@2048: }