diff --git a/config/docs.cfg b/config/docs.cfg
index 1910bc85..4b3fffde 100644
--- a/config/docs.cfg
+++ b/config/docs.cfg
@@ -339,6 +339,7 @@ docremark [The servers are written to the config/servers.cfg file. This menu can
docident [version] [Gets an integer representing the game version. READ ONLY];
docremark [As example, version 1.0 is represented as value 1000.];
docident [writecfg] [writes current configuration to config/saved.cfg - automatic on quit];
+docident [onNewMap] [If this alias exists, it will be automatically executed when you start a new map.];
docsection [Gameplay]
docident [add2alias] [This will append the passed 2nd argument to any existing content of the alias named in the 1st argument. Several popular aliases have predefined shortcuts using this scriptalias: addOnQuit, addOnLoadOnce, addOnLoadAlways. Check config/scripts.cfg for possible omissions in that list.];
docexample [foo = "one" add2alias foo two echo foo] [Output: one two];
diff --git a/docs/reference.xml b/docs/reference.xml
index 142360be..211fcaca 100644
--- a/docs/reference.xml
+++ b/docs/reference.xml
@@ -3526,6 +3526,10 @@ Output:
If disabled, an updated editing binds system is used, see the comments in "/config/resetbinds.cfg" for more info.
+
+
+ If this alias exists, it will be automatically executed when you start a new map.
+
diff --git a/source/src/world.cpp b/source/src/world.cpp
index b27f0361..8d64396e 100644
--- a/source/src/world.cpp
+++ b/source/src/world.cpp
@@ -496,7 +496,13 @@ bool empty_world(int factor, bool force) // main empty world creation routine
void mapenlarge() { if(empty_world(-1, false)) addmsg(SV_NEWMAP, "ri", -1); }
void mapshrink() { if(empty_world(-2, false)) addmsg(SV_NEWMAP, "ri", -2); }
-void newmap(int i) { if(empty_world(i, false)) addmsg(SV_NEWMAP, "ri", max(i, 0)); }
+void newmap(int i) {
+ if(empty_world(i, false))
+ {
+ addmsg(SV_NEWMAP, "ri", max(i, 0));
+ if(identexists("onNewMap")) execute("onNewMap");
+ }
+}
COMMAND(mapenlarge, ARG_NONE);
COMMAND(mapshrink, ARG_NONE);