diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index 833dc0e0..709bb12e 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -140,6 +140,16 @@ static cell_t GetGameDescription(IPluginContext *pContext, const cell_t *params) return numBytes; } +static cell_t GetGameFolderName(IPluginContext *pContext, const cell_t *params) +{ + const char *name = g_SourceMod.GetModFolderName(); + size_t numBytes; + + pContext->StringToLocalUTF8(params[1], params[2], name, &numBytes); + + return numBytes; +} + static cell_t GetCurrentMap(IPluginContext *pContext, const cell_t *params) { size_t bytes; @@ -277,6 +287,7 @@ REGISTER_NATIVES(halflifeNatives) {"GetCurrentMap", GetCurrentMap}, {"GetEngineTime", GetEngineTime}, {"GetGameDescription", GetGameDescription}, + {"GetGameFolderName", GetGameFolderName}, {"GetGameTime", GetGameTime}, {"GetRandomFloat", GetRandomFloat}, {"GetRandomInt", GetRandomInt}, diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 8568fd6d..cedd2aab 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -314,6 +314,16 @@ native Float:GetGameTime(); */ native GetGameDescription(String:buffer[], maxlength, bool:original=false); +/** + * Returns the name of the game's directory. + * + * @param buffer Buffer to store the directory name. + * @param maxlength Maximum size of the buffer. + * + * return Number of bytes written to the buffer (UTF-8 safe). + */ +native GetGameFolderName(String:buffer[], maxlength); + /** * Returns the current map name. *