TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gm_commandscript Class Reference

Public Member Functions

 gm_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleGMChatCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMFlyCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMListIngameCommand (ChatHandler *handler, char const *)
 
static bool HandleGMListFullCommand (ChatHandler *handler, char const *)
 Display the list of GMs. More...
 
static bool HandleGMVisibleCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

gm_commandscript::gm_commandscript ( )
inline
37 : CommandScript("gm_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> gm_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

40  {
41  static std::vector<ChatCommand> gmCommandTable =
42  {
44  { "fly", rbac::RBAC_PERM_COMMAND_GM_FLY, false, &HandleGMFlyCommand, "" },
48  { "", rbac::RBAC_PERM_COMMAND_GM, false, &HandleGMCommand, "" },
49  };
50  static std::vector<ChatCommand> commandTable =
51  {
52  { "gm", rbac::RBAC_PERM_COMMAND_GM, false, NULL, "", gmCommandTable },
53  };
54  return commandTable;
55  }
static bool HandleGMFlyCommand(ChatHandler *handler, char const *args)
Definition: cs_gm.cpp:93
static bool HandleGMListFullCommand(ChatHandler *handler, char const *)
Display the list of GMs.
Definition: cs_gm.cpp:159
static bool HandleGMCommand(ChatHandler *handler, char const *args)
Definition: cs_gm.cpp:233
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:280
static bool HandleGMChatCommand(ChatHandler *handler, char const *args)
Definition: cs_gm.cpp:58
Definition: RBAC.h:278
Definition: RBAC.h:279
Definition: RBAC.h:282
Definition: RBAC.h:281
static bool HandleGMVisibleCommand(ChatHandler *handler, char const *args)
Definition: cs_gm.cpp:194
static bool HandleGMListIngameCommand(ChatHandler *handler, char const *)
Definition: cs_gm.cpp:116

+ Here is the call graph for this function:

static bool gm_commandscript::HandleGMChatCommand ( ChatHandler handler,
char const args 
)
inlinestatic
59  {
60  if (WorldSession* session = handler->GetSession())
61  {
62  if (!*args)
63  {
64  if (session->HasPermission(rbac::RBAC_PERM_CHAT_USE_STAFF_BADGE) && session->GetPlayer()->isGMChat())
65  session->SendNotification(LANG_GM_CHAT_ON);
66  else
67  session->SendNotification(LANG_GM_CHAT_OFF);
68  return true;
69  }
70 
71  std::string param = (char*)args;
72 
73  if (param == "on")
74  {
75  session->GetPlayer()->SetGMChat(true);
76  session->SendNotification(LANG_GM_CHAT_ON);
77  return true;
78  }
79 
80  if (param == "off")
81  {
82  session->GetPlayer()->SetGMChat(false);
83  session->SendNotification(LANG_GM_CHAT_OFF);
84  return true;
85  }
86  }
87 
88  handler->SendSysMessage(LANG_USE_BOL);
89  handler->SetSentErrorMessage(true);
90  return false;
91  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:362
Definition: Language.h:363
Definition: Language.h:290
WorldSession * GetSession()
Definition: Chat.h:59
Player session in the World.
Definition: WorldSession.h:882
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool gm_commandscript::HandleGMCommand ( ChatHandler handler,
char const args 
)
inlinestatic
234  {
235  Player* _player = handler->GetSession()->GetPlayer();
236 
237  if (!*args)
238  {
239  handler->GetSession()->SendNotification(_player->IsGameMaster() ? LANG_GM_ON : LANG_GM_OFF);
240  return true;
241  }
242 
243  std::string param = (char*)args;
244 
245  if (param == "on")
246  {
247  _player->SetGameMaster(true);
249  _player->UpdateTriggerVisibility();
250 #ifdef _DEBUG_VMAPS
252  vMapManager->processCommand("stoplog");
253 #endif
254  return true;
255  }
256 
257  if (param == "off")
258  {
259  _player->SetGameMaster(false);
261  _player->UpdateTriggerVisibility();
262 #ifdef _DEBUG_VMAPS
264  vMapManager->processCommand("startlog");
265 #endif
266  return true;
267  }
268 
269  handler->SendSysMessage(LANG_USE_BOL);
270  handler->SetSentErrorMessage(true);
271  return false;
272  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:360
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:361
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Definition: Language.h:290
Definition: IVMapManager.h:45
WorldSession * GetSession()
Definition: Chat.h:59
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
virtual bool processCommand(char *pCommand)=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool gm_commandscript::HandleGMFlyCommand ( ChatHandler handler,
char const args 
)
inlinestatic
94  {
95  if (!*args)
96  return false;
97 
98  Player* target = handler->getSelectedPlayer();
99  if (!target)
100  target = handler->GetSession()->GetPlayer();
101 
102  WorldPacket data;
103  if (strncmp(args, "on", 3) == 0)
104  target->SetCanFly(true);
105  else if (strncmp(args, "off", 4) == 0)
106  target->SetCanFly(false);
107  else
108  {
109  handler->SendSysMessage(LANG_USE_BOL);
110  return false;
111  }
112  handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args);
113  return true;
114  }
Player * GetPlayer() const
Definition: WorldSession.h:927
virtual std::string GetNameLink() const
Definition: Chat.h:101
Definition: Language.h:290
Definition: Language.h:481
Player * getSelectedPlayer()
Definition: Chat.cpp:579
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool gm_commandscript::HandleGMListFullCommand ( ChatHandler handler,
char const  
)
inlinestatic

Display the list of GMs.

  • Get the accounts with GM Level >0
  • Cycle through them. Display username and GM level
160  {
163  stmt->setUInt8(0, uint8(SEC_MODERATOR));
164  stmt->setInt32(1, int32(realm.Id.Realm));
165  PreparedQueryResult result = LoginDatabase.Query(stmt);
166 
167  if (result)
168  {
169  handler->SendSysMessage(LANG_GMLIST);
170  handler->SendSysMessage("========================");
172  do
173  {
174  Field* fields = result->Fetch();
175  char const* name = fields[0].GetCString();
176  uint8 security = fields[1].GetUInt8();
177  uint8 max = (16 - strlen(name)) / 2;
178  uint8 max2 = max;
179  if ((max + max2 + strlen(name)) == 16)
180  max2 = max - 1;
181  if (handler->GetSession())
182  handler->PSendSysMessage("| %s GMLevel %u", name, security);
183  else
184  handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
185  } while (result->NextRow());
186  handler->SendSysMessage("========================");
187  }
188  else
190  return true;
191  }
uint32 Realm
Definition: Realm.h:53
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Realm realm
Definition: World.cpp:3485
Class used to access individual fields of database query result.
Definition: Field.h:56
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: Language.h:626
Definition: PreparedStatement.h:74
T max(const T &x, const T &y)
Definition: g3dmath.h:320
char const * GetCString() const
Definition: Field.h:260
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
uint8 GetUInt8() const
Definition: Field.h:70
Battlenet::RealmHandle Id
Definition: Realm.h:86
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Common.h:109
Definition: LoginDatabase.h:88
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
uint8_t uint8
Definition: g3dmath.h:164
Definition: Language.h:628
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
int32_t int32
Definition: g3dmath.h:167
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool gm_commandscript::HandleGMListIngameCommand ( ChatHandler handler,
char const  
)
inlinestatic
117  {
118  bool first = true;
119  bool footer = false;
120 
121  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
123  for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
124  {
125  AccountTypes itrSec = itr->second->GetSession()->GetSecurity();
126  if ((itr->second->IsGameMaster() ||
127  (itr->second->GetSession()->HasPermission(rbac::RBAC_PERM_COMMANDS_APPEAR_IN_GM_LIST) &&
128  itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
129  (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
130  {
131  if (first)
132  {
133  first = false;
134  footer = true;
136  handler->SendSysMessage("========================");
137  }
138  std::string const& name = itr->second->GetName();
139  uint8 size = name.size();
140  uint8 security = itrSec;
141  uint8 max = ((16 - size) / 2);
142  uint8 max2 = max;
143  if ((max + max2 + size) == 16)
144  max2 = max - 1;
145  if (handler->GetSession())
146  handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security);
147  else
148  handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security);
149  }
150  }
151  if (footer)
152  handler->SendSysMessage("========================");
153  if (first)
155  return true;
156  }
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
T max(const T &x, const T &y)
Definition: g3dmath.h:320
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
AccountTypes
Definition: Common.h:106
Definition: Language.h:49
WorldSession * GetSession()
Definition: Chat.h:59
Definition: ObjectAccessor.h:45
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:50
Definition: World.h:263

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool gm_commandscript::HandleGMVisibleCommand ( ChatHandler handler,
char const args 
)
inlinestatic
195  {
196  Player* _player = handler->GetSession()->GetPlayer();
197 
198  if (!*args)
199  {
200  handler->PSendSysMessage(LANG_YOU_ARE, _player->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE));
201  return true;
202  }
203 
204  const uint32 VISUAL_AURA = 37800;
205  std::string param = (char*)args;
206 
207  if (param == "on")
208  {
209  if (_player->HasAura(VISUAL_AURA))
210  _player->RemoveAurasDueToSpell(VISUAL_AURA);
211 
212  _player->SetGMVisible(true);
213  _player->UpdateObjectVisibility();
215  return true;
216  }
217 
218  if (param == "off")
219  {
220  _player->AddAura(VISUAL_AURA, _player);
221  _player->SetGMVisible(false);
222  _player->UpdateObjectVisibility();
224  return true;
225  }
226 
227  handler->SendSysMessage(LANG_USE_BOL);
228  handler->SetSentErrorMessage(true);
229  return false;
230  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:602
Definition: Language.h:74
Definition: Language.h:75
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:603
Definition: Language.h:73
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Definition: Language.h:290
uint32_t uint32
Definition: Define.h:150
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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