ferret99gt@1175: /**
ds@1330: * vim: set ts=4 :
ds@1330: * =============================================================================
ds@1330: * SourceMod Nextmap Plugin
ds@1330: * Adds sm_nextmap cvar for changing map and nextmap chat trigger.
ds@1330: *
ds@1330: * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
ferret99gt@1175: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
ds@1330: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
ferret99gt@1175: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
ds@1330: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
ferret99gt@1175: *
ferret99gt@1175: * Version: $Id$
ferret99gt@1175: */
ds@1330:
ds@1330: #pragma semicolon 1
ds@1330:
ferret99gt@1175: #include
ferret99gt@1175:
ferret99gt@1175: public Plugin:myinfo =
ferret99gt@1175: {
ferret99gt@1175: name = "Nextmap",
ferret99gt@1175: author = "AlliedModders LLC",
ferret99gt@1175: description = "Provides nextmap and sm_nextmap",
ferret99gt@1175: version = SOURCEMOD_VERSION,
ferret99gt@1175: url = "http://www.sourcemod.net/"
ferret99gt@1175: };
ferret99gt@1175:
ferret99gt@1175: new bool:g_IntermissionCalled;
ferret99gt@1175: new UserMsg:g_VGUIMenu;
ferret99gt@1175:
ferret99gt@1175: new Handle:g_Cvar_Chattime;
ferret99gt@1175: new Handle:g_Cvar_Nextmap;
ferret99gt@1175: new Handle:g_Cvar_Mapcycle;
ferret99gt@1175:
ferret99gt@1175: new g_MapPos = -1;
ferret99gt@1175: new Handle:g_MapList = INVALID_HANDLE;
ferret99gt@1175:
ferret99gt@1175: public OnPluginStart()
ferret99gt@1175: {
ferret99gt@1366: LoadTranslations("common.phrases");
ferret99gt@1187: LoadTranslations("nextmap.phrases");
ferret99gt@1175:
ferret99gt@1175: g_VGUIMenu = GetUserMessageId("VGUIMenu");
ferret99gt@1175: if (g_VGUIMenu == INVALID_MESSAGE_ID)
ferret99gt@1175: {
ferret99gt@1366: LogError("FATAL: Cannot find VGUIMenu user message id. Nextmap not loaded.");
ferret99gt@1366: SetFailState("VGUIMenu Not Found");
ferret99gt@1175: }
ferret99gt@1175:
ferret99gt@1175: g_Cvar_Chattime = FindConVar("mp_chattime");
ferret99gt@1175: g_Cvar_Mapcycle = FindConVar("mapcyclefile");
ferret99gt@1175:
ferret99gt@1175: g_MapList = CreateArray(32);
ferret99gt@1175:
ferret99gt@1175: decl String:mapCycle[64];
ferret99gt@1175: GetConVarString(g_Cvar_Mapcycle, mapCycle, 64);
ferret99gt@1366: if (LoadMaps(mapCycle) < 1)
ferret99gt@1175: {
ferret99gt@1366: LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
ferret99gt@1366: SetFailState("Mapcycle Not Found");
ferret99gt@1175: }
ferret99gt@1175:
ferret99gt@1175: HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
ferret99gt@1175: HookConVarChange(g_Cvar_Mapcycle, ConVarChange_Mapcyclefile);
ferret99gt@1175:
ferret99gt@1180: g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY);
ferret99gt@1175:
ferret99gt@1175: RegConsoleCmd("say", Command_Say);
ferret99gt@1175: RegConsoleCmd("say_team", Command_Say);
ferret99gt@1180:
ferret99gt@1366: RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap