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:227
static bool HandleGMVisibleCommand(ChatHandler *handler, Optional< bool > visibleArg)
Definition cs_gm.cpp:187
static bool HandleGMSpectatorCommand(ChatHandler *handler, Optional< bool > enable)
Definition cs_gm.cpp:235
static bool HandleGMListIngameCommand(ChatHandler *handler)
Definition cs_gm.cpp:111
static bool HandleGMListFullCommand(ChatHandler *handler)
Display the list of GMs.
Definition cs_gm.cpp:152
static bool HandleGMOnCommand(ChatHandler *handler)
Definition cs_gm.cpp:219
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:308
@ LANG_GM_CHAT_ON
Definition Language.h:381
@ LANG_GM_CHAT_OFF
Definition Language.h:382
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:369
bool IsPlayerAccount(uint32 gmlevel)
Definition AccountMgr.cpp:312

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 bool canFly = false;
96 if (enable.has_value())
97 {
98 canFly = *enable;
99 target->SetCanFly(canFly);
100 }
101 else
102 {
103 canFly = !handler->GetSession()->GetPlayer()->CanFly();
104 target->SetCanFly(canFly);
105 }
106
107 handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
108 return true;
109 }
@ LANG_COMMAND_FLYMODE_STATUS
Definition Language.h:517
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
Definition Player.h:1071
bool CanFly() const override
Definition Player.h:2569
void SetCanFly(bool enable)
Add the movement flag: MOVEMENTFLAGCAN_FLY. Generaly only use by players, allowing them to fly by pre...
Definition Unit.cpp:20397
Player * GetPlayer() const
Definition WorldSession.h:424

References Player::CanFly(), ChatHandler::GetNameLink(), WorldSession::GetPlayer(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSession(), LANG_COMMAND_FLYMODE_STATUS, ChatHandler::PSendSysMessage(), and Unit::SetCanFly().

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
153 {
156 stmt->SetData(0, uint8(SEC_MODERATOR));
157 stmt->SetData(1, int32(realm.Id.Realm));
158 PreparedQueryResult result = LoginDatabase.Query(stmt);
159
160 if (result)
161 {
162 handler->SendSysMessage(LANG_GMLIST);
163 handler->SendSysMessage("========================");
165 do
166 {
167 Field* fields = result->Fetch();
168 std::string name = fields[0].Get<std::string>();
169 uint8 security = fields[1].Get<uint8>();
170 uint8 max = (16 - name.length()) / 2;
171 uint8 max2 = max;
172 if ((max + max2 + name.length()) == 16)
173 max2 = max - 1;
174 if (handler->GetSession())
175 handler->PSendSysMessage("| {} GMLevel {}", name, security);
176 else
177 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
178 } while (result->NextRow());
179 handler->SendSysMessage("========================");
180 }
181 else
183 return true;
184 }
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:665
@ LANG_GMLIST_EMPTY
Definition Language.h:667
@ LOGIN_SEL_GM_ACCOUNTS
Definition LoginDatabase.h:92
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
112 {
113 bool first = true;
114 bool footer = false;
115
116 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
117 for (auto const& [playerGuid, player] : ObjectAccessor::GetPlayers())
118 {
119 AccountTypes playerSec = player->GetSession()->GetSecurity();
120 if ((player->IsGameMaster() ||
121 (!AccountMgr::IsPlayerAccount(playerSec) && playerSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
122 (!handler->GetSession() || player->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
123 {
124 if (first)
125 {
126 first = false;
127 footer = true;
129 handler->SendSysMessage("========================");
130 }
131 std::string const& name = player->GetName();
132 uint8 size = uint8(name.size());
133 uint8 security = playerSec;
134 uint8 max = ((16 - size) / 2);
135 uint8 max2 = max;
136 if ((max + max2 + size) == 16)
137 max2 = max - 1;
138 if (handler->GetSession())
139 handler->PSendSysMessage("| {} GMLevel {}", name, security);
140 else
141 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
142 }
143 }
144 if (footer)
145 handler->SendSysMessage("========================");
146 if (first)
148 return true;
149 }
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:211
Definition ObjectAccessor.h:41
#define sWorld
Definition World.h:316
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
228 {
229 handler->GetPlayer()->SetGameMaster(false);
232 return true;
233 }
@ LANG_GM_OFF
Definition Language.h:380
Player * GetPlayer() const
Definition Chat.cpp:36
void SetGameMaster(bool on)
Definition Player.cpp:2204
void UpdateTriggerVisibility()
Definition PlayerUpdates.cpp:1732

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
220 {
221 handler->GetPlayer()->SetGameMaster(true);
224 return true;
225 }
@ LANG_GM_ON
Definition Language.h:379

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
236 {
237 Player* player = handler->GetSession()->GetPlayer();
238
239 if (enable.has_value())
240 player->SetGMSpectator(*enable);
241 else
242 player->SetGMSpectator(!player->IsGMSpectator());
244
245 return true;
246 }
@ LANG_GM_SPECTATOR_OFF
Definition Language.h:1180
@ LANG_GM_SPECTATOR_ON
Definition Language.h:1179
void SetGMSpectator(bool on)
Definition Player.h:1166
bool IsGMSpectator() const
Definition Player.h:1165

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
188 {
189 Player* _player = handler->GetSession()->GetPlayer();
190
191 if (!visibleArg)
192 {
194 return true;
195 }
196
197 const uint32 VISUAL_AURA = 37800;
198
199 if (*visibleArg)
200 {
201 if (_player->HasAura(VISUAL_AURA))
202 _player->RemoveAurasDueToSpell(VISUAL_AURA);
203
204 _player->SetGMVisible(true);
205 _player->UpdateObjectVisibility();
207 }
208 else
209 {
210 _player->AddAura(VISUAL_AURA, _player);
211 _player->SetGMVisible(false);
212 _player->UpdateObjectVisibility();
214 }
215
216 return true;
217 }
std::uint32_t uint32
Definition Define.h:107
@ LANG_INVISIBLE_INVISIBLE
Definition Language.h:641
@ LANG_YOU_ARE
Definition Language.h:72
@ LANG_INVISIBLE
Definition Language.h:74
@ LANG_INVISIBLE_VISIBLE
Definition Language.h:642
@ LANG_VISIBLE
Definition Language.h:73
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
bool isGMVisible() const
Definition Player.h:1170
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition PlayerUpdates.cpp:1604
void SetGMVisible(bool on)
Definition Player.cpp:2273
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:18894
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5789
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4977
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: