mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
feat: add player:RunCommand (#176)
This commit is contained in:
@@ -705,6 +705,8 @@ ElunaRegister<Player> PlayerMethods[] =
|
|||||||
{ "ModifyMoney", &LuaPlayer::ModifyMoney },
|
{ "ModifyMoney", &LuaPlayer::ModifyMoney },
|
||||||
{ "LearnSpell", &LuaPlayer::LearnSpell },
|
{ "LearnSpell", &LuaPlayer::LearnSpell },
|
||||||
{ "LearnTalent", &LuaPlayer::LearnTalent },
|
{ "LearnTalent", &LuaPlayer::LearnTalent },
|
||||||
|
|
||||||
|
{ "RunCommand", &LuaPlayer::RunCommand },
|
||||||
{ "SetGlyph", &LuaPlayer::SetGlyph },
|
{ "SetGlyph", &LuaPlayer::SetGlyph },
|
||||||
{ "GetGlyph", &LuaPlayer::GetGlyph },
|
{ "GetGlyph", &LuaPlayer::GetGlyph },
|
||||||
#if !defined(CLASSIC)
|
#if !defined(CLASSIC)
|
||||||
|
|||||||
@@ -3935,6 +3935,25 @@ namespace LuaPlayer
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Run a chat command as if the player typed it into the chat
|
||||||
|
*
|
||||||
|
* @param string command: text to display in chat or console
|
||||||
|
*/
|
||||||
|
int RunCommand(lua_State* L, Player* player)
|
||||||
|
{
|
||||||
|
auto command = Eluna::CHECKVAL<std::string>(L, 2);
|
||||||
|
|
||||||
|
// In _ParseCommands which is used below no leading . or ! is allowed for the command string.
|
||||||
|
if (command[0] == '.' || command[0] == '!') {
|
||||||
|
command = command.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto handler = ChatHandler(player->GetSession());
|
||||||
|
handler._ParseCommands(command);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a glyph specified by `glyphId` to the [Player]'s current talent specialization into the slot with the index `slotIndex`
|
* Adds a glyph specified by `glyphId` to the [Player]'s current talent specialization into the slot with the index `slotIndex`
|
||||||
|
|||||||
Reference in New Issue
Block a user