1.1 --- a/plugins/nextmap.sp Sun May 25 03:26:31 2008 +0000
1.2 +++ b/plugins/nextmap.sp Sun May 25 07:11:16 2008 +0000
1.3 @@ -34,6 +34,8 @@
1.4 #pragma semicolon 1
1.5
1.6 #include <sourcemod>
1.7 +#include "include/nextmap.inc"
1.8 +
1.9
1.10 public Plugin:myinfo =
1.11 {
1.12 @@ -44,12 +46,7 @@
1.13 url = "http://www.sourcemod.net/"
1.14 };
1.15
1.16 -new bool:g_IntermissionCalled;
1.17 -new UserMsg:g_VGUIMenu;
1.18
1.19 -new Handle:g_Cvar_Chattime;
1.20 -new Handle:g_Cvar_Nextmap;
1.21 -
1.22 new g_MapPos = -1;
1.23 new Handle:g_MapList = INVALID_HANDLE;
1.24 new g_MapListSerial = -1;
1.25 @@ -59,19 +56,7 @@
1.26 LoadTranslations("common.phrases");
1.27 LoadTranslations("nextmap.phrases");
1.28
1.29 - g_VGUIMenu = GetUserMessageId("VGUIMenu");
1.30 - if (g_VGUIMenu == INVALID_MESSAGE_ID)
1.31 - {
1.32 - LogError("FATAL: Cannot find VGUIMenu user message id. Nextmap not loaded.");
1.33 - SetFailState("VGUIMenu Not Found");
1.34 - }
1.35 -
1.36 g_MapList = CreateArray(32);
1.37 -
1.38 - HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
1.39 -
1.40 - g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY);
1.41 - g_Cvar_Chattime = FindConVar("mp_chattime");
1.42
1.43 RegConsoleCmd("say", Command_Say);
1.44 RegConsoleCmd("say_team", Command_Say);
1.45 @@ -87,13 +72,13 @@
1.46 // Set to the current map so OnMapStart() will know what to do
1.47 decl String:currentMap[64];
1.48 GetCurrentMap(currentMap, 64);
1.49 - SetConVarString(g_Cvar_Nextmap, currentMap);
1.50 + SetNextMap(currentMap);
1.51 }
1.52
1.53 public OnConfigsExecuted()
1.54 {
1.55 decl String:lastMap[64], String:currentMap[64];
1.56 - GetConVarString(g_Cvar_Nextmap, lastMap, 64);
1.57 + GetNextMap(lastMap, sizeof(lastMap));
1.58 GetCurrentMap(currentMap, 64);
1.59
1.60 // Why am I doing this? If we switched to a new map, but it wasn't what we expected (Due to sm_map, sm_votemap, or
1.61 @@ -104,11 +89,6 @@
1.62 FindAndSetNextMap();
1.63 }
1.64 }
1.65 -
1.66 -public OnMapEnd()
1.67 -{
1.68 - g_IntermissionCalled = false;
1.69 -}
1.70
1.71 public Action:Command_Say(client, args)
1.72 {
1.73 @@ -131,7 +111,7 @@
1.74 if (strcmp(message, "nextmap", false) == 0)
1.75 {
1.76 decl String:map[32];
1.77 - GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
1.78 + GetNextMap(map, sizeof(map));
1.79
1.80 PrintToChat(client, "%t", "Next Map", map);
1.81 }
1.82 @@ -156,10 +136,10 @@
1.83 return Plugin_Handled;
1.84 }
1.85
1.86 - ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map);
1.87 - LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map);
1.88 + ShowActivity(client, "%t", "Changed Next Map", map);
1.89 + LogMessage("\"%L\" changed nextmap to \"%s\"", client, map);
1.90
1.91 - SetConVarString(g_Cvar_Nextmap, map);
1.92 + SetNextMap(map);
1.93
1.94 return Plugin_Handled;
1.95 }
1.96 @@ -179,76 +159,17 @@
1.97 return Plugin_Handled;
1.98 }
1.99
1.100 -public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
1.101 -{
1.102 - if (g_IntermissionCalled)
1.103 - {
1.104 - return Plugin_Handled;
1.105 - }
1.106 -
1.107 - decl String:type[15];
1.108 -
1.109 - /* If we don't get a valid string, bail out. */
1.110 - if (BfReadString(bf, type, sizeof(type)) < 0)
1.111 - {
1.112 - return Plugin_Handled;
1.113 - }
1.114 -
1.115 - if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0))
1.116 - {
1.117 - g_IntermissionCalled = true;
1.118 -
1.119 - decl String:map[32];
1.120 - new Float:fChatTime = GetConVarFloat(g_Cvar_Chattime);
1.121 -
1.122 - GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
1.123 -
1.124 - if (!IsMapValid(map))
1.125 - {
1.126 - if (g_MapPos == -1)
1.127 - {
1.128 - FindAndSetNextMap();
1.129 - }
1.130 - GetArrayString(g_MapList, g_MapPos, map, sizeof(map));
1.131 - }
1.132 -
1.133 - if (fChatTime < 2.0)
1.134 - SetConVarFloat(g_Cvar_Chattime, 2.0);
1.135 -
1.136 - new Handle:dp;
1.137 - CreateDataTimer(fChatTime - 1.0, Timer_ChangeMap, dp);
1.138 - WritePackString(dp, map);
1.139 - }
1.140 -
1.141 - return Plugin_Handled;
1.142 -}
1.143 -
1.144 public Action:Command_Nextmap(args)
1.145 {
1.146 decl String:map[64];
1.147
1.148 - GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
1.149 + GetNextMap(map, sizeof(map));
1.150
1.151 ReplyToCommand(0, "%t", "Next Map", map);
1.152
1.153 return Plugin_Handled;
1.154 }
1.155
1.156 -public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
1.157 -{
1.158 - new String:map[32];
1.159 -
1.160 - ResetPack(dp);
1.161 - ReadPackString(dp, map, sizeof(map));
1.162 -
1.163 - InsertServerCommand("changelevel \"%s\"", map);
1.164 - ServerExecute();
1.165 -
1.166 - LogMessage("Nextmap changed map to \"%s\"", map);
1.167 -
1.168 - return Plugin_Stop;
1.169 -}
1.170 -
1.171 FindAndSetNextMap()
1.172 {
1.173 if (ReadMapList(g_MapList,
1.174 @@ -291,5 +212,5 @@
1.175 g_MapPos = 0;
1.176
1.177 GetArrayString(g_MapList, g_MapPos, mapName, sizeof(mapName));
1.178 - SetConVarString(g_Cvar_Nextmap, mapName);
1.179 + SetNextMap(mapName);
1.180 }