AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
gm_commandscript Class Reference
Inheritance diagram for gm_commandscript:
CommandScript ScriptObject

Public Member Functions

 gm_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleGMChatCommand (ChatHandler *handler, Optional< bool > enableArg)
 
static bool HandleGMFlyCommand (ChatHandler *handler, Optional< bool > enable)
 
static bool HandleGMListIngameCommand (ChatHandler *handler)
 
static bool HandleGMListFullCommand (ChatHandler *handler)
 Display the list of GMs.
 
static bool HandleGMVisibleCommand (ChatHandler *handler, Optional< bool > visibleArg)
 
static bool HandleGMOnCommand (ChatHandler *handler)
 
static bool HandleGMOffCommand (ChatHandler *handler)
 
static bool HandleGMSpectatorCommand (ChatHandler *handler, Optional< bool > enable)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ gm_commandscript()

gm_commandscript::gm_commandscript ( )
inline
35: CommandScript("gm_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable gm_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

38 {
39 static ChatCommandTable gmCommandTable =
40 {
41 { "chat", HandleGMChatCommand, SEC_GAMEMASTER, Console::No },
42 { "fly", HandleGMFlyCommand, SEC_GAMEMASTER, Console::No },
43 { "ingame", HandleGMListIngameCommand, SEC_PLAYER, Console::Yes },
44 { "list", HandleGMListFullCommand, SEC_ADMINISTRATOR, Console::Yes },
45 { "visible", HandleGMVisibleCommand, SEC_GAMEMASTER, Console::No },
46 { "on", HandleGMOnCommand, SEC_MODERATOR, Console::No },
47 { "off", HandleGMOffCommand, SEC_MODERATOR, Console::No },
48 { "spectator", HandleGMSpectatorCommand, SEC_GAMEMASTER, Console::No },
49 };
50 static ChatCommandTable commandTable =
51 {
52 { "gm", gmCommandTable }
53 };
54 return commandTable;
55 }
@ SEC_PLAYER
Definition Common.h:57
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleGMChatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_gm.cpp:58
static bool HandleGMFlyCommand(ChatHandler *handler, Optional< bool > enable)
Definition cs_gm.cpp:89
static bool HandleGMOffCommand(ChatHandler *handler)
Definition cs_gm.cpp:233
static bool HandleGMVisibleCommand(ChatHandler *handler, Optional< bool > visibleArg)
Definition cs_gm.cpp:193
static bool HandleGMSpectatorCommand(ChatHandler *handler, Optional< bool > enable)
Definition cs_gm.cpp:241
static bool HandleGMListIngameCommand(ChatHandler *handler)
Definition cs_gm.cpp:117
static bool HandleGMListFullCommand(ChatHandler *handler)
Display the list of GMs.
Definition cs_gm.cpp:158
static bool HandleGMOnCommand(ChatHandler *handler)
Definition cs_gm.cpp:225
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleGMChatCommand(), HandleGMFlyCommand(), HandleGMListFullCommand(), HandleGMListIngameCommand(), HandleGMOffCommand(), HandleGMOnCommand(), HandleGMSpectatorCommand(), HandleGMVisibleCommand(), SEC_ADMINISTRATOR, SEC_GAMEMASTER, SEC_MODERATOR, and SEC_PLAYER.

◆ HandleGMChatCommand()

static bool gm_commandscript::HandleGMChatCommand ( ChatHandler handler,
Optional< bool >  enableArg 
)
inlinestatic
59 {
60 if (WorldSession* session = handler->GetSession())
61 {
62 if (!enableArg)
63 {
64 if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->isGMChat())
66 else
68 return true;
69 }
70
71 if (*enableArg)
72 {
73 session->GetPlayer()->SetGMChat(true);
75 return true;
76 }
77 else
78 {
79 session->GetPlayer()->SetGMChat(false);
81 return true;
82 }
83 }
84
86 return false;
87 }
@ LANG_USE_BOL
Definition Language.h:304
@ LANG_GM_CHAT_ON
Definition Language.h:377
@ LANG_GM_CHAT_OFF
Definition Language.h:378
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
void SendNotification(std::string_view str)
Definition Chat.cpp:105
Player session in the World.
Definition WorldSession.h:330
bool IsPlayerAccount(uint32 gmlevel)
Definition AccountMgr.cpp:311

References ChatHandler::GetSession(), AccountMgr::IsPlayerAccount(), LANG_GM_CHAT_OFF, LANG_GM_CHAT_ON, LANG_USE_BOL, ChatHandler::SendErrorMessage(), and ChatHandler::SendNotification().

Referenced by GetCommands().

◆ HandleGMFlyCommand()

static bool gm_commandscript::HandleGMFlyCommand ( ChatHandler handler,
Optional< bool >  enable 
)
inlinestatic
90 {
91 Player* target = handler->getSelectedPlayer();
92 if (!target)
93 target = handler->GetSession()->GetPlayer();
94
95 WorldPacket data(12);
96
97 bool canFly = false;
98 if (enable.has_value())
99 {
100 data.SetOpcode(*enable ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY);
101 canFly = *enable;
102 }
103 else
104 {
105 canFly = handler->GetSession()->GetPlayer()->CanFly();
106 data.SetOpcode(canFly ? SMSG_MOVE_UNSET_CAN_FLY : SMSG_MOVE_SET_CAN_FLY);
107 canFly = !canFly;
108 }
109
110 data << target->GetPackGUID();
111 data << uint32(0); // unknown
112 target->SendMessageToSet(&data, true);
113 handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
114 return true;
115 }
std::uint32_t uint32
Definition Define.h:107
@ LANG_COMMAND_FLYMODE_STATUS
Definition Language.h:513
virtual std::string GetNameLink() const
Definition Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
Player * getSelectedPlayer() const
Definition Chat.cpp:374
PackedGuid const & GetPackGUID() const
Definition Object.h:115
Definition Player.h:1083
bool CanFly() const override
Definition Player.h:2583
void SendMessageToSet(WorldPacket const *data, bool self) const override
Definition Player.cpp:5676
Definition WorldPacket.h:26
Player * GetPlayer() const
Definition WorldSession.h:376
@ SMSG_MOVE_SET_CAN_FLY
Definition Opcodes.h:865
@ SMSG_MOVE_UNSET_CAN_FLY
Definition Opcodes.h:866

References Player::CanFly(), ChatHandler::GetNameLink(), Object::GetPackGUID(), WorldSession::GetPlayer(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), LANG_COMMAND_FLYMODE_STATUS, ChatHandler::PSendSysMessage(), Player::SendMessageToSet(), WorldPacket::SetOpcode(), SMSG_MOVE_SET_CAN_FLY, and SMSG_MOVE_UNSET_CAN_FLY.

Referenced by GetCommands().

◆ HandleGMListFullCommand()

static bool gm_commandscript::HandleGMListFullCommand ( ChatHandler handler)
inlinestatic

Display the list of GMs.

  • Get the accounts with GM Level >0
  • Cycle through them. Display username and GM level
159 {
162 stmt->SetData(0, uint8(SEC_MODERATOR));
163 stmt->SetData(1, int32(realm.Id.Realm));
164 PreparedQueryResult result = LoginDatabase.Query(stmt);
165
166 if (result)
167 {
168 handler->SendSysMessage(LANG_GMLIST);
169 handler->SendSysMessage("========================");
171 do
172 {
173 Field* fields = result->Fetch();
174 std::string name = fields[0].Get<std::string>();
175 uint8 security = fields[1].Get<uint8>();
176 uint8 max = (16 - name.length()) / 2;
177 uint8 max2 = max;
178 if ((max + max2 + name.length()) == 16)
179 max2 = max - 1;
180 if (handler->GetSession())
181 handler->PSendSysMessage("| {} GMLevel {}", name, security);
182 else
183 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
184 } while (result->NextRow());
185 handler->SendSysMessage("========================");
186 }
187 else
189 return true;
190 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
std::int32_t int32
Definition Define.h:103
std::uint8_t uint8
Definition Define.h:109
@ LANG_GMLIST
Definition Language.h:661
@ LANG_GMLIST_EMPTY
Definition Language.h:663
@ LOGIN_SEL_GM_ACCOUNTS
Definition LoginDatabase.h:90
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
Realm realm
Definition World.cpp:111
uint32 Realm
Definition Realm.h:43
RealmHandle Id
Definition Realm.h:69

References Field::Get(), ChatHandler::GetSession(), Realm::Id, LANG_GMLIST, LANG_GMLIST_EMPTY, LOGIN_SEL_GM_ACCOUNTS, LoginDatabase, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, SEC_MODERATOR, ChatHandler::SendSysMessage(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleGMListIngameCommand()

static bool gm_commandscript::HandleGMListIngameCommand ( ChatHandler handler)
inlinestatic
118 {
119 bool first = true;
120 bool footer = false;
121
122 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
123 for (auto const& [playerGuid, player] : ObjectAccessor::GetPlayers())
124 {
125 AccountTypes playerSec = player->GetSession()->GetSecurity();
126 if ((player->IsGameMaster() ||
127 (!AccountMgr::IsPlayerAccount(playerSec) && playerSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
128 (!handler->GetSession() || player->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
129 {
130 if (first)
131 {
132 first = false;
133 footer = true;
135 handler->SendSysMessage("========================");
136 }
137 std::string const& name = player->GetName();
138 uint8 size = uint8(name.size());
139 uint8 security = playerSec;
140 uint8 max = ((16 - size) / 2);
141 uint8 max2 = max;
142 if ((max + max2 + size) == 16)
143 max2 = max - 1;
144 if (handler->GetSession())
145 handler->PSendSysMessage("| {} GMLevel {}", name, security);
146 else
147 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
148 }
149 }
150 if (footer)
151 handler->SendSysMessage("========================");
152 if (first)
154 return true;
155 }
AccountTypes
Definition Common.h:56
@ LANG_GMS_ON_SRV
Definition Language.h:48
@ LANG_GMS_NOT_LOGGED
Definition Language.h:49
@ CONFIG_GM_LEVEL_IN_GM_LIST
Definition WorldConfig.h:209
Definition ObjectAccessor.h:41
#define sWorld
Definition World.h:320
Definition ObjectAccessor.h:61
HashMapHolder< Player >::MapType const & GetPlayers()
Definition ObjectAccessor.cpp:75

References CONFIG_GM_LEVEL_IN_GM_LIST, WorldSession::GetPlayer(), ObjectAccessor::GetPlayers(), ChatHandler::GetSession(), AccountMgr::IsPlayerAccount(), LANG_GMS_NOT_LOGGED, LANG_GMS_ON_SRV, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and sWorld.

Referenced by GetCommands().

◆ HandleGMOffCommand()

static bool gm_commandscript::HandleGMOffCommand ( ChatHandler handler)
inlinestatic
234 {
235 handler->GetPlayer()->SetGameMaster(false);
238 return true;
239 }
@ LANG_GM_OFF
Definition Language.h:376
Player * GetPlayer() const
Definition Chat.cpp:36
void SetGameMaster(bool on)
Definition Player.cpp:2212
void UpdateTriggerVisibility()
Definition PlayerUpdates.cpp:1746

References ChatHandler::GetPlayer(), LANG_GM_OFF, ChatHandler::SendNotification(), Player::SetGameMaster(), and Player::UpdateTriggerVisibility().

Referenced by GetCommands().

◆ HandleGMOnCommand()

static bool gm_commandscript::HandleGMOnCommand ( ChatHandler handler)
inlinestatic
226 {
227 handler->GetPlayer()->SetGameMaster(true);
230 return true;
231 }
@ LANG_GM_ON
Definition Language.h:375

References ChatHandler::GetPlayer(), LANG_GM_ON, ChatHandler::SendNotification(), Player::SetGameMaster(), and Player::UpdateTriggerVisibility().

Referenced by GetCommands().

◆ HandleGMSpectatorCommand()

static bool gm_commandscript::HandleGMSpectatorCommand ( ChatHandler handler,
Optional< bool >  enable 
)
inlinestatic
242 {
243 Player* player = handler->GetSession()->GetPlayer();
244
245 if (enable.has_value())
246 player->SetGMSpectator(*enable);
247 else
248 player->SetGMSpectator(!player->IsGMSpectator());
250
251 return true;
252 }
@ LANG_GM_SPECTATOR_OFF
Definition Language.h:1175
@ LANG_GM_SPECTATOR_ON
Definition Language.h:1174
void SetGMSpectator(bool on)
Definition Player.h:1182
bool IsGMSpectator() const
Definition Player.h:1181

References WorldSession::GetPlayer(), ChatHandler::GetSession(), Player::IsGMSpectator(), LANG_GM_SPECTATOR_OFF, LANG_GM_SPECTATOR_ON, ChatHandler::SendNotification(), and Player::SetGMSpectator().

Referenced by GetCommands().

◆ HandleGMVisibleCommand()

static bool gm_commandscript::HandleGMVisibleCommand ( ChatHandler handler,
Optional< bool >  visibleArg 
)
inlinestatic
194 {
195 Player* _player = handler->GetSession()->GetPlayer();
196
197 if (!visibleArg)
198 {
200 return true;
201 }
202
203 const uint32 VISUAL_AURA = 37800;
204
205 if (*visibleArg)
206 {
207 if (_player->HasAura(VISUAL_AURA))
208 _player->RemoveAurasDueToSpell(VISUAL_AURA);
209
210 _player->SetGMVisible(true);
211 _player->UpdateObjectVisibility();
213 }
214 else
215 {
216 _player->AddAura(VISUAL_AURA, _player);
217 _player->SetGMVisible(false);
218 _player->UpdateObjectVisibility();
220 }
221
222 return true;
223 }
@ LANG_INVISIBLE_INVISIBLE
Definition Language.h:637
@ LANG_YOU_ARE
Definition Language.h:72
@ LANG_INVISIBLE
Definition Language.h:74
@ LANG_INVISIBLE_VISIBLE
Definition Language.h:638
@ LANG_VISIBLE
Definition Language.h:73
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
bool isGMVisible() const
Definition Player.h:1186
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition PlayerUpdates.cpp:1617
void SetGMVisible(bool on)
Definition Player.cpp:2281
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:18919
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5755
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4943
AC_GAME_API std::string GetAcoreString(ChatHandler const *handler, AcoreStrings which)
Definition ChatCommandHelpers.cpp:27

References Unit::AddAura(), ChatHandler::GetAcoreString(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::HasAura(), Player::isGMVisible(), LANG_INVISIBLE, LANG_INVISIBLE_INVISIBLE, LANG_INVISIBLE_VISIBLE, LANG_VISIBLE, LANG_YOU_ARE, ChatHandler::PSendSysMessage(), Unit::RemoveAurasDueToSpell(), ChatHandler::SendNotification(), Player::SetGMVisible(), and Player::UpdateObjectVisibility().

Referenced by GetCommands().


The documentation for this class was generated from the following file: