Implemented guild info command (#756)

This commit is contained in:
Nefertumm
2018-01-28 16:27:17 -03:00
committed by Yehonal
parent 75ca1afe85
commit de7d331daf
4 changed files with 47 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
INSERT INTO version_db_world (`sql_rev`) VALUES ('1515920217003409800');
DELETE FROM `command` WHERE `name` = 'guild info';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('guild info', 2, 'Shows information about the target''s guild or a given Guild Id or Name.');

View File

@@ -1161,7 +1161,7 @@ bool Guild::Create(Player* pLeader, std::string const& name)
m_info = "";
m_motd = "No message set.";
m_bankMoney = 0;
m_createdDate = ::time(NULL);
m_createdDate = sWorld->GetGameTime();
_CreateLogHolders();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)

View File

@@ -747,6 +747,7 @@ public:
// pussywizard
uint64 GetTotalBankMoney() const { return m_bankMoney; }
uint32 GetMemberCount() const { return m_members.size(); }
time_t GetCreatedDate() const { return m_createdDate; }
// Bank tabs
void SetBankTabText(uint8 tabId, std::string const& text);

View File

@@ -31,7 +31,8 @@ public:
{ "delete", SEC_GAMEMASTER, true, &HandleGuildDeleteCommand, "" },
{ "invite", SEC_GAMEMASTER, true, &HandleGuildInviteCommand, "" },
{ "uninvite", SEC_GAMEMASTER, true, &HandleGuildUninviteCommand, "" },
{ "rank", SEC_GAMEMASTER, true, &HandleGuildRankCommand, "" }
{ "rank", SEC_GAMEMASTER, true, &HandleGuildRankCommand, "" },
{ "info", SEC_GAMEMASTER, true, &HandleGuildInfoCommand, "" }
};
static std::vector<ChatCommand> commandTable =
{
@@ -180,6 +181,44 @@ public:
uint8 newRank = uint8(atoi(rankStr));
return targetGuild->ChangeMemberRank(targetGuid, newRank);
}
static bool HandleGuildInfoCommand(ChatHandler* handler, char const* args)
{
Guild* guild = nullptr;
if (args && args[0] != '\0')
{
if (isNumeric(args))
guild = sGuildMgr->GetGuildById(strtoull(args, nullptr, 10));
else
guild = sGuildMgr->GetGuildByName(args);
}
else if (Player* target = handler->getSelectedPlayerOrSelf())
guild = target->GetGuild();
if (!guild)
return false;
// Display Guild Information
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
std::string guildMasterName;
if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), GUID_LOPART(guild->GetLeaderGUID())); // Guild Master
// Format creation date
char createdDateStr[20];
time_t createdDate = guild->GetCreatedDate();
tm localTm;
ACE_OS::localtime_r(&createdDate, &localTm);
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", &localTm);
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMemberCount()); // Number of Members
handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetTotalBankMoney() / 100 / 100); // Bank Gold (in gold coins)
handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the day
handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information
return true;
}
};
void AddSC_guild_commandscript()