diff --git a/amxmodx/CPlugin.cpp b/amxmodx/CPlugin.cpp index eee6d6e6..93058a7d 100755 --- a/amxmodx/CPlugin.cpp +++ b/amxmodx/CPlugin.cpp @@ -15,6 +15,7 @@ #include "debugger.h" #include "libraries.h" #include +#include "engine_strucs.h" extern const char *no_function; @@ -154,6 +155,11 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn) *get_amxaddr(plugin->getAMX(), addr) = gpGlobals->maxClients; } + if (amx_FindPubVar(plugin->getAMX(), "MapName", &addr) != AMX_ERR_NOTFOUND) + { + set_amxstring(plugin->getAMX(), addr, STRING(gpGlobals->mapname), MAX_MAPNAME_LENGTH - 1); + } + if (amx_FindPubVar(plugin->getAMX(), "NULL_STRING", &addr) != AMX_ERR_NOTFOUND) { plugin->m_pNullStringOfs = get_amxaddr(plugin->getAMX(), addr); diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index b041c5c9..995e1318 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -29,7 +29,7 @@ static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params) char* sName = get_amxstring(amx, params[1], 0, len); cell ptr; - if (!strcmp(sName, "MaxClients") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR")) + if (!strcmp(sName, "MaxClients") || !strcmp(sName, "MapName") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR")) { return -1; } diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index fef8543e..2944fcdc 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -29,6 +29,11 @@ */ #define MAX_STRING_LENGTH 16384 +/** + * The maximum buffer size required to store a map's name. + */ +#define MAX_MAPNAME_LENGTH 64 + /** * Defines and constants related to the maximum number of clients. * @@ -44,6 +49,11 @@ */ public stock const MaxClients; +/** + * Current map name + */ +public stock const MapName[MAX_MAPNAME_LENGTH]; + /** * Pass this into certain functions to act as a C++ NULL */ diff --git a/public/engine_strucs.h b/public/engine_strucs.h index bb3bf806..f339ed8f 100644 --- a/public/engine_strucs.h +++ b/public/engine_strucs.h @@ -22,6 +22,7 @@ #define MAX_LIGHTSTYLES 64 #define MAX_PACKET_ENTITIES 256 #define MAX_PATH_LENGTH 260 +#define MAX_MAPNAME_LENGTH 64 #define MAX_LATENT 32 #define FRAGMENT_SIZE 1400