mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(CORE/Commands): .Pinfo - Show guild informations (#1775)
* fix(CORE/Commands): .Pinfo *Now you can see Guild Name, Guild Rank, Note, Officer Note And Xp - Total Xp * Renamed inappropriate variable names * Add Guild related informations
This commit is contained in:
committed by
Poszer
parent
3e071ea740
commit
e56c8e07ce
@@ -1742,7 +1742,7 @@ public:
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
PreparedStatement* stmt = nullptr;
|
||||
|
||||
|
||||
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
|
||||
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
|
||||
@@ -1755,6 +1755,7 @@ public:
|
||||
|
||||
// Account data print variables
|
||||
std::string userName = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 lowguid = GUID_LOPART(targetGuid);
|
||||
uint32 accId = 0;
|
||||
std::string eMail = handler->GetTrinityString(LANG_ERROR);
|
||||
std::string regMail = handler->GetTrinityString(LANG_ERROR);
|
||||
@@ -1788,14 +1789,14 @@ public:
|
||||
uint32 money = 0;
|
||||
uint32 xp = 0;
|
||||
uint32 xptotal = 0;
|
||||
|
||||
|
||||
// Position data print
|
||||
uint32 mapId;
|
||||
uint32 areaId;
|
||||
uint32 phase = 0;
|
||||
char const* areaName = nullptr;
|
||||
char const* zoneName = nullptr;
|
||||
|
||||
|
||||
// Guild data print variables defined so that they exist, but are not necessarily used
|
||||
uint32 guildId = 0;
|
||||
uint8 guildRankId = 0;
|
||||
@@ -1803,7 +1804,7 @@ public:
|
||||
std::string guildRank;
|
||||
std::string note;
|
||||
std::string officeNote;
|
||||
|
||||
|
||||
// get additional information from Player object
|
||||
if (target)
|
||||
{
|
||||
@@ -1835,12 +1836,12 @@ public:
|
||||
// Query informations from the DB
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
stmt->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
if (!charInfoResult)
|
||||
return false;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
Field* fields = charInfoResult->Fetch();
|
||||
totalPlayerTime = fields[0].GetUInt32();
|
||||
level = fields[1].GetUInt8();
|
||||
money = fields[2].GetUInt32();
|
||||
@@ -1858,16 +1859,16 @@ public:
|
||||
else
|
||||
alive = handler->GetTrinityString(LANG_YES);
|
||||
}
|
||||
|
||||
|
||||
// Query the prepared statement for login data
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
|
||||
stmt->setInt32(0, int32(realmID));
|
||||
stmt->setUInt32(1, accId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
PreparedQueryResult accInfoResult = LoginDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
if (accInfoResult)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Field* fields = accInfoResult->Fetch();
|
||||
userName = fields[0].GetString();
|
||||
security = fields[1].GetUInt8();
|
||||
|
||||
@@ -1885,7 +1886,7 @@ public:
|
||||
lastIp.append(location->CountryName);
|
||||
lastIp.append(")");
|
||||
} **/
|
||||
|
||||
|
||||
uint32 ip = inet_addr(lastIp.c_str());
|
||||
#if TRINITY_ENDIAN == BIGENDIAN
|
||||
EndianConvertReverse(ip);
|
||||
@@ -1918,42 +1919,81 @@ public:
|
||||
locked = fields[10].GetUInt8();
|
||||
OS = fields[11].GetString();
|
||||
}
|
||||
|
||||
|
||||
// Creates a chat link to the character. Returns nameLink
|
||||
std::string nameLink = handler->playerLink(targetName);
|
||||
|
||||
// Returns banType, banTime, bannedBy, banreason
|
||||
PreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
stmt2->setUInt32(0, accId);
|
||||
PreparedQueryResult result2 = LoginDatabase.Query(stmt2);
|
||||
if (!result2)
|
||||
PreparedStatement* banQuery = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
banQuery->setUInt32(0, accId);
|
||||
PreparedQueryResult accBannedResult = LoginDatabase.Query(banQuery);
|
||||
if (!accBannedResult)
|
||||
{
|
||||
banType = handler->GetTrinityString(LANG_CHARACTER);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
result2 = CharacterDatabase.Query(stmt);
|
||||
accBannedResult = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
|
||||
if (result2)
|
||||
if (accBannedResult)
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
Field* fields = accBannedResult->Fetch();
|
||||
banTime = int64(fields[1].GetUInt64() ? 0 : fields[0].GetUInt32());
|
||||
bannedBy = fields[2].GetString();
|
||||
banReason = fields[3].GetString();
|
||||
}
|
||||
|
||||
|
||||
// Can be used to query data from World database
|
||||
PreparedStatement* xpQuery = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP);
|
||||
xpQuery->setUInt8(0, level);
|
||||
PreparedQueryResult xpResult = WorldDatabase.Query(xpQuery);
|
||||
|
||||
if (xpResult)
|
||||
{
|
||||
Field* fields = xpResult->Fetch();
|
||||
xptotal = fields[0].GetUInt32();
|
||||
}
|
||||
|
||||
// Can be used to query data from Characters database
|
||||
PreparedStatement* charXpQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP);
|
||||
charXpQuery->setUInt32(0, lowguid);
|
||||
PreparedQueryResult charXpResult = CharacterDatabase.Query(charXpQuery);
|
||||
|
||||
if (charXpResult)
|
||||
{
|
||||
Field* fields = charXpResult->Fetch();
|
||||
xp = fields[0].GetUInt32();
|
||||
uint32 gguid = fields[1].GetUInt32();
|
||||
|
||||
if (gguid != 0)
|
||||
{
|
||||
PreparedStatement* guildQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED);
|
||||
guildQuery->setUInt32(0, lowguid);
|
||||
PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
|
||||
if (guildInfoResult)
|
||||
{
|
||||
Field* fields = guildInfoResult->Fetch();
|
||||
guildId = fields[0].GetUInt32();
|
||||
guildName = fields[1].GetString();
|
||||
guildRank = fields[2].GetString();
|
||||
note = fields[3].GetString();
|
||||
officeNote = fields[4].GetString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initiate output
|
||||
// Output I. LANG_PINFO_PLAYER
|
||||
handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetTrinityString(LANG_OFFLINE), nameLink.c_str(), GUID_LOPART(targetGuid));
|
||||
|
||||
|
||||
// Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster
|
||||
if (target && target->IsGameMaster())
|
||||
handler->PSendSysMessage(LANG_PINFO_GM_ACTIVE);
|
||||
|
||||
|
||||
// Output III. LANG_PINFO_BANNED if ban exists and is applied
|
||||
if (banTime >= 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - time(nullptr), true).c_str() : handler->GetTrinityString(LANG_PERMANENTLY), bannedBy.c_str());
|
||||
|
||||
|
||||
// Output IV. LANG_PINFO_MUTED if mute is applied
|
||||
if (muteTime > 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - time(nullptr), true).c_str(), muteBy.c_str());
|
||||
@@ -2047,8 +2087,8 @@ public:
|
||||
classStr = "Druid";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetTrinityString(LANG_CHARACTER_GENDER_MALE) : handler->GetTrinityString(LANG_CHARACTER_GENDER_FEMALE)), raceStr.c_str(), classStr.c_str());
|
||||
|
||||
// Output XII. LANG_PINFO_CHR_ALIVE
|
||||
@@ -2103,12 +2143,12 @@ public:
|
||||
|
||||
// Mail Data - an own query, because it may or may not be useful.
|
||||
// SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?"
|
||||
PreparedStatement* stmt4 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS);
|
||||
stmt4->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
PreparedQueryResult result6 = CharacterDatabase.Query(stmt4);
|
||||
if (result6)
|
||||
PreparedStatement* mailQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS);
|
||||
mailQuery->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery);
|
||||
if (mailInfoResult)
|
||||
{
|
||||
Field* fields = result6->Fetch();
|
||||
Field* fields = mailInfoResult->Fetch();
|
||||
uint32 readmail = uint32(fields[0].GetDouble());
|
||||
uint32 totalmail = uint32(fields[1].GetUInt64());
|
||||
|
||||
@@ -3025,7 +3065,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user