diff --git a/addons/sourcemod/plugins/optional/l4d2_map_transitions.smx b/addons/sourcemod/plugins/optional/l4d2_map_transitions.smx
index 215259701..ace7b1f52 100644
Binary files a/addons/sourcemod/plugins/optional/l4d2_map_transitions.smx and b/addons/sourcemod/plugins/optional/l4d2_map_transitions.smx differ
diff --git a/addons/sourcemod/scripting/include/l4d2_map_transitions.inc b/addons/sourcemod/scripting/include/l4d2_map_transitions.inc
new file mode 100644
index 000000000..e3b297e34
--- /dev/null
+++ b/addons/sourcemod/scripting/include/l4d2_map_transitions.inc
@@ -0,0 +1,72 @@
+/*
+ SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
+ SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
+ Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
+ Source is Copyright (C) Valve Corporation.
+ All trademarks are property of their respective owners.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ 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 .
+*/
+#if defined _l4d2_map_transitions_included_
+ #endinput
+#endif
+#define _l4d2_map_transitions_included_
+
+/**
+ * @brief Get the next map name for map transition
+ *
+ * @param buffer String to write map name, empty if no map transition set
+ * @param maxlength Max length of buffer
+ *
+ * @noreturn
+ */
+native void l4d2_map_transitions_GetNextMap(char[] buffer, int maxlength);
+
+/**
+ * @brief Called when the plugin is about to force change next map
+ *
+ * @param sNextMapName the next map name for map transition
+ *
+ * @return Plugin_Handled to block map changing, Plugin_Continue otherwise
+ */
+forward Action l4d2_map_transitions_OnChangeNextMap_Pre(const char[] sNextMapName);
+
+/**
+ * @brief Called when the plugin is about to force change next map
+ * @remarks This forward will not trigger if the relative pre-hook forward has been blocked with Plugin_Handled
+ *
+ * @param sNextMapName the next map name for map transition
+ *
+ * @noreturn
+ */
+forward void l4d2_map_transitions_OnChangeNextMap_Post(const char[] sNextMapName);
+
+
+public SharedPlugin __pl_l4d2_map_transitions =
+{
+ name = "l4d2_map_transitions",
+ file = "l4d2_map_transitions.smx",
+#if defined REQUIRE_PLUGIN
+ required = 1,
+#else
+ required = 0,
+#endif
+};
+
+#if !defined REQUIRE_PLUGIN
+public void __pl_l4d2_map_transitions_SetNTVOptional()
+{
+ MarkNativeAsOptional("l4d2_map_transitions_GetNextMap");
+}
+#endif
\ No newline at end of file
diff --git a/addons/sourcemod/scripting/l4d2_map_transitions.sp b/addons/sourcemod/scripting/l4d2_map_transitions.sp
index 370de345f..d097d60d8 100644
--- a/addons/sourcemod/scripting/l4d2_map_transitions.sp
+++ b/addons/sourcemod/scripting/l4d2_map_transitions.sp
@@ -11,6 +11,21 @@
#include
#include
+GlobalForward g_hFWD_ChangeNextMapPre;
+GlobalForward g_hFWD_ChangeNextMapPost;
+
+public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
+{
+ CreateNative("l4d2_map_transitions_GetNextMap", Native_GetNextMap);
+
+ g_hFWD_ChangeNextMapPre = new GlobalForward("l4d2_map_transitions_OnChangeNextMap_Pre", ET_Event, Param_String);
+ g_hFWD_ChangeNextMapPost = new GlobalForward("l4d2_map_transitions_OnChangeNextMap_Post", ET_Ignore, Param_String);
+
+ RegPluginLibrary("l4d2_map_transitions");
+
+ return APLRes_Success;
+}
+
#define DEBUG 0
#define MAP_NAME_MAX_LENGTH 64
@@ -115,6 +130,24 @@ Action OnRoundEnd_Post(Handle hTimer)
LogMessage("Map transitioned from: %s to: %s", sCurrentMapName, sNextMapName);
#endif
+ Action aResult = Plugin_Continue;
+ Call_StartForward(g_hFWD_ChangeNextMapPre);
+ Call_PushString(sNextMapName);
+ Call_Finish(aResult);
+
+ if( aResult == Plugin_Handled )
+ {
+ g_iPointsTeamA = 0;
+ g_iPointsTeamB = 0;
+ g_bHasTransitioned = false;
+
+ return Plugin_Stop;
+ }
+
+ Call_StartForward(g_hFWD_ChangeNextMapPost);
+ Call_PushString(sNextMapName);
+ Call_Finish();
+
CPrintToChatAll("{olive}[MT]{default} Starting transition from: {blue}%s{default} to: {blue}%s", sCurrentMapName, sNextMapName);
ForceChangeLevel(sNextMapName, "Map Transitions");
}
@@ -195,3 +228,32 @@ int GetCurrentMapLower(char[] buffer, int maxlength)
if (bytes) String_ToLower(buffer, maxlength);
return bytes;
}
+
+
+// Native------------
+
+// native void l4d2_map_transitions_GetNextMap(char[] buffer, int maxlength);
+int Native_GetNextMap(Handle plugin, int numParams)
+{
+ int maxlength = GetNativeCell(2);
+ if (maxlength <= 0)
+ return 0;
+
+ char[] buffer = new char[maxlength];
+
+ char sCurrentMapName[MAP_NAME_MAX_LENGTH], sNextMapName[MAP_NAME_MAX_LENGTH];
+ GetCurrentMapLower(sCurrentMapName, sizeof(sCurrentMapName));
+
+ //We have a map to transition to
+ if (g_hMapTransitionPair.GetString(sCurrentMapName, sNextMapName, sizeof(sNextMapName)))
+ {
+ FormatEx(buffer, maxlength, "%s", sNextMapName);
+ SetNativeString(1, buffer, maxlength);
+ }
+ else
+ {
+ FormatEx(buffer, maxlength, "");
+ }
+
+ return 0;
+}
\ No newline at end of file