diff --git a/GlobalMethods.h b/GlobalMethods.h index 4d32e30..44d9966 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -1210,6 +1210,22 @@ namespace LuaGlobalFunctions return 0; } + /** + * Runs a command. + * + * @param string command : the command to run + */ + int RunCommand(lua_State* L) + { + const char* command = Eluna::CHECKVAL(L, 1); +#if defined TRINITY || AZEROTHCORE + eWorld->QueueCliCommand(new CliCommandHolder(nullptr, command, nullptr, nullptr)); +#elif defined MANGOS + eWorld->QueueCliCommand(new CliCommandHolder(0, SEC_CONSOLE, nullptr, command, nullptr, nullptr)); +#endif + return 0; + } + /** * Sends a message to all [Player]s online. * diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 4bc3121..841a86c 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -120,6 +120,7 @@ luaL_Reg GlobalMethods[] = // Other { "ReloadEluna", &LuaGlobalFunctions::ReloadEluna }, + { "RunCommand", &LuaGlobalFunctions::RunCommand }, { "SendWorldMessage", &LuaGlobalFunctions::SendWorldMessage }, { "WorldDBQuery", &LuaGlobalFunctions::WorldDBQuery }, { "WorldDBExecute", &LuaGlobalFunctions::WorldDBExecute }, diff --git a/MapMethods.h b/MapMethods.h index 65016ba..e065cbf 100644 --- a/MapMethods.h +++ b/MapMethods.h @@ -206,6 +206,7 @@ namespace LuaMap * Returns a [WorldObject] by its GUID from the map if it is spawned. * * @param ObjectGuid guid + * @return WorldObject object */ int GetWorldObject(lua_State* L, Map* map) {