Core/Commands: Convert guild commands in commandscript
This commit is contained in:
1 parent
c49bc934b8
commit
f8374fac0b
6 files changed
+202
-157
No files matched your search
@@ -1300,145 +1300,6 @@ bool ChatHandler::HandleLookupMapCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief 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.
|
||||
*
|
||||
*/
|
||||
bool ChatHandler::HandleGuildCreateCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// if not guild name only (in "") then player name
|
||||
Player* target;
|
||||
if (!extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target))
|
||||
return false;
|
||||
|
||||
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
|
||||
if (!tailStr)
|
||||
return false;
|
||||
|
||||
char* guildStr = extractQuotedArg(tailStr);
|
||||
if (!guildStr)
|
||||
return false;
|
||||
|
||||
std::string guildname = guildStr;
|
||||
|
||||
if (target->GetGuildId())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_IN_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild* guild = new Guild;
|
||||
if (!guild->Create(target, guildname))
|
||||
{
|
||||
delete guild;
|
||||
SendSysMessage(LANG_GUILD_NOT_CREATED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sGuildMgr->AddGuild(guild);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGuildInviteCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// if not guild name only (in "") then player name
|
||||
uint64 target_guid;
|
||||
if (!extractPlayerTarget(*args != '"' ? (char*)args : NULL, NULL, &target_guid))
|
||||
return false;
|
||||
|
||||
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
|
||||
if (!tailStr)
|
||||
return false;
|
||||
|
||||
char* guildStr = extractQuotedArg(tailStr);
|
||||
if (!guildStr)
|
||||
return false;
|
||||
|
||||
std::string glName = guildStr;
|
||||
Guild* targetGuild = sGuildMgr->GetGuildByName(glName);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
// player's guild membership checked in AddMember before add
|
||||
return targetGuild->AddMember(target_guid);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGuildUninviteCommand(const char *args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
if (!extractPlayerTarget((char*)args, &target, &target_guid))
|
||||
return false;
|
||||
|
||||
uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid);
|
||||
if (!glId)
|
||||
return false;
|
||||
|
||||
Guild* targetGuild = sGuildMgr->GetGuildById(glId);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
targetGuild->DeleteMember(target_guid, false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGuildRankCommand(const char *args)
|
||||
{
|
||||
char* nameStr;
|
||||
char* rankStr;
|
||||
extractOptFirstArg((char*)args, &nameStr, &rankStr);
|
||||
if (!rankStr)
|
||||
return false;
|
||||
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
|
||||
return false;
|
||||
|
||||
uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid);
|
||||
if (!glId)
|
||||
return false;
|
||||
|
||||
Guild* targetGuild = sGuildMgr->GetGuildById (glId);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
uint32 newrank = uint32 (atoi (rankStr));
|
||||
return targetGuild->ChangeMemberRank(target_guid, newrank);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGuildDeleteCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* guildStr = extractQuotedArg((char*)args);
|
||||
if (!guildStr)
|
||||
return false;
|
||||
|
||||
std::string gld = guildStr;
|
||||
|
||||
Guild* targetGuild = sGuildMgr->GetGuildByName(gld);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
targetGuild->Disband();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGetDistanceCommand(const char *args)
|
||||
{
|
||||
WorldObject* obj = NULL;
|
||||
|
||||
Reference in new issue
Block a user