From d9357d52241f550351f5a41eeacfe4886d0db49a Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Sun, 25 May 2008 07:11:16 +0000 Subject: [PATCH] Fixed amb1454 - Nextmap broken on mods that use the scores usermsg differently to CS:S --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402185 --- core/Makefile | 4 +- core/NextMap.cpp | 90 ++ core/NextMap.h | 52 + core/msvc8/sourcemod_mm.vcproj | 12 + core/msvc9/sourcemod_mm.sln | 41 + core/msvc9/sourcemod_mm.vcproj | 1723 ++++++++++++++++++++++++++++++ core/smn_nextmap.cpp | 63 ++ plugins/include/nextmap.inc | 54 + plugins/include/sourcemod.inc | 1 + plugins/nextmap.sp | 99 +- translations/nextmap.phrases.txt | 7 +- 11 files changed, 2054 insertions(+), 92 deletions(-) create mode 100644 core/NextMap.cpp create mode 100644 core/NextMap.h create mode 100644 core/msvc9/sourcemod_mm.sln create mode 100644 core/msvc9/sourcemod_mm.vcproj create mode 100644 core/smn_nextmap.cpp create mode 100644 plugins/include/nextmap.inc diff --git a/core/Makefile b/core/Makefile index 95ba47a4..5d02e221 100644 --- a/core/Makefile +++ b/core/Makefile @@ -18,14 +18,14 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC sm_autonatives.cpp sm_memtable.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \ sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \ MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp sm_crc32.cpp \ - frame_hooks.cpp concmd_cleaner.cpp Profiler.cpp PhraseCollection.cpp + frame_hooks.cpp concmd_cleaner.cpp Profiler.cpp PhraseCollection.cpp NextMap.cpp OBJECTS += smn_admin.cpp smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \ smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \ smn_filesystem.cpp smn_float.cpp smn_functions.cpp smn_gameconfigs.cpp smn_halflife.cpp \ smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp smn_maplists.cpp \ smn_lang.cpp smn_player.cpp smn_string.cpp smn_sorting.cpp smn_textparse.cpp smn_timers.cpp \ smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp smn_adt_array.cpp \ - smn_adt_trie.cpp smn_hudtext.cpp smn_adt_stack.cpp + smn_adt_trie.cpp smn_hudtext.cpp smn_adt_stack.cpp smn_nextmap.cpp OBJECTS += systems/ExtensionSys.cpp systems/ForwardSys.cpp systems/HandleSys.cpp \ systems/LibrarySys.cpp systems/PluginInfoDatabase.cpp systems/PluginSys.cpp \ systems/ShareSys.cpp vm/sp_vm_basecontext.cpp vm/sp_vm_engine.cpp \ diff --git a/core/NextMap.cpp b/core/NextMap.cpp new file mode 100644 index 00000000..3c2c0b1e --- /dev/null +++ b/core/NextMap.cpp @@ -0,0 +1,90 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#include "NextMap.h" +#include "Logger.h" +#include "sourcemm_api.h" +#include "sm_stringutil.h" + +NextMapManager g_NextMap; + +SH_DECL_HOOK2_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *); + +ConVar sm_nextmap("sm_nextmap", "", FCVAR_NOTIFY); + +void NextMapManager::OnSourceModAllInitialized_Post() +{ +#if defined ORANGEBOX_BUILD + SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); +#else + SH_ADD_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false); +#endif +} + +void NextMapManager::OnSourceModShutdown() +{ +#if defined ORANGEBOX_BUILD + SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); +#else + SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false); +#endif +} + +const char *NextMapManager::GetNextMap() +{ + return sm_nextmap.GetString(); +} + +bool NextMapManager::SetNextMap(const char *map) +{ + if (!engine->IsMapValid(map)) + { + return false; + } + + sm_nextmap.SetValue(map); + + return true; +} + +void NextMapManager::HookChangeLevel(const char *map, const char *unknown) +{ + const char *newmap = sm_nextmap.GetString(); + + if (newmap[0] == 0 || !engine->IsMapValid(newmap)) + { + RETURN_META(MRES_IGNORED); + } + + g_Logger.LogMessage("[SM] Changed map to \"%s\"", newmap); + + RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown)); +} diff --git a/core/NextMap.h b/core/NextMap.h new file mode 100644 index 00000000..a7ae75ba --- /dev/null +++ b/core/NextMap.h @@ -0,0 +1,52 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_NEXTMAP_H_ +#define _INCLUDE_SOURCEMOD_NEXTMAP_H_ + +#include "sm_globals.h" +#include "eiface.h" + +class NextMapManager : public SMGlobalClass +{ +public: + void OnSourceModAllInitialized_Post(); + void OnSourceModShutdown(); + + const char *GetNextMap(); + bool SetNextMap(const char *map); + + void HookChangeLevel(const char *map, const char *unknown); +}; + +extern NextMapManager g_NextMap; + +#endif //_INCLUDE_SOURCEMOD_NEXTMAP_H_ diff --git a/core/msvc8/sourcemod_mm.vcproj b/core/msvc8/sourcemod_mm.vcproj index f61857de..2968ecb3 100644 --- a/core/msvc8/sourcemod_mm.vcproj +++ b/core/msvc8/sourcemod_mm.vcproj @@ -901,6 +901,10 @@ RelativePath="..\MenuVoting.cpp" > + + @@ -1067,6 +1071,10 @@ RelativePath="..\MenuVoting.h" > + + @@ -1634,6 +1642,10 @@ RelativePath="..\smn_menus.cpp" > + + diff --git a/core/msvc9/sourcemod_mm.sln b/core/msvc9/sourcemod_mm.sln new file mode 100644 index 00000000..231543e2 --- /dev/null +++ b/core/msvc9/sourcemod_mm.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 + CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 + CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 + Debug - Episode 1|Win32 = Debug - Episode 1|Win32 + Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 + Debug - Orange Box|Win32 = Debug - Orange Box|Win32 + Release - Episode 1|Win32 = Release - Episode 1|Win32 + Release - Old Metamod|Win32 = Release - Old Metamod|Win32 + Release - Orange Box|Win32 = Release - Orange Box|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj new file mode 100644 index 00000000..3c145008 --- /dev/null +++ b/core/msvc9/sourcemod_mm.vcproj @@ -0,0 +1,1723 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/smn_nextmap.cpp b/core/smn_nextmap.cpp new file mode 100644 index 00000000..0140a573 --- /dev/null +++ b/core/smn_nextmap.cpp @@ -0,0 +1,63 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#include "sm_globals.h" +#include "NextMap.h" + +static cell_t sm_GetNextMap(IPluginContext *pCtx, const cell_t *params) +{ + const char *map = g_NextMap.GetNextMap(); + + if (map[0] == 0) + { + return 0; + } + + pCtx->StringToLocal(params[1], params[2], map); + + return 1; +} + +static cell_t sm_SetNextMap(IPluginContext *pCtx, const cell_t *params) +{ + char *map; + pCtx->LocalToString(params[1], &map); + + return g_NextMap.SetNextMap(map); +} + + +REGISTER_NATIVES(nextmapnatives) +{ + {"GetNextMap", sm_GetNextMap}, + {"SetNextMap", sm_SetNextMap}, + {NULL, NULL}, +}; diff --git a/plugins/include/nextmap.inc b/plugins/include/nextmap.inc new file mode 100644 index 00000000..e811ae52 --- /dev/null +++ b/plugins/include/nextmap.inc @@ -0,0 +1,54 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#if defined _nextmap_included_ + #endinput +#endif +#define _nextmap_included_ + +/** + * Sets SourceMod's internal nextmap. + * Equivalent to changing sm_nextmap but with an added validity check. + * + * @param map Next map to set. + * @return True if the nextmap was set, false if map was invalid. + */ +native bool:SetNextMap(const String:map[]); + +/** + * Returns SourceMod's internal nextmap. + * + * @param map Buffer to store the nextmap name. + * @param maxlen Maximum length of the map buffer. + * @return True if a Map was found and copied, false if no nextmap is set (map will be unchanged). + */ +native bool:GetNextMap(String:map[], maxlen); \ No newline at end of file diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index a65281fb..d7ababb2 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -72,6 +72,7 @@ struct Plugin #include #include #include +#include /** * Declare this as a struct in your plugin to expose its information. diff --git a/plugins/nextmap.sp b/plugins/nextmap.sp index c3767276..2589ea16 100644 --- a/plugins/nextmap.sp +++ b/plugins/nextmap.sp @@ -34,6 +34,8 @@ #pragma semicolon 1 #include +#include "include/nextmap.inc" + public Plugin:myinfo = { @@ -44,12 +46,7 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -new bool:g_IntermissionCalled; -new UserMsg:g_VGUIMenu; -new Handle:g_Cvar_Chattime; -new Handle:g_Cvar_Nextmap; - new g_MapPos = -1; new Handle:g_MapList = INVALID_HANDLE; new g_MapListSerial = -1; @@ -59,19 +56,7 @@ public OnPluginStart() LoadTranslations("common.phrases"); LoadTranslations("nextmap.phrases"); - g_VGUIMenu = GetUserMessageId("VGUIMenu"); - if (g_VGUIMenu == INVALID_MESSAGE_ID) - { - LogError("FATAL: Cannot find VGUIMenu user message id. Nextmap not loaded."); - SetFailState("VGUIMenu Not Found"); - } - g_MapList = CreateArray(32); - - HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu); - - g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY); - g_Cvar_Chattime = FindConVar("mp_chattime"); RegConsoleCmd("say", Command_Say); RegConsoleCmd("say_team", Command_Say); @@ -87,13 +72,13 @@ public OnPluginStart() // Set to the current map so OnMapStart() will know what to do decl String:currentMap[64]; GetCurrentMap(currentMap, 64); - SetConVarString(g_Cvar_Nextmap, currentMap); + SetNextMap(currentMap); } public OnConfigsExecuted() { decl String:lastMap[64], String:currentMap[64]; - GetConVarString(g_Cvar_Nextmap, lastMap, 64); + GetNextMap(lastMap, sizeof(lastMap)); GetCurrentMap(currentMap, 64); // 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 @@ -104,11 +89,6 @@ public OnConfigsExecuted() FindAndSetNextMap(); } } - -public OnMapEnd() -{ - g_IntermissionCalled = false; -} public Action:Command_Say(client, args) { @@ -131,7 +111,7 @@ public Action:Command_Say(client, args) if (strcmp(message, "nextmap", false) == 0) { decl String:map[32]; - GetConVarString(g_Cvar_Nextmap, map, sizeof(map)); + GetNextMap(map, sizeof(map)); PrintToChat(client, "%t", "Next Map", map); } @@ -156,10 +136,10 @@ public Action:Command_SetNextmap(client, args) return Plugin_Handled; } - ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map); - LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map); + ShowActivity(client, "%t", "Changed Next Map", map); + LogMessage("\"%L\" changed nextmap to \"%s\"", client, map); - SetConVarString(g_Cvar_Nextmap, map); + SetNextMap(map); return Plugin_Handled; } @@ -179,76 +159,17 @@ public Action:Command_List(client, args) return Plugin_Handled; } -public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init) -{ - if (g_IntermissionCalled) - { - return Plugin_Handled; - } - - decl String:type[15]; - - /* If we don't get a valid string, bail out. */ - if (BfReadString(bf, type, sizeof(type)) < 0) - { - return Plugin_Handled; - } - - if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0)) - { - g_IntermissionCalled = true; - - decl String:map[32]; - new Float:fChatTime = GetConVarFloat(g_Cvar_Chattime); - - GetConVarString(g_Cvar_Nextmap, map, sizeof(map)); - - if (!IsMapValid(map)) - { - if (g_MapPos == -1) - { - FindAndSetNextMap(); - } - GetArrayString(g_MapList, g_MapPos, map, sizeof(map)); - } - - if (fChatTime < 2.0) - SetConVarFloat(g_Cvar_Chattime, 2.0); - - new Handle:dp; - CreateDataTimer(fChatTime - 1.0, Timer_ChangeMap, dp); - WritePackString(dp, map); - } - - return Plugin_Handled; -} - public Action:Command_Nextmap(args) { decl String:map[64]; - GetConVarString(g_Cvar_Nextmap, map, sizeof(map)); + GetNextMap(map, sizeof(map)); ReplyToCommand(0, "%t", "Next Map", map); return Plugin_Handled; } -public Action:Timer_ChangeMap(Handle:timer, Handle:dp) -{ - new String:map[32]; - - ResetPack(dp); - ReadPackString(dp, map, sizeof(map)); - - InsertServerCommand("changelevel \"%s\"", map); - ServerExecute(); - - LogMessage("Nextmap changed map to \"%s\"", map); - - return Plugin_Stop; -} - FindAndSetNextMap() { if (ReadMapList(g_MapList, @@ -291,5 +212,5 @@ FindAndSetNextMap() g_MapPos = 0; GetArrayString(g_MapList, g_MapPos, mapName, sizeof(mapName)); - SetConVarString(g_Cvar_Nextmap, mapName); + SetNextMap(mapName); } diff --git a/translations/nextmap.phrases.txt b/translations/nextmap.phrases.txt index e1a4ba97..794a215a 100644 --- a/translations/nextmap.phrases.txt +++ b/translations/nextmap.phrases.txt @@ -2,7 +2,12 @@ { "Next Map" { - #format "{1:s}" + "#format" "{1:s}" "en" "Next Map: {1}" } + "Changed Next Map" + { + "#format" "{1:s}" + "en" "Changed nextmap to \"{1}\"." + } }