Don't even bother trying to compile these, it's not finished. Just committing for archiving purposes, this is not intended for 1.0 release.
3 * =============================================================================
4 * SourceMod Map Manager Plugin
5 * Contains callbacks for commands
7 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
34 public Action:Command_Say(client, args)
36 decl String:text[192];
37 if (GetCmdArgString(text, sizeof(text)) < 1)
39 return Plugin_Continue;
43 if (text[strlen(text)-1] == '"')
45 text[strlen(text)-1] = '\0';
49 decl String:message[8];
50 BreakString(text[startidx], message, sizeof(message));
52 if (strcmp(message, "nextmap", false) == 0)
55 GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
57 PrintToChat(client, "%t", "Next Map", map);
61 if (GetConVarBool(g_Cvar_RockTheVote) && (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0))
65 ReplyToCommand(client, "[SM] %t", "Map change in progress");
66 return Plugin_Continue;
71 PrintToChat(client, "[SM] %t", "RTV Not Allowed");
72 return Plugin_Continue;
77 PrintToChat(client, "[SM] %t", "RTV Ended");
78 return Plugin_Continue;
83 PrintToChat(client, "[SM] %t", "RTV Started");
84 return Plugin_Continue;
87 if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_RTV_Votes == 0) // Should we keep checking g_Votes here?
89 PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
90 return Plugin_Continue;
93 if (g_RTV_Voted[client])
95 PrintToChat(client, "[SM] %t", "Already Voted");
96 return Plugin_Continue;
100 GetClientName(client, name, sizeof(name));
103 g_RTV_Voted[client] = true;
105 PrintToChatAll("[SM] %t", "RTV Requested", name, g_RTV_Votes, g_RTV_VotesNeeded);
107 if (g_RTV_Votes >= g_RTV_VotesNeeded)
109 g_RTV_Started = true;
110 CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
113 else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
117 ReplyToCommand(client, "[SM] %t", "Map change in progress");
118 return Plugin_Continue;
121 if (g_RTV_Started || g_HasVoteStarted)
123 ReplyToCommand(client, "[SM] %t", "Map vote in progress");
124 return Plugin_Continue;
127 if (g_Nominated[client])
129 PrintToChat(client, "[SM] %t", "Already Nominated");
130 return Plugin_Continue;
133 if (GetArraySize(g_Nominate) >= GetConVarInt(g_Cvar_Maps))
135 PrintToChat(client, "[SM] %t", "Max Nominations");
136 return Plugin_Continue;
139 DisplayMenu(g_Menu_Nominate, client, MENU_TIME_FOREVER);
143 return Plugin_Continue;
146 public Action:Command_Mapvote(client, args)
150 return Plugin_Handled;
153 public Action:Command_Nextmap(args)
157 GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
159 ReplyToCommand(0, "%t", "Next Map", map);
161 return Plugin_Handled;
164 public Action:Command_List(client, args)
166 PrintToConsole(client, "Map Cycle:");
168 decl String:currentMap[64];
169 GetCurrentMap(currentMap, 64);
171 decl String:mapName[64];
172 for (new i = 0; i < GetArraySize(g_MapCycle); i++)
174 GetArrayString(g_MapCycle, i, mapName, sizeof(mapName));
175 if (strcmp(mapName, currentMap) == 0)
177 PrintToConsole(client, "%s <========= Current map", mapName);
179 else if (strcmp(mapName, g_NextMap) == 0)
181 PrintToConsole(client, "%s <========= Next map", mapName);
185 PrintToConsole(client, "%s", mapName);
189 return Plugin_Handled;
192 public Action:Command_SetNextmap(client, args)
196 ReplyToCommand(client, "[SM] Usage: sm_setnextmap <map>");
197 return Plugin_Handled;
202 ReplyToCommand(client, "[SM] %t", "Map change in progress");
203 return Plugin_Handled;
207 GetCmdArg(1, map, sizeof(map));
209 if (!IsMapValid(map))
211 ReplyToCommand(client, "[SM] %t", "Map was not found", map);
212 return Plugin_Handled;
215 ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map);
216 LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map);
220 return Plugin_Handled;
223 public Action:Command_Map(client, args)
227 ReplyToCommand(client, "[SM] Usage: sm_map <map> [r/e]");
228 return Plugin_Handled;
233 ReplyToCommand(client, "[SM] %t", "Map change in progress");
234 return Plugin_Handled;
238 GetCmdArg(1, map, sizeof(map));
240 if (!IsMapValid(map))
242 ReplyToCommand(client, "[SM] %t", "Map was not found", map);
243 return Plugin_Handled;
249 GetCmdArg(2, when, sizeof(when));
251 when[0] = CharToLower(when[0]);
252 if (when[0] != 'r' && when[0] != 'e')
258 SetMapChange(client, map, when);
260 return Plugin_Handled;
263 public Action:Command_Votemap(client, args)
267 ReplyToCommand(client, "[SM] Usage: sm_votemap [r/e] <mapname> [mapname2] ... [mapname5]");
268 return Plugin_Handled;
273 ReplyToCommand(client, "[SM] %t", "Map change in progress");
274 return Plugin_Handled;
277 if (IsVoteInProgress())
279 ReplyToCommand(client, "[SM] %t", "Vote in Progress");
280 return Plugin_Handled;
283 if (!TestVoteDelay(client))
285 return Plugin_Handled;
288 decl String:text[256];
289 GetCmdArgString(text, sizeof(text));
291 decl String:maps[5][64];
295 // Find out if the user specified "when"
296 decl String:when[64];
297 pos = BreakString(text[len], when, sizeof(when));
298 if (!IsMapValid(when))
300 when[0] = CharToLower(when[0]);
301 if (when[0] != 'r' && when[0] != 'e')
303 ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
304 return Plugin_Handled;
309 strcpy(maps[mapCount], sizeof(maps[]), when);
316 while (pos != -1 && mapCount < 5)
318 pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
320 if (!IsMapValid(maps[mapCount]))
322 ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
323 return Plugin_Handled;
331 g_VoteMapInUse = client;
332 g_Client_Data[client][0] = when[0];
334 DisplayVoteMapMenu(client, mapCount, maps);
336 return Plugin_Handled;
339 public Action:Command_Nominate(client, args)
343 ReplyToCommand(client, "[SM] Usage: sm_nominate <mapname>");
344 return Plugin_Handled;
347 if (!GetConVarBool(g_Cvar_Nominate))
349 ReplyToCommand(client, "[SM] Nominations are currently disabled.");
350 return Plugin_Handled;
353 decl String:mapname[64];
354 GetCmdArg(1, mapname, sizeof(mapname));
356 if (FindStringInArray(g_MapList, mapname) == -1)
358 ReplyToCommand(client, "%t", "Map was not found", mapname);
359 return Plugin_Handled;
362 if (GetArraySize(g_Nominated) > 0)
364 if (FindStringInArray(g_Nominated, mapname) != -1)
366 ReplyToCommand(client, "%t", "Map Already In Vote", mapname);
367 return Plugin_Handled;
370 ShiftArrayUp(g_Nominated, 0);
371 SetArrayString(g_Nominated, 0, mapname);
373 while (GetArraySize(g_Nominated) > GetConVarInt(g_Cvar_Maps))
375 RemoveFromArray(g_Nominated, GetConVarInt(g_Cvar_Maps));
380 PushArrayString(g_Nominated, mapname);
383 decl String:item[64];
384 for (new i = 0; i < GetMenuItemCount(g_Menu_Nominate); i++)
386 GetMenuItem(g_Menu_Nominate, i, item, sizeof(item));
387 if (strcmp(item, mapname) == 0)
389 RemoveMenuItem(g_Menu_Nominate, i);
394 ReplyToCommand(client, "%t", "Map Inserted", mapname);
395 LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
397 return Plugin_Handled;