3 * =============================================================================
4 * SourceMod Map Manager Plugin
5 * Contains timer callbacks
7 * SourceMod (C)2004-2008 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:Timer_ChangeMap(Handle:timer)
36 ServerCommand("changelevel \"%s\"", g_NextMap);
37 PushArrayString(g_MapHistory, g_NextMap);
42 public Action:Timer_RandomizeNextmap(Handle:timer)
46 new exclusion = GetConVarInt(g_Cvar_ExcludeMaps);
47 if (exclusion > GetArraySize(g_MapCycle))
49 exclusion = GetArraySize(g_MapCycle) - 1;
52 new b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
53 GetArrayString(g_MapCycle, b, map, sizeof(map));
55 while (FindStringInArray(g_MapHistory, map) != -1)
57 b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
58 GetArrayString(g_MapCycle, b, map, sizeof(map));
63 LogMessage("[MapManager] Randomizer has chosen '%s' as the next map.", map);
68 public Action:Timer_DelayRTV(Handle:timer)
75 public Action:Timer_StartRTV(Handle:timer)
77 if (timer == g_RetryTimer)
79 g_RetryTimer = INVALID_HANDLE;
82 if (g_RetryTimer != INVALID_HANDLE)
87 if (IsVoteInProgress())
89 // Can't start a vote, try again in 5 seconds.
90 g_RetryTimer = CreateTimer(5.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
94 PrintToChatAll("[SM] %t", "RTV Vote Ready");
96 new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
97 SetMenuTitle(MapVoteMenu, "Rock The Vote");
99 new Handle:tempMaps = CloneArray(g_MapList);
102 GetCurrentMap(map, sizeof(map));
103 new index = FindStringInArray(tempMaps, map);
106 RemoveFromArray(tempMaps, index);
109 // We assume that g_RTVMapList is within the correct limits, based on the logic for nominations
110 for (new i = 0; i < GetArraySize(g_RTVMapList); i++)
112 GetArrayString(g_RTVMapList, i, map, sizeof(map));
113 AddMenuItem(MapVoteMenu, map, map);
115 index = FindStringInArray(tempMaps, map);
118 RemoveFromArray(tempMaps, index);
122 new limit = GetConVarInt(g_Cvar_Maps) - GetArraySize(g_RTVMapList);
123 if (limit > GetArraySize(tempMaps))
125 limit = GetArraySize(tempMaps);
128 for (new i = 0; i < limit; i++)
130 new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
131 GetArrayString(tempMaps, b, map, sizeof(map));
132 PushArrayString(g_RTVMapList, map);
133 AddMenuItem(MapVoteMenu, map, map);
134 RemoveFromArray(tempMaps, b);
137 CloseHandle(tempMaps);
139 AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");
141 SetMenuExitButton(MapVoteMenu, false);
142 VoteMenuToAll(MapVoteMenu, 20);
144 LogMessage("[SM] Rockthevote was successfully started.");
147 public Action:Timer_StartMapVote(Handle:timer)
149 if (!GetArraySize(g_MapList))
154 if (timer == g_RetryTimer)
156 g_RetryTimer = INVALID_HANDLE;
160 g_VoteTimer = INVALID_HANDLE;