rendered paste bodyvoid IRCcommand::HandlePlayerIRCCommand(std::string param, std::string outputChan,std::string type)
{
int pos = param.find(" ");
if (param == "")
{
sIRC.SendIRCData(type + " " + outputChan + " :" + "Syntax: " + sIRC.IRC_CMDS_PREFIX + "player playername" + "\n");
return;
}
std::string pname = param.substr(0, pos);
normalizePlayerName(pname);
sDatabase.escape_string(pname);
std::string sqlquery = "SELECT `guid`, `name`, `race`, `class`, `online`, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 35), ' ' , -1) AS `level`, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 230), ' ' , -1) AS `guildid`, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 231), ' ' , -1) AS `guildrank`, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 859), ' ' , -1) AS `xp`, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 860), ' ' , -1) AS `maxxp`, SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ' , 1327), ' ' , -1) AS `gold` FROM `character` WHERE `name` LIKE '" + pname + "';";
QueryResult *result = sDatabase.Query(sqlquery.c_str());
if(result)
{
Field *fields = result->Fetch();
std::string pguid = fields[0].GetCppString();
pname = fields[1].GetCppString();
uint32 praceid = fields[2].GetUInt32();
uint32 pclassid = fields[3].GetUInt32();
std::string ponline = (fields[4].GetInt32() == 1 ? "\x3\x30\x33Online" : "\x3\x30\x34Offline\xF");
std::string plevel = fields[5].GetCppString();
uint32 pguildid = fields[6].GetUInt32();
uint32 pguildrank = fields[7].GetUInt32();
std::string pxp = fields[8].GetCppString();
std::string pmaxxp = fields[9].GetCppString();
unsigned int money = fields[10].GetInt32();
delete result;
std::string guildinfo = "";
if (pguildid != 0)
{
Guild* guild = objmgr.GetGuildById(pguildid);
if (guild)
{
guildinfo = ", " + guild->GetRankName(pguildrank) + " of " + guild->GetName();
}
}
ChrRacesEntry const* prace = sChrRacesStore.LookupEntry(praceid);
ChrClassesEntry const* pclass = sChrClassesStore.LookupEntry(pclassid);
if (atoi(plevel.c_str()) < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
plevel += " (" + pxp + "/" + pmaxxp + ")";
unsigned int gold = money / 10000;
unsigned int silv = (money % 10000) / 100;
unsigned int cop = (money % 10000) % 100;
char tempgold [100];
sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop);
if (ponline == "\x3\x30\x33Online")
{
Player * player = ObjectAccessor::Instance().FindPlayerByName(pname.c_str());
if (player)
{
AreaTableEntry const* area = GetAreaEntryByAreaID(player->GetAreaId());
ponline += " in " + (std::string) area->area_name[sWorld.GetDBClang()];
if (area->zone != 0)
{
AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
ponline += " (" + (std::string)zone->area_name[sWorld.GetDBClang()] + ")";
}
}
}
sIRC.SendIRCData(type + " " + outputChan + " :" + "About " + pname + guildinfo + "\n");
sIRC.SendIRCData(type + " " + outputChan + " :" + "\x2Race:\x2\x3\x31\x30 " + (std::string)prace->name[sWorld.GetDBClang()] + "\xF |\x2 Class:\x2\x3\x31\x30 " + (std::string)pclass->name[sWorld.GetDBClang()] + "\xF |\x2 Level:\x2\x3\x31\x30 " + plevel + "\xF |\x2 Money:\x2 " + tempgold + "\xF |\x2 Status:\x2 " + ponline + "\n");
}
else
sIRC.SendIRCData(type + " " + outputChan + " :" + "Unknown Player: " + pname + "\n");
}
void IRCcommand::HandleInChanIRCCommand(std::string outputChan,std::string type)
{
QueryResult *result = sDatabase.Query("SELECT * FROM irc_inchan ORDER BY `name`");
if (!result)
{
sIRC.SendIRCData(type + " " + outputChan + " :No Players are in the Channel\n");
return;
}
std::string output = "\x02Players in the Channel:";
for (uint64 i=0; i < result->GetRowCount(); i++)
{
Field *fields = result->Fetch();
output += " \x03" + fields[2].GetCppString() + fields[1].GetCppString() + "\x03";
result->NextRow();
}
delete result;
sIRC.SendIRCData(type + " " + outputChan + " :" + output + "\n");
}