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
36: CommandScript("gm_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable gm_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

39 {
40 static ChatCommandTable gmCommandTable =
41 {
47 { "on", HandleGMOnCommand, rbac::RBAC_PERM_COMMAND_GM, Console::No },
48 { "off", HandleGMOffCommand, rbac::RBAC_PERM_COMMAND_GM, Console::No },
49 { "spectator", HandleGMSpectatorCommand, rbac::RBAC_PERM_COMMAND_GM, Console::No },
50 };
51 static ChatCommandTable commandTable =
52 {
53 { "gm", gmCommandTable }
54 };
55 return commandTable;
56 }
static bool HandleGMChatCommand(ChatHandler *handler, Optional< bool > enableArg)
Definition cs_gm.cpp:59
static bool HandleGMFlyCommand(ChatHandler *handler, Optional< bool > enable)
Definition cs_gm.cpp:90
static bool HandleGMOffCommand(ChatHandler *handler)
Definition cs_gm.cpp:228
static bool HandleGMVisibleCommand(ChatHandler *handler, Optional< bool > visibleArg)
Definition cs_gm.cpp:188
static bool HandleGMSpectatorCommand(ChatHandler *handler, Optional< bool > enable)
Definition cs_gm.cpp:236
static bool HandleGMListIngameCommand(ChatHandler *handler)
Definition cs_gm.cpp:112
static bool HandleGMListFullCommand(ChatHandler *handler)
Display the list of GMs.
Definition cs_gm.cpp:153
static bool HandleGMOnCommand(ChatHandler *handler)
Definition cs_gm.cpp:220
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_GM
Definition RBAC.h:219
@ RBAC_PERM_COMMAND_GM_INGAME
Definition RBAC.h:222
@ RBAC_PERM_COMMAND_GM_CHAT
Definition RBAC.h:220
@ RBAC_PERM_COMMAND_GM_VISIBLE
Definition RBAC.h:224
@ RBAC_PERM_COMMAND_GM_LIST
Definition RBAC.h:223
@ RBAC_PERM_COMMAND_GM_FLY
Definition RBAC.h:221

References HandleGMChatCommand(), HandleGMFlyCommand(), HandleGMListFullCommand(), HandleGMListIngameCommand(), HandleGMOffCommand(), HandleGMOnCommand(), HandleGMSpectatorCommand(), HandleGMVisibleCommand(), rbac::RBAC_PERM_COMMAND_GM, rbac::RBAC_PERM_COMMAND_GM_CHAT, rbac::RBAC_PERM_COMMAND_GM_FLY, rbac::RBAC_PERM_COMMAND_GM_INGAME, rbac::RBAC_PERM_COMMAND_GM_LIST, and rbac::RBAC_PERM_COMMAND_GM_VISIBLE.

◆ HandleGMChatCommand()

static bool gm_commandscript::HandleGMChatCommand ( ChatHandler handler,
Optional< bool >  enableArg 
)
inlinestatic
60 {
61 if (WorldSession* session = handler->GetSession())
62 {
63 if (!enableArg)
64 {
65 if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->isGMChat())
67 else
69 return true;
70 }
71
72 if (*enableArg)
73 {
74 session->GetPlayer()->SetGMChat(true);
76 return true;
77 }
78 else
79 {
80 session->GetPlayer()->SetGMChat(false);
82 return true;
83 }
84 }
85
87 return false;
88 }
@ LANG_USE_BOL
Definition Language.h:311
@ LANG_GM_CHAT_ON
Definition Language.h:384
@ LANG_GM_CHAT_OFF
Definition Language.h:385
static bool IsPlayerAccount(uint32 gmlevel)
Definition AccountMgr.cpp:324
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
void SendNotification(std::string_view str)
Definition Chat.cpp:113
Player session in the World.
Definition WorldSession.h:384

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
91 {
92 Player* target = handler->getSelectedPlayer();
93 if (!target)
94 target = handler->GetSession()->GetPlayer();
95
96 bool canFly = false;
97 if (enable.has_value())
98 {
99 canFly = *enable;
100 target->SetCanFly(canFly);
101 }
102 else
103 {
104 canFly = !handler->GetSession()->GetPlayer()->CanFly();
105 target->SetCanFly(canFly);
106 }
107
108 handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
109 return true;
110 }
@ LANG_COMMAND_FLYMODE_STATUS
Definition Language.h:520
virtual std::string GetNameLink() const
Definition Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
Player * getSelectedPlayer() const
Definition Chat.cpp:382
Definition Player.h:1084
bool CanFly() const override
Definition Player.h:2605
void SetCanFly(bool enable)
Add the movement flag: MOVEMENTFLAGCAN_FLY. Generaly only use by players, allowing them to fly by pre...
Definition Unit.cpp:16557
Player * GetPlayer() const
Definition WorldSession.h:454

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
154 {
157 stmt->SetData(0, uint8(SEC_MODERATOR));
158 stmt->SetData(1, int32(realm.Id.Realm));
159 PreparedQueryResult result = LoginDatabase.Query(stmt);
160
161 if (result)
162 {
163 handler->SendSysMessage(LANG_GMLIST);
164 handler->SendSysMessage("========================");
166 do
167 {
168 Field* fields = result->Fetch();
169 std::string name = fields[0].Get<std::string>();
170 uint8 security = fields[1].Get<uint8>();
171 uint8 max = (16 - name.length()) / 2;
172 uint8 max2 = max;
173 if ((max + max2 + name.length()) == 16)
174 max2 = max - 1;
175 if (handler->GetSession())
176 handler->PSendSysMessage("| {} GMLevel {}", name, security);
177 else
178 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
179 } while (result->NextRow());
180 handler->SendSysMessage("========================");
181 }
182 else
184 return true;
185 }
@ SEC_MODERATOR
Definition Common.h:58
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:668
@ LANG_GMLIST_EMPTY
Definition Language.h:670
@ LOGIN_SEL_GM_ACCOUNTS
Definition LoginDatabase.h:92
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
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
113 {
114 bool first = true;
115 bool footer = false;
116
117 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
118 for (auto const& [playerGuid, player] : ObjectAccessor::GetPlayers())
119 {
120 AccountTypes playerSec = player->GetSession()->GetSecurity();
121 if ((player->IsGameMaster() ||
122 (!AccountMgr::IsPlayerAccount(playerSec) && playerSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
123 (!handler->GetSession() || player->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
124 {
125 if (first)
126 {
127 first = false;
128 footer = true;
130 handler->SendSysMessage("========================");
131 }
132 std::string const& name = player->GetName();
133 uint8 size = uint8(name.size());
134 uint8 security = playerSec;
135 uint8 max = ((16 - size) / 2);
136 uint8 max2 = max;
137 if ((max + max2 + size) == 16)
138 max2 = max - 1;
139 if (handler->GetSession())
140 handler->PSendSysMessage("| {} GMLevel {}", name, security);
141 else
142 handler->PSendSysMessage("|{}{}{}| {} |", max, " ", name, max2, " ", security);
143 }
144 }
145 if (footer)
146 handler->SendSysMessage("========================");
147 if (first)
149 return true;
150 }
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:317
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
229 {
230 handler->GetPlayer()->SetGameMaster(false);
233 return true;
234 }
@ LANG_GM_OFF
Definition Language.h:383
Player * GetPlayer() const
Definition Chat.cpp:37
void SetGameMaster(bool on)
Definition Player.cpp:2197
void UpdateTriggerVisibility()
Definition PlayerUpdates.cpp:1741

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

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

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