add RunCommand()

This commit is contained in:
Axel Cocat
2021-06-21 15:59:44 +02:00
parent b62c606c9e
commit d533224895
3 changed files with 18 additions and 0 deletions

View File

@@ -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<const char*>(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.
*

View File

@@ -120,6 +120,7 @@ luaL_Reg GlobalMethods[] =
// Other
{ "ReloadEluna", &LuaGlobalFunctions::ReloadEluna },
{ "RunCommand", &LuaGlobalFunctions::RunCommand },
{ "SendWorldMessage", &LuaGlobalFunctions::SendWorldMessage },
{ "WorldDBQuery", &LuaGlobalFunctions::WorldDBQuery },
{ "WorldDBExecute", &LuaGlobalFunctions::WorldDBExecute },

View File

@@ -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)
{