|
pred@2048
|
1 |
/** |
|
pred@2048
|
2 |
* vim: set ts=4 : |
|
pred@2048
|
3 |
* ============================================================================= |
|
pred@2048
|
4 |
* SourceMod Map Management Plugin |
|
pred@2048
|
5 |
* Provides all map related functionality, including map changing, map voting, |
|
pred@2048
|
6 |
* and nextmap. |
|
pred@2048
|
7 |
* |
|
pred@2048
|
8 |
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. |
|
pred@2048
|
9 |
* ============================================================================= |
|
pred@2048
|
10 |
* |
|
pred@2048
|
11 |
* This program is free software; you can redistribute it and/or modify it under |
|
pred@2048
|
12 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
pred@2048
|
13 |
* Free Software Foundation. |
|
pred@2048
|
14 |
* |
|
pred@2048
|
15 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
pred@2048
|
16 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
pred@2048
|
17 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
pred@2048
|
18 |
* details. |
|
pred@2048
|
19 |
* |
|
pred@2048
|
20 |
* You should have received a copy of the GNU General Public License along with |
|
pred@2048
|
21 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
pred@2048
|
22 |
* |
|
pred@2048
|
23 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
pred@2048
|
24 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
pred@2048
|
25 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
pred@2048
|
26 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
pred@2048
|
27 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
pred@2048
|
28 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
pred@2048
|
29 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
pred@2048
|
30 |
* or <http://www.sourcemod.net/license.php>. |
|
pred@2048
|
31 |
* |
|
pred@2048
|
32 |
* Version: $Id$ |
|
pred@2048
|
33 |
*/ |
|
pred@2048
|
34 |
|
|
pred@2048
|
35 |
|
|
pred@2048
|
36 |
#pragma semicolon 1 |
|
pred@2048
|
37 |
#include <sourcemod> |
|
pred@2048
|
38 |
#include <clientprefs> |
|
pred@2048
|
39 |
|
|
pred@2048
|
40 |
public Plugin:myinfo = |
|
pred@2048
|
41 |
{ |
|
pred@2048
|
42 |
name = "Client Preferences", |
|
pred@2048
|
43 |
author = "AlliedModders LLC", |
|
pred@2048
|
44 |
description = "Client peferences and settings menu", |
|
pred@2048
|
45 |
version = SOURCEMOD_VERSION, |
|
pred@2048
|
46 |
url = "http://www.sourcemod.net/" |
|
pred@2048
|
47 |
}; |
|
pred@2048
|
48 |
|
|
pred@2048
|
49 |
public OnPluginStart() |
|
pred@2048
|
50 |
{ |
|
pred@2048
|
51 |
LoadTranslations("clientprefs.phrases"); |
|
pred@2048
|
52 |
|
|
pred@2049
|
53 |
RegConsoleCmd("sm_cookies", Command_Cookie, "sm_cookies <name> [value]"); |
|
pred@2048
|
54 |
RegConsoleCmd("sm_settings", Command_Settings); |
|
pred@2048
|
55 |
} |
|
pred@2048
|
56 |
|
|
pred@2048
|
57 |
public Action:Command_Cookie(client, args) |
|
pred@2048
|
58 |
{ |
|
pred@2048
|
59 |
if (args == 0) |
|
pred@2048
|
60 |
{ |
|
pred@2048
|
61 |
ReplyToCommand(client, "[SM] Usage: sm_cookie <name> [value]"); |
|
pred@2048
|
62 |
ReplyToCommand(client, "[SM] %t", "Printing Cookie List"); |
|
pred@2048
|
63 |
|
|
pred@2048
|
64 |
/* Show list of cookies */ |
|
pred@2048
|
65 |
new Handle:iter = GetCookieIterator(); |
|
pred@2048
|
66 |
|
|
pred@2048
|
67 |
decl String:name[30]; |
|
pred@2048
|
68 |
name[0] = '\0'; |
|
pred@2048
|
69 |
decl String:description[255]; |
|
pred@2048
|
70 |
description[0] = '\0'; |
|
pred@2048
|
71 |
|
|
pred@2048
|
72 |
PrintToConsole(client, "%t:", "Cookie List"); |
|
pred@2048
|
73 |
|
|
pred@2048
|
74 |
new CookieAccess:access; |
|
pred@2048
|
75 |
|
|
pred@2048
|
76 |
while (ReadCookieIterator(iter, |
|
pred@2048
|
77 |
name, |
|
pred@2048
|
78 |
sizeof(name), |
|
pred@2048
|
79 |
access, |
|
pred@2048
|
80 |
description, |
|
pred@2048
|
81 |
sizeof(description)) != false) |
|
pred@2048
|
82 |
{ |
|
pred@2048
|
83 |
if (access < CookieAccess_Private) |
|
pred@2048
|
84 |
{ |
|
pred@2048
|
85 |
PrintToConsole(client, "%s - %s", name, description); |
|
pred@2048
|
86 |
} |
|
pred@2048
|
87 |
} |
|
pred@2048
|
88 |
|
|
pred@2048
|
89 |
return Plugin_Handled; |
|
pred@2048
|
90 |
} |
|
pred@2048
|
91 |
|
|
pred@2048
|
92 |
decl String:name[30]; |
|
pred@2048
|
93 |
name[0] = '\0'; |
|
pred@2048
|
94 |
GetCmdArg(1, name, sizeof(name)); |
|
pred@2048
|
95 |
|
|
pred@2048
|
96 |
new Handle:cookie = FindClientCookie(name); |
|
pred@2048
|
97 |
|
|
pred@2048
|
98 |
if (cookie == INVALID_HANDLE) |
|
pred@2048
|
99 |
{ |
|
pred@2048
|
100 |
ReplyToCommand(client, "[SM] %t", "Cookie not Found", name); |
|
pred@2048
|
101 |
return Plugin_Handled; |
|
pred@2048
|
102 |
} |
|
pred@2048
|
103 |
|
|
pred@2048
|
104 |
new CookieAccess:access = GetCookieAccess(cookie); |
|
pred@2048
|
105 |
|
|
pred@2048
|
106 |
if (access == CookieAccess_Private) |
|
pred@2048
|
107 |
{ |
|
pred@2048
|
108 |
ReplyToCommand(client, "[SM] %t", "Cookie not Found", name); |
|
pred@2048
|
109 |
return Plugin_Handled; |
|
pred@2048
|
110 |
} |
|
pred@2048
|
111 |
|
|
pred@2048
|
112 |
decl String:value[100]; |
|
pred@2048
|
113 |
value[0] = '\0'; |
|
pred@2048
|
114 |
|
|
pred@2048
|
115 |
if (args == 1) |
|
pred@2048
|
116 |
{ |
|
pred@2048
|
117 |
GetClientCookie(client, cookie, value, sizeof(value)); |
|
pred@2048
|
118 |
ReplyToCommand(client, "[SM] %t", "Cookie Value", name, value); |
|
pred@2048
|
119 |
|
|
pred@2048
|
120 |
return Plugin_Handled; |
|
pred@2048
|
121 |
} |
|
pred@2048
|
122 |
|
|
pred@2048
|
123 |
if (access == CookieAccess_Protected) |
|
pred@2048
|
124 |
{ |
|
pred@2048
|
125 |
ReplyToCommand(client, "[SM] %t", "Protected Cookie", name); |
|
pred@2048
|
126 |
return Plugin_Handled; |
|
pred@2048
|
127 |
} |
|
pred@2048
|
128 |
|
|
pred@2048
|
129 |
/* Set the new value of the cookie */ |
|
pred@2048
|
130 |
|
|
pred@2048
|
131 |
GetCmdArg(2, value, sizeof(value)); |
|
pred@2048
|
132 |
|
|
pred@2048
|
133 |
SetClientCookie(client, cookie, value); |
|
pred@2048
|
134 |
ReplyToCommand(client, "[SM] %t", "Cookie Changed Value", name, value); |
|
pred@2048
|
135 |
|
|
pred@2048
|
136 |
return Plugin_Handled; |
|
pred@2048
|
137 |
} |
|
pred@2048
|
138 |
|
|
pred@2048
|
139 |
public Action:Command_Settings(client, args) |
|
pred@2048
|
140 |
{ |
|
pred@2048
|
141 |
if (client == 0) |
|
pred@2048
|
142 |
{ |
|
pred@2048
|
143 |
PrintToServer("%T", "No Console", LANG_SERVER); |
|
pred@2048
|
144 |
return Plugin_Handled; |
|
pred@2048
|
145 |
} |
|
pred@2048
|
146 |
|
|
pred@2048
|
147 |
ShowCookieMenu(client); |
|
pred@2048
|
148 |
|
|
pred@2048
|
149 |
return Plugin_Handled; |
|
pred@2048
|
150 |
} |