1.1 --- a/plugins/nextmap.sp Wed Aug 22 01:18:17 2007 +0000
1.2 +++ b/plugins/nextmap.sp Wed Aug 22 01:19:10 2007 +0000
1.3 @@ -53,20 +53,17 @@
1.4
1.5 new g_MapPos = -1;
1.6 new Handle:g_MapList = INVALID_HANDLE;
1.7 -
1.8 -#if 0
1.9 -new bool:g_INS = false;
1.10 -#endif
1.11
1.12 public OnPluginStart()
1.13 {
1.14 + LoadTranslations("common.phrases");
1.15 LoadTranslations("nextmap.phrases");
1.16
1.17 g_VGUIMenu = GetUserMessageId("VGUIMenu");
1.18 if (g_VGUIMenu == INVALID_MESSAGE_ID)
1.19 {
1.20 - LogMessage("FATAL: Cannot find VGUIMenu user message id. Nextmap not loaded.");
1.21 - return;
1.22 + LogError("FATAL: Cannot find VGUIMenu user message id. Nextmap not loaded.");
1.23 + SetFailState("VGUIMenu Not Found");
1.24 }
1.25
1.26 g_Cvar_Chattime = FindConVar("mp_chattime");
1.27 @@ -76,10 +73,10 @@
1.28
1.29 decl String:mapCycle[64];
1.30 GetConVarString(g_Cvar_Mapcycle, mapCycle, 64);
1.31 - if (LoadMaps(mapCycle) == 0)
1.32 + if (LoadMaps(mapCycle) < 1)
1.33 {
1.34 - LogMessage("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.35 - return;
1.36 + LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.37 + SetFailState("Mapcycle Not Found");
1.38 }
1.39
1.40 HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
1.41 @@ -89,21 +86,11 @@
1.42
1.43 RegConsoleCmd("say", Command_Say);
1.44 RegConsoleCmd("say_team", Command_Say);
1.45 -
1.46 - #if 0
1.47 - decl String:modname[64];
1.48 - GetGameFolderName(modname, sizeof(modname));
1.49 -
1.50 - if (strcmp(modname, "ins") == 0)
1.51 - {
1.52 - RegConsoleCmd("say2", Command_SayChat);
1.53 - g_INS = true;
1.54 - }
1.55 - #endif
1.56
1.57 + RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>");
1.58 RegConsoleCmd("listmaps", Command_List);
1.59 -
1.60 - /* Set to the current map so OnMapStart() will know what to do */
1.61 +
1.62 + // Set to the current map so OnMapStart() will know what to do
1.63 decl String:currentMap[64];
1.64 GetCurrentMap(currentMap, 64);
1.65 SetConVarString(g_Cvar_Nextmap, currentMap);
1.66 @@ -133,7 +120,13 @@
1.67 {
1.68 if (strcmp(oldValue, newValue, false) != 0)
1.69 {
1.70 - LoadMaps(newValue);
1.71 + if (LoadMaps(newValue) < 1)
1.72 + {
1.73 + LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.74 + SetFailState("Mapcycle Not Found");
1.75 + }
1.76 +
1.77 + FindAndSetNextMap();
1.78 }
1.79 }
1.80
1.81 @@ -149,13 +142,6 @@
1.82 startidx = 1;
1.83 }
1.84
1.85 - #if 0
1.86 - if (g_INS)
1.87 - {
1.88 - startidx += 4;
1.89 - }
1.90 - #endif
1.91 -
1.92 decl String:message[8];
1.93 BreakString(text[startidx], message, sizeof(message));
1.94
1.95 @@ -169,6 +155,46 @@
1.96
1.97 return Plugin_Continue;
1.98 }
1.99 +
1.100 +public Action:Command_SetNextmap(client, args)
1.101 +{
1.102 + if (args < 1)
1.103 + {
1.104 + ReplyToCommand(client, "[SM] Usage: sm_setnextmap <map>");
1.105 + return Plugin_Handled;
1.106 + }
1.107 +
1.108 + decl String:map[64];
1.109 + GetCmdArg(1, map, sizeof(map));
1.110 +
1.111 + if (!IsMapValid(map))
1.112 + {
1.113 + ReplyToCommand(client, "[SM] %t", "Map was not found", map);
1.114 + return Plugin_Handled;
1.115 + }
1.116 +
1.117 + ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map);
1.118 + LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map);
1.119 +
1.120 + SetConVarString(g_Cvar_Nextmap, map);
1.121 +
1.122 + return Plugin_Handled;
1.123 +}
1.124 +
1.125 +public Action:Command_List(client, args)
1.126 +{
1.127 + PrintToConsole(client, "Map Cycle:");
1.128 +
1.129 + new mapCount = GetArraySize(g_MapList);
1.130 + decl String:mapName[32];
1.131 + for (new i = 0; i < mapCount; i++)
1.132 + {
1.133 + GetArrayString(g_MapList, i, mapName, sizeof(mapName));
1.134 + PrintToConsole(client, "%s", mapName);
1.135 + }
1.136 +
1.137 + return Plugin_Handled;
1.138 +}
1.139
1.140 public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
1.141 {
1.142 @@ -215,21 +241,6 @@
1.143 return Plugin_Stop;
1.144 }
1.145
1.146 -public Action:Command_List(client, args)
1.147 -{
1.148 - PrintToConsole(client, "Map Cycle:");
1.149 -
1.150 - new mapCount = GetArraySize(g_MapList);
1.151 - decl String:mapName[32];
1.152 - for (new i = 0; i < mapCount; i++)
1.153 - {
1.154 - GetArrayString(g_MapList, i, mapName, sizeof(mapName));
1.155 - PrintToConsole(client, "%s", mapName);
1.156 - }
1.157 -
1.158 - return Plugin_Handled;
1.159 -}
1.160 -
1.161 LoadMaps(const String:path[])
1.162 {
1.163 if (!FileExists(path))