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

Public Member Functions

 deserter_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 Returns the command structure for the system. More...
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleDeserterAdd (ChatHandler *handler, char const *args, bool isInstance)
 Applies the Deserter Debuff to a player. More...
 
static bool HandleDeserterRemove (ChatHandler *handler, char const *, bool isInstance)
 Removes the Deserter Debuff from a player. More...
 
static bool HandleDeserterInstanceAdd (ChatHandler *handler, char const *args)
 
static bool HandleDeserterBGAdd (ChatHandler *handler, char const *args)
 
static bool HandleDeserterInstanceRemove (ChatHandler *handler, char const *args)
 
static bool HandleDeserterBGRemove (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

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

Member Function Documentation

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

Returns the command structure for the system.

Implements CommandScript.

47  {
48  static std::vector<ChatCommand> deserterInstanceCommandTable =
49  {
52  };
53  static std::vector<ChatCommand> deserterBGCommandTable =
54  {
57  };
58 
59  static std::vector<ChatCommand> deserterCommandTable =
60  {
61  { "instance", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE, false, NULL, "", deserterInstanceCommandTable },
62  { "bg", rbac::RBAC_PERM_COMMAND_DESERTER_BG, false, NULL, "", deserterBGCommandTable },
63  };
64  static std::vector<ChatCommand> commandTable =
65  {
66  { "deserter", rbac::RBAC_PERM_COMMAND_DESERTER, false, NULL, "", deserterCommandTable },
67  };
68  return commandTable;
69  }
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleDeserterInstanceAdd(ChatHandler *handler, char const *args)
Definition: cs_deserter.cpp:168
static bool HandleDeserterBGAdd(ChatHandler *handler, char const *args)
Definition: cs_deserter.cpp:174
Definition: RBAC.h:248
static bool HandleDeserterInstanceRemove(ChatHandler *handler, char const *args)
Definition: cs_deserter.cpp:180
static bool HandleDeserterBGRemove(ChatHandler *handler, char const *args)
Definition: cs_deserter.cpp:186

+ Here is the call graph for this function:

static bool deserter_commandscript::HandleDeserterAdd ( ChatHandler handler,
char const args,
bool  isInstance 
)
inlinestatic

Applies the Deserter Debuff to a player.

This function applies a Deserter Debuff of the given type (Instance or BG) to the selected player, with the provided duration in seconds.

Parameters
handlerThe ChatHandler, passed by the system.
argsThe provided duration in seconds.
isInstanceprovided by the relaying functions, so we don't have to write that much code :)
Returns
true if everything was correct, false if an error occured.

Example Usage:

.deserter instance add 3600 (one hour)
-or-
.deserter bg add 3600 (one hour)
92  {
93  if (!*args)
94  return false;
95 
96  Player* player = handler->getSelectedPlayer();
97  if (!player)
98  {
100  handler->SetSentErrorMessage(true);
101  return false;
102  }
103  char* timeStr = strtok((char*)args, " ");
104  if (!timeStr)
105  {
106  handler->SendSysMessage(LANG_BAD_VALUE);
107  handler->SetSentErrorMessage(true);
108  return false;
109  }
110  uint32 time = atoi(timeStr);
111 
112  if (!time)
113  {
114  handler->SendSysMessage(LANG_BAD_VALUE);
115  handler->SetSentErrorMessage(true);
116  return false;
117  }
118 
119  Aura* aura = player->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, player);
120 
121  if (!aura)
122  {
123  handler->SendSysMessage(LANG_BAD_VALUE);
124  handler->SetSentErrorMessage(true);
125  return false;
126  }
127  aura->SetDuration(time * IN_MILLISECONDS);
128 
129  return true;
130  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:140
uint32_t uint32
Definition: Define.h:150
Definition: cs_deserter.cpp:34
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: Language.h:139
Definition: Common.h:103
Definition: cs_deserter.cpp:33
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:806
Definition: SpellAuras.h:116
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 deserter_commandscript::HandleDeserterBGAdd ( ChatHandler handler,
char const args 
)
inlinestatic
See also
HandleDeserterAdd()
175  {
176  return HandleDeserterAdd(handler, args, false);
177  }
static bool HandleDeserterAdd(ChatHandler *handler, char const *args, bool isInstance)
Applies the Deserter Debuff to a player.
Definition: cs_deserter.cpp:91

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool deserter_commandscript::HandleDeserterBGRemove ( ChatHandler handler,
char const args 
)
inlinestatic
See also
HandleDeserterRemove()
187  {
188  return HandleDeserterRemove(handler, args, false);
189  }
static bool HandleDeserterRemove(ChatHandler *handler, char const *, bool isInstance)
Removes the Deserter Debuff from a player.
Definition: cs_deserter.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool deserter_commandscript::HandleDeserterInstanceAdd ( ChatHandler handler,
char const args 
)
inlinestatic
See also
HandleDeserterAdd()
169  {
170  return HandleDeserterAdd(handler, args, true);
171  }
static bool HandleDeserterAdd(ChatHandler *handler, char const *args, bool isInstance)
Applies the Deserter Debuff to a player.
Definition: cs_deserter.cpp:91

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool deserter_commandscript::HandleDeserterInstanceRemove ( ChatHandler handler,
char const args 
)
inlinestatic
See also
HandleDeserterRemove()
181  {
182  return HandleDeserterRemove(handler, args, true);
183  }
static bool HandleDeserterRemove(ChatHandler *handler, char const *, bool isInstance)
Removes the Deserter Debuff from a player.
Definition: cs_deserter.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool deserter_commandscript::HandleDeserterRemove ( ChatHandler handler,
char const ,
bool  isInstance 
)
inlinestatic

Removes the Deserter Debuff from a player.

This function removes a Deserter Debuff of the given type (Instance or BG) from the selected player.

Parameters
handlerThe ChatHandler, passed by the system.
argsShould be nothing.
isInstanceprovided by the relaying functions, so we don't have to write that much code :)
Returns
true if everything was correct, false if an error occured.

Example Usage:

.deserter instance remove
-or-
.deserter bg remove
153  {
154  Player* player = handler->getSelectedPlayer();
155  if (!player)
156  {
158  handler->SetSentErrorMessage(true);
159  return false;
160  }
161 
162  player->RemoveAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
163 
164  return true;
165  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:140
Definition: cs_deserter.cpp:34
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: cs_deserter.cpp:33
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: