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

Public Member Functions

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

Static Public Member Functions

static bool HandleGuildCreateCommand (ChatHandler *handler, char const *args)
 GM command level 3 - Create a guild. More...
 
static bool HandleGuildDeleteCommand (ChatHandler *handler, char const *args)
 
static bool HandleGuildInviteCommand (ChatHandler *handler, char const *args)
 
static bool HandleGuildUninviteCommand (ChatHandler *handler, char const *args)
 
static bool HandleGuildRankCommand (ChatHandler *handler, char const *args)
 
static bool HandleGuildRenameCommand (ChatHandler *handler, char const *_args)
 
static bool HandleGuildInfoCommand (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

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

Member Function Documentation

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

Implements CommandScript.

40  {
41  static std::vector<ChatCommand> guildCommandTable =
42  {
50  };
51  static std::vector<ChatCommand> commandTable =
52  {
53  { "guild", rbac::RBAC_PERM_COMMAND_GUILD, true, NULL, "", guildCommandTable },
54  };
55  return commandTable;
56  }
static bool HandleGuildInfoCommand(ChatHandler *handler, char const *args)
Definition: cs_guild.cpp:248
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleGuildRankCommand(ChatHandler *handler, char const *args)
Definition: cs_guild.cpp:173
static bool HandleGuildDeleteCommand(ChatHandler *handler, char const *args)
Definition: cs_guild.cpp:106
static bool HandleGuildUninviteCommand(ChatHandler *handler, char const *args)
Definition: cs_guild.cpp:154
static bool HandleGuildCreateCommand(ChatHandler *handler, char const *args)
GM command level 3 - Create a guild.
Definition: cs_guild.cpp:66
static bool HandleGuildInviteCommand(ChatHandler *handler, char const *args)
Definition: cs_guild.cpp:127
Definition: RBAC.h:308
static bool HandleGuildRenameCommand(ChatHandler *handler, char const *_args)
Definition: cs_guild.cpp:199

+ Here is the call graph for this function:

static bool guild_commandscript::HandleGuildCreateCommand ( ChatHandler handler,
char const args 
)
inlinestatic

GM command level 3 - Create a guild.

This command allows a GM (level 3) to create a guild.

The "args" parameter contains the name of the guild leader and then the name of the guild.

67  {
68  if (!*args)
69  return false;
70 
71  // if not guild name only (in "") then player name
72  Player* target;
73  if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target))
74  return false;
75 
76  char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
77  if (!tailStr)
78  return false;
79 
80  char* guildStr = handler->extractQuotedArg(tailStr);
81  if (!guildStr)
82  return false;
83 
84  std::string guildName = guildStr;
85 
86  if (target->GetGuildId())
87  {
89  return true;
90  }
91 
92  Guild* guild = new Guild;
93  if (!guild->Create(target, guildName))
94  {
95  delete guild;
97  handler->SetSentErrorMessage(true);
98  return false;
99  }
100 
101  sGuildMgr->AddGuild(guild);
102 
103  return true;
104  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:511
#define sGuildMgr
Definition: GuildMgr.h:61
char * extractQuotedArg(char *args)
Definition: Chat.cpp:1016
arena_t NULL
Definition: jemalloc_internal.h:624
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
bool Create(Player *pLeader, std::string const &name)
Definition: Guild.cpp:1078
Definition: Language.h:510
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildDeleteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
107  {
108  if (!*args)
109  return false;
110 
111  char* guildStr = handler->extractQuotedArg((char*)args);
112  if (!guildStr)
113  return false;
114 
115  std::string guildName = guildStr;
116 
117  Guild* targetGuild = sGuildMgr->GetGuildByName(guildName);
118  if (!targetGuild)
119  return false;
120 
121  targetGuild->Disband();
122  delete targetGuild;
123 
124  return true;
125  }
#define sGuildMgr
Definition: GuildMgr.h:61
char * extractQuotedArg(char *args)
Definition: Chat.cpp:1016
void Disband()
Definition: Guild.cpp:1140
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildInfoCommand ( ChatHandler handler,
char const args 
)
inlinestatic
249  {
250  Guild* guild = nullptr;
251 
252  if (args && args[0] != '\0')
253  {
254  if (isNumeric(args))
255  guild = sGuildMgr->GetGuildById(strtoull(args, nullptr, 10));
256  else
257  guild = sGuildMgr->GetGuildByName(args);
258  }
259  else if (Player* target = handler->getSelectedPlayerOrSelf())
260  guild = target->GetGuild();
261 
262  if (!guild)
263  return false;
264 
265  // Display Guild Information
266  handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
267 
268  std::string guildMasterName;
269  if (ObjectMgr::GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
270  handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().ToString().c_str()); // Guild Master
271 
272  // Format creation date
273  char createdDateStr[20];
274  time_t createdDate = guild->GetCreatedDate();
275  tm localTm;
276  strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", localtime_r(&createdDate, &localTm));
277 
278  handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
279  handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMembersCount()); // Number of Members
280  handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetBankMoney() / 100 / 100); // Bank Gold (in gold coins)
281  handler->PSendSysMessage(LANG_GUILD_INFO_LEVEL, guild->GetLevel()); // Level
282  handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the Day
283  handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information
284  return true;
285  }
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:765
Definition: Language.h:984
#define sGuildMgr
Definition: GuildMgr.h:61
std::string const & GetMOTD() const
Definition: Guild.h:767
Definition: Language.h:980
std::string const & GetName() const
Definition: Guild.h:766
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:623
uint32 GetMembersCount() const
Definition: Guild.h:859
uint8 GetLevel() const
Definition: Guild.h:872
uint64 GetBankMoney() const
Definition: Guild.h:770
time_t GetCreatedDate() const
Definition: Guild.h:769
Definition: Language.h:985
ObjectGuid::LowType GetId() const
Definition: Guild.h:763
Definition: Language.h:983
Definition: Language.h:986
TC_COMMON_API struct tm * localtime_r(const time_t *time, struct tm *result)
static bool GetPlayerNameByGUID(ObjectGuid const &guid, std::string &name)
Definition: ObjectMgr.cpp:2258
bool isNumeric(wchar_t wchar)
Definition: Util.h:194
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Guild.h:320
Definition: Language.h:987
std::string const & GetInfo() const
Definition: Guild.h:768
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Language.h:981
Definition: Language.h:982

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildInviteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
128  {
129  if (!*args)
130  return false;
131 
132  // if not guild name only (in "") then player name
133  ObjectGuid targetGuid;
134  if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, NULL, &targetGuid))
135  return false;
136 
137  char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
138  if (!tailStr)
139  return false;
140 
141  char* guildStr = handler->extractQuotedArg(tailStr);
142  if (!guildStr)
143  return false;
144 
145  std::string guildName = guildStr;
146  Guild* targetGuild = sGuildMgr->GetGuildByName(guildName);
147  if (!targetGuild)
148  return false;
149 
150  // player's guild membership checked in AddMember before add
151  return targetGuild->AddMember(targetGuid);
152  }
#define sGuildMgr
Definition: GuildMgr.h:61
char * extractQuotedArg(char *args)
Definition: Chat.cpp:1016
arena_t NULL
Definition: jemalloc_internal.h:624
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
bool AddMember(ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2560
Definition: ObjectGuid.h:189
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildRankCommand ( ChatHandler handler,
char const args 
)
inlinestatic
174  {
175  char* nameStr;
176  char* rankStr;
177  handler->extractOptFirstArg((char*)args, &nameStr, &rankStr);
178  if (!rankStr)
179  return false;
180 
181  Player* target;
182  ObjectGuid targetGuid;
183  std::string target_name;
184  if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name))
185  return false;
186 
187  ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid);
188  if (!guildId)
189  return false;
190 
191  Guild* targetGuild = sGuildMgr->GetGuildById(guildId);
192  if (!targetGuild)
193  return false;
194 
195  uint8 newRank = uint8(atoi(rankStr));
196  return targetGuild->ChangeMemberRank(targetGuid, newRank);
197  }
bool ChangeMemberRank(ObjectGuid guid, uint8 newRank)
Definition: Guild.cpp:2708
#define sGuildMgr
Definition: GuildMgr.h:61
uint64 LowType
Definition: ObjectGuid.h:199
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
void extractOptFirstArg(char *args, char **arg1, char **arg2)
Definition: Chat.cpp:998
Definition: ObjectGuid.h:189
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildRenameCommand ( ChatHandler handler,
char const _args 
)
inlinestatic
200  {
201  if (!*_args)
202  return false;
203 
204  char *args = (char *)_args;
205 
206  char const* oldGuildStr = handler->extractQuotedArg(args);
207  if (!oldGuildStr)
208  {
209  handler->SendSysMessage(LANG_BAD_VALUE);
210  handler->SetSentErrorMessage(true);
211  return false;
212  }
213 
214  char const* newGuildStr = handler->extractQuotedArg(strtok(NULL, ""));
215  if (!newGuildStr)
216  {
218  handler->SetSentErrorMessage(true);
219  return false;
220  }
221 
222  Guild* guild = sGuildMgr->GetGuildByName(oldGuildStr);
223  if (!guild)
224  {
225  handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, oldGuildStr);
226  handler->SetSentErrorMessage(true);
227  return false;
228  }
229 
230  if (sGuildMgr->GetGuildByName(newGuildStr))
231  {
232  handler->PSendSysMessage(LANG_GUILD_RENAME_ALREADY_EXISTS, newGuildStr);
233  handler->SetSentErrorMessage(true);
234  return false;
235  }
236 
237  if (!guild->SetName(newGuildStr))
238  {
239  handler->SendSysMessage(LANG_BAD_VALUE);
240  handler->SetSentErrorMessage(true);
241  return false;
242  }
243 
244  handler->PSendSysMessage(LANG_GUILD_RENAME_DONE, oldGuildStr, newGuildStr);
245  return true;
246  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:119
Definition: Language.h:118
#define sGuildMgr
Definition: GuildMgr.h:61
char * extractQuotedArg(char *args)
Definition: Chat.cpp:1016
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:436
Definition: Language.h:139
bool SetName(std::string const &name)
Definition: Guild.cpp:1237
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: Guild.h:320
Definition: Language.h:508

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool guild_commandscript::HandleGuildUninviteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
155  {
156  Player* target;
157  ObjectGuid targetGuid;
158  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
159  return false;
160 
161  ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid);
162  if (!guildId)
163  return false;
164 
165  Guild* targetGuild = sGuildMgr->GetGuildById(guildId);
166  if (!targetGuild)
167  return false;
168 
169  targetGuild->DeleteMember(targetGuid, false, true, true);
170  return true;
171  }
#define sGuildMgr
Definition: GuildMgr.h:61
uint64 LowType
Definition: ObjectGuid.h:199
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
void DeleteMember(ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2646
Definition: ObjectGuid.h:189
Definition: Guild.h:320

+ 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: