//rename characters bool ChatHandler::HandleCharacterRenameCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; PSendSysMessage(LANG_RENAME_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_RENAME); } else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; std::string oldNameLink = playerLink(target_name); PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid)); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(target_guid)); } return true; }
bool ChatHandler::HandleCharacterChangeRaceCommand(const char * args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; if (target) { // TODO : add text into database PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '128' WHERE guid = %u", target->GetGUIDLow()); } else { std::string oldNameLink = playerLink(target_name); // TODO : add text into database PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid)); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '128' WHERE guid = %u", GUID_LOPART(target_guid)); } return true; }
bool ChatHandler::HandleCharacterChangeRaceCommand(const char * args) { Player* target; uint64 targetGuid; std::string targetName; if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE)); if (target) { // TODO : add text into database PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); stmt->setUInt32(1, target->GetGUIDLow()); } else { std::string oldNameLink = playerLink(targetName); // TODO : add text into database PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); stmt->setUInt32(1, GUID_LOPART(targetGuid)); } CharacterDatabase.Execute(stmt); return true; }
//mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { char* nameStr; char* delayStr; extractOptFirstArg((char*)args, &nameStr, &delayStr); if (!delayStr) return false; char *mutereason = strtok(NULL, "\r"); std::string mutereasonstr = "No reason"; if (mutereason != NULL) mutereasonstr = mutereason; Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(account_id)) target = session->GetPlayer(); uint32 notspeaktime = (uint32) atoi(delayStr); // must have strong lesser security level if (HasLowerSecurity (target, target_guid, true)) return false; if (target) { //! Target is online, mute will be in effect right away. int64 mutetime = time(NULL) + notspeaktime * MINUTE; target->GetSession()->m_muteTime = mutetime; LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, account_id); ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str()); } else { //! Target is offline, mute will be in effect starting from the next login. int32 muteTime = -int32(notspeaktime * MINUTE); LoginDatabase.PExecute("UPDATE account SET mutetime = %d WHERE id = %u", muteTime, account_id); } std::string nameLink = playerLink(target_name); PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); return true; }
//mute player for some times, in global channels only bool ChatHandler::HandleChannelMuteCommand(char* args) { char* nameStr = ExtractOptNotLastArg(&args); Player* target; ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) return false; uint32 notspeaktime; if (!ExtractUInt32(&args, notspeaktime)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) { if (WorldSession* session = sWorld.FindSession(account_id)) target = session->GetPlayer(); } // FG: limit mutetime if set in conf if(uint32 maxtime = sWorld.getConfig(CONFIG_UINT32_MAX_CHANNEL_MUTETIME)) { notspeaktime = std::min(maxtime,notspeaktime); } // must have strong lesser security level if (HasLowerSecurity(target, target_guid, true)) return false; time_t mutetime = time(NULL) + notspeaktime*60; if (target) target->GetSession()->m_channelMuteTime = mutetime; LoginDatabase.PExecute("UPDATE account SET chanmutetime = " UI64FMTD " WHERE id = '%u'", uint64(mutetime), account_id); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_GLOBAL_CHANNELS_CHAT_DISABLED, notspeaktime); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_DISABLE_CHANNEL_CHAT, nameLink.c_str(), notspeaktime); return true; }
//mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { char* nameStr; char* delayStr; extractOptFirstArg((char*)args,&nameStr,&delayStr); if (!delayStr) return false; char *mutereason = strtok(NULL, "\r"); std::string mutereasonstr = "No reason"; if (mutereason != NULL) mutereasonstr = mutereason; Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget(nameStr,&target,&target_guid,&target_name)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld.FindSession(account_id)) target = session->GetPlayer(); uint32 notspeaktime = (uint32) atoi(delayStr); // must have strong lesser security level if (HasLowerSecurity (target,target_guid,true)) return false; time_t mutetime = time(NULL) + notspeaktime*60; if (target) target->GetSession()->m_muteTime = mutetime; LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'",uint64(mutetime), account_id); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str()); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); return true; }
//unmute player bool ChatHandler::HandleUnmuteCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(accountId)) target = session->GetPlayer(); // must have strong lesser security level if (HasLowerSecurity (target, target_guid, true)) return false; if (target) { if (target->CanSpeak()) { SendSysMessage(LANG_CHAT_ALREADY_ENABLED); SetSentErrorMessage(true); return false; } target->GetSession()->m_muteTime = 0; } PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); stmt->setInt64(0, 0); stmt->setUInt32(1, accountId); LoginDatabase.Execute(stmt); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str()); return true; }
//Send mail by command bool ChatHandler::HandleSendMailCommand(const char* args) { // format: name "subject text" "mail text" Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; char* tail1 = strtok(NULL, ""); if (!tail1) return false; char* msgSubject = extractQuotedArg(tail1); if (!msgSubject) return false; char* tail2 = strtok(NULL, ""); if (!tail2) return false; char* msgText = extractQuotedArg(tail2); if (!msgText) return false; // msgSubject, msgText isn't NUL after prev. check std::string subject = msgSubject; std::string text = msgText; // from console show not existed sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); //- TODO: Fix poor design SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailDraft(subject, text) .SendMailTo(trans, MailReceiver(target, GUID_LOPART(target_guid)), sender); CharacterDatabase.CommitTransaction(trans); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); return true; }
//unmute player bool ChatHandler::HandleUnmuteCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(account_id)) target = session->GetPlayer(); // must have strong lesser security level if (HasLowerSecurity (target, target_guid, true)) return false; if (target) { if (target->CanSpeak()) { SendSysMessage(LANG_CHAT_ALREADY_ENABLED); SetSentErrorMessage(true); return false; } target->GetSession()->m_muteTime = 0; } LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str()); return true; }
//unmute player, in global channels only bool ChatHandler::HandleChannelUnmuteCommand(char* args) { Player* target; ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) { if (WorldSession* session = sWorld.FindSession(account_id)) target = session->GetPlayer(); } if (target) { if (target->CanSpeak()) { SendSysMessage(LANG_CHAT_ALREADY_ENABLED); SetSentErrorMessage(true); return false; } target->GetSession()->m_channelMuteTime = 0; } LoginDatabase.PExecute("UPDATE account SET chanmutetime = '0' WHERE id = '%u'", account_id); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_GLOBAL_CHANNELS_CHAT_ENABLED); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_ENABLE_CHANNEL_CHAT, nameLink.c_str()); return true; }
//rename characters bool ChatHandler::HandleCharacterRenameCommand(const char* args) { Player* target; uint64 targetGuid; std::string targetName; if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; PSendSysMessage(LANG_RENAME_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_RENAME); } else { // check offline security if (HasLowerSecurity(NULL, targetGuid)) return false; std::string oldNameLink = playerLink(targetName); PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); stmt->setUInt32(1, GUID_LOPART(targetGuid)); CharacterDatabase.Execute(stmt); } return true; }
std::string ChatHandler::GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
bool ChatHandler::Additem(int itemid, int count, int type, bool remplacement) { Player* pl = m_session->GetPlayer(); if(!pl) return false; uint64 receiver_guid = pl->GetGUID(); int levelItem = 0; if (type == 0) { int typeRecup; QueryResult result = CharacterDatabase.PQuery("SELECT `typeRecup`, `level_item` FROM `recup_infos` WHERE name = '%s'",pl->GetName()); if (!result) return false; Field* fields = result->Fetch(); if (!fields) return false; typeRecup = fields[0].GetUInt32(); levelItem = fields[1].GetUInt32(); if(remplacement) { QueryResult result = CharacterDatabase.PQuery("SELECT `itemEpique`, `itemRare` FROM `recup_itemRemplacement` WHERE item = '%u'",itemid); if (result) { Field* fields = result->Fetch(); if (fields) { if(typeRecup == 0 || typeRecup == 1) itemid = fields[typeRecup].GetUInt32(); } } } } if(!levelItem) levelItem = 200; QueryResult result = WorldDatabase.PQuery("SELECT `ItemLevel` FROM `item_template` WHERE `entry` = '%d'",itemid); if (!result) return false; if (result) { Field* fields = result->Fetch(); if(!fields) return false; if(fields) { int itemLevel = fields[0].GetUInt32(); if(itemLevel > levelItem) { return false; } } } std::string name = pl->GetName(); if(name.empty()) { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); return false; } char* msgSubject; char* msgText; switch(type) { case 0 : msgSubject="Recuperation";sLog->outDetail("Recuperation");break; case 1 : msgSubject="Achat";sLog->outDetail("Achat");break; } switch(type) { case 0 : msgText="Voici les objets de votre recuperation. Nous vous remercions d'avoir choisi Avalon";sLog->outDetail("Voici les objets de votre recuperation. Nous vous remercions d'avoir choisi Avalon");break; case 1 : msgText="Merci pour votre achat. Bon jeu sur Avalon";sLog->outDetail("Merci pour votre achat. Bon jeu sur Avalon");break; } if (!msgSubject) return false; if (!msgText) return false; // msgSubject, msgText isn't NUL after prev. check std::string subject = msgSubject; std::string text = msgText; // extract items typedef std::pair<uint32,uint32> ItemPair; typedef std::list< ItemPair > ItemPairs; ItemPairs items; uint32 item_id = itemid; if (!item_id) return false; ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(item_id); if (!item_proto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); SetSentErrorMessage(true); return false; } uint32 item_count = count; if (item_count < 1 || (item_proto->MaxCount > 0 && item_count > uint32(item_proto->MaxCount))) { PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); SetSentErrorMessage(true); return false; } while (item_count > item_proto->GetMaxStackSize()) { items.push_back(ItemPair(item_id,item_proto->GetMaxStackSize())); item_count -= item_proto->GetMaxStackSize(); } items.push_back(ItemPair(item_id,item_count)); if (items.size() > MAX_MAIL_ITEMS) { PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); SetSentErrorMessage(true); return false; } // from console show not existed sender MailSender sender(MAIL_NORMAL,m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); // fill mail MailDraft draft(subject, text); SQLTransaction trans = CharacterDatabase.BeginTransaction(); for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) { if (Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0)) { item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted draft.AddItem(item); } } draft.SendMailTo(trans, MailReceiver(pl,GUID_LOPART(receiver_guid)), sender); CharacterDatabase.CommitTransaction(trans); std::string nameLink = playerLink(name); PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); return true; }
//show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; uint32 accId = 0; uint32 money = 0; uint32 total_player_time = 0; uint8 level = 0; uint32 latency = 0; uint8 race; uint8 Class; int64 muteTime = 0; int64 banTime = -1; // get additional information from Player object if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; accId = target->GetSession()->GetAccountId(); money = target->GetMoney(); total_player_time = target->GetTotalPlayedTime(); level = target->getLevel(); latency = target->GetSession()->GetLatency(); race = target->getRace(); Class = target->getClass(); muteTime = target->GetSession()->m_muteTime; } // get additional information from DB else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; // 0 1 2 3 4 5 QueryResult result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account, race, class FROM characters WHERE guid = '%u'", GUID_LOPART(target_guid)); if (!result) return false; Field *fields = result->Fetch(); total_player_time = fields[0].GetUInt32(); level = fields[1].GetUInt32(); money = fields[2].GetUInt32(); accId = fields[3].GetUInt32(); race = fields[4].GetUInt8(); Class = fields[5].GetUInt8(); } std::string username = GetTrilliumString(LANG_ERROR); std::string email = GetTrilliumString(LANG_ERROR); std::string last_ip = GetTrilliumString(LANG_ERROR); uint32 security = 0; std::string last_login = GetTrilliumString(LANG_ERROR); QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel, a.email, a.last_ip, a.last_login, a.mutetime " "FROM account a " "LEFT JOIN account_access aa " "ON (a.id = aa.id) " "WHERE a.id = '%u'", accId); if (result) { Field* fields = result->Fetch(); username = fields[0].GetString(); security = fields[1].GetUInt32(); email = fields[2].GetString(); muteTime = fields[5].GetUInt64(); if (email.empty()) email = "-"; if (!m_session || m_session->GetSecurity() >= AccountTypes(security)) { last_ip = fields[3].GetString(); last_login = fields[4].GetString(); } else { last_ip = "-"; last_login = "******"; } } std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetTrilliumString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(target_guid), username.c_str(), accId, email.c_str(), security, last_ip.c_str(), last_login.c_str(), latency); if (QueryResult result = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate FROM account_banned WHERE id = '%u' AND active ORDER BY bandate ASC LIMIT 1", accId)) { Field * fields = result->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); } else if (QueryResult result = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate FROM character_banned WHERE guid = '%u' AND active ORDER BY bandate ASC LIMIT 1", GUID_LOPART(target_guid))) { Field * fields = result->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); } muteTime = muteTime - time(NULL); if (muteTime > 0 || banTime >= 0) PSendSysMessage(LANG_PINFO_MUTE_BAN, muteTime > 0 ? secsToTimeString(muteTime, true).c_str() : "---", !banTime ? "perm." : (banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "---")); std::string race_s, Class_s; switch(race) { case RACE_HUMAN: race_s = "Human"; break; case RACE_ORC: race_s = "Orc"; break; case RACE_DWARF: race_s = "Dwarf"; break; case RACE_NIGHTELF: race_s = "Night Elf"; break; case RACE_UNDEAD_PLAYER: race_s = "Undead"; break; case RACE_TAUREN: race_s = "Tauren"; break; case RACE_GNOME: race_s = "Gnome"; break; case RACE_TROLL: race_s = "Troll"; break; case RACE_BLOODELF: race_s = "Blood Elf"; break; case RACE_DRAENEI: race_s = "Draenei"; break; } switch(Class) { case CLASS_WARRIOR: Class_s = "Warrior"; break; case CLASS_PALADIN: Class_s = "Paladin"; break; case CLASS_HUNTER: Class_s = "Hunter"; break; case CLASS_ROGUE: Class_s = "Rogue"; break; case CLASS_PRIEST: Class_s = "Priest"; break; case CLASS_DEATH_KNIGHT: Class_s = "Death Knight"; break; case CLASS_SHAMAN: Class_s = "Shaman"; break; case CLASS_MAGE: Class_s = "Mage"; break; case CLASS_WARLOCK: Class_s = "Warlock"; break; case CLASS_DRUID: Class_s = "Druid"; break; } std::string timeStr = secsToTimeString(total_player_time, true, true); uint32 gold = money /GOLD; uint32 silv = (money % GOLD) / SILVER; uint32 copp = (money % GOLD) % SILVER; PSendSysMessage(LANG_PINFO_LEVEL, race_s.c_str(), Class_s.c_str(), timeStr.c_str(), level, gold, silv, copp); return true; }
//mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { char* nameStr; char* delayStr; extractOptFirstArg((char*)args, &nameStr, &delayStr); if (!delayStr) return false; char *mutereason = strtok(NULL, "\r"); std::string mutereasonstr = "No reason"; if (mutereason != NULL) mutereasonstr = mutereason; mutereasonstr = mutereasonstr + " - Наказал - " + m_session->GetPlayer()->GetName(); Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(accountId)) target = session->GetPlayer(); uint32 notspeaktime = (uint32) atoi(delayStr); // must have strong lesser security level if (HasLowerSecurity (target, target_guid, true)) return false; PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); if (target) { // Target is online, mute will be in effect right away. int64 muteTime = time(NULL) + notspeaktime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str()); } else { // Target is offline, mute will be in effect starting from the next login. int32 muteTime = -int32(notspeaktime * MINUTE); stmt->setInt64(0, muteTime); } stmt->setUInt32(1, accountId); LoginDatabase.Execute(stmt); std::string nameLink = playerLink(target_name); if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD)) sWorld->SendWorldText(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); else PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); return true; }
//mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { std::string announce; char* nameStr; char* delayStr; extractOptFirstArg((char*)args,&nameStr,&delayStr); if (!delayStr) return false; char *mutereason = strtok(NULL, "\r"); std::string mutereasonstr = "Нет причины"; if (mutereason != NULL) mutereasonstr = mutereason; if(!mutereason) { PSendSysMessage("Вы должны ввести причину блокировки чата"); SetSentErrorMessage(true); return false; } Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget(nameStr,&target,&target_guid,&target_name)) return false; uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld.FindSession(account_id)) target = session->GetPlayer(); uint32 notspeaktime = (uint32) atoi(delayStr); // must have strong lesser security level if (HasLowerSecurity (target,target_guid,true)) return false; time_t mutetime = time(NULL) + notspeaktime*60; if (target) target->GetSession()->m_muteTime = mutetime; LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'",uint64(mutetime), account_id); if (target) ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str()); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); announce = "У игрока '"; announce += nameStr; announce += "' был отключён чат на "; announce += delayStr; announce += " минут персонажем '"; announce += m_session->GetPlayerName(); announce += "'. Причина: "; announce += mutereason; HandleAnnounceCommand(announce.c_str()); return true; }
//Teleport to Player bool ChatHandler::HandleAppearCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; Player* _player = m_session->GetPlayer(); if (target == _player || target_guid == _player->GetGUID()) { SendSysMessage(LANG_CANT_TELEPORT_SELF); SetSentErrorMessage(true); return false; } if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; std::string chrNameLink = playerLink(target_name); Map* cMap = target->GetMap(); if (cMap->IsBattlegroundOrArena()) { // only allow if gm mode is on if (!_player->isGameMaster()) { PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } // if both players are in different bgs else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId()) _player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff // all's well, set bg id // when porting out from the bg, it will be reset to 0 _player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId()); // remember current position as entry point for return at bg end teleportation if (!_player->GetMap()->IsBattlegroundOrArena()) _player->SetBattlegroundEntryPoint(); } else if (cMap->IsDungeon()) { // we have to go to instance, and can go to player only if: // 1) we are in his group (either as leader or as member) // 2) we are not bound to any group and have GM mode on if (_player->GetGroup()) { // we are in group, we can go only if we are in the player group if (_player->GetGroup() != target->GetGroup()) { PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } } else { // we are not in group, let's verify our GM mode if (!_player->isGameMaster()) { PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } } // if the player or the player's group is bound to another instance // the player will not be bound to another one InstancePlayerBind* pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(cMap->IsRaid())); if (!pBind) { Group* group = _player->GetGroup(); // if no bind exists, create a solo bind InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : NULL; // if no bind exists, create a solo bind if (!gBind) if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId())) _player->BindToInstance(save, !save->CanReset()); } if (cMap->IsRaid()) _player->SetRaidDifficulty(target->GetRaidDifficulty()); else _player->SetDungeonDifficulty(target->GetDungeonDifficulty()); } PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str()); // stop flight if need if (_player->isInFlight()) { _player->GetMotionMaster()->MovementExpired(); _player->CleanupAfterTaxiFlight(); } // save only in non-flight case else _player->SaveRecallPosition(); // to point to see at target with same orientation float x, y, z; target->GetContactPoint(_player, x, y, z); _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE); _player->SetPhaseMask(target->GetPhaseMask(), true); } else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); // to point where player stay (if loaded) float x, y, z, o; uint32 map; bool in_flight; if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, target_guid)) return false; // stop flight if need if (_player->isInFlight()) { _player->GetMotionMaster()->MovementExpired(); _player->CleanupAfterTaxiFlight(); } // save only in non-flight case else _player->SaveRecallPosition(); _player->TeleportTo(map, x, y, z, _player->GetOrientation()); } return true; }
//Summon Player bool ChatHandler::HandleSummonCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; Player* _player = m_session->GetPlayer(); if (target == _player || target_guid == _player->GetGUID()) { PSendSysMessage(LANG_CANT_TELEPORT_SELF); SetSentErrorMessage(true); return false; } if (target) { std::string nameLink = playerLink(target_name); // check online security if (HasLowerSecurity(target, 0)) return false; if (target->IsBeingTeleported()) { PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str()); SetSentErrorMessage(true); return false; } Map* map = m_session->GetPlayer()->GetMap(); if (map->IsBattlegroundOrArena()) { // only allow if gm mode is on if (!_player->isGameMaster()) { PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str()); SetSentErrorMessage(true); return false; } // if both players are in different bgs else if (target->GetBattlegroundId() && m_session->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId()) target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff // all's well, set bg id // when porting out from the bg, it will be reset to 0 target->SetBattlegroundId(m_session->GetPlayer()->GetBattlegroundId(), m_session->GetPlayer()->GetBattlegroundTypeId()); // remember current position as entry point for return at bg end teleportation if (!target->GetMap()->IsBattlegroundOrArena()) target->SetBattlegroundEntryPoint(); } else if (map->IsDungeon()) { Map* cMap = target->GetMap(); if (cMap->Instanceable() && cMap->GetInstanceId() != map->GetInstanceId()) target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true); // we are in instance, and can summon only player in our group with us as lead if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() || (target->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID())) // the last check is a bit excessive, but let it be, just in case { PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str()); SetSentErrorMessage(true); return false; } } PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); if (needReportToTarget(target)) ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(_player->GetName()).c_str()); // stop flight if need if (target->isInFlight()) { target->GetMotionMaster()->MovementExpired(); target->CleanupAfterTaxiFlight(); } // save only in non-flight case else target->SaveRecallPosition(); // before GM float x, y, z; m_session->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize()); target->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, target->GetOrientation()); target->SetPhaseMask(m_session->GetPlayer()->GetPhaseMask(), true); } else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), GetSkyFireString(LANG_OFFLINE)); // in point where GM stay Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetOrientation(), m_session->GetPlayer()->GetZoneId(), target_guid); } return true; }
bool ChatHandler::HandlePartyInfoCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args,&target,&target_guid,&target_name)) return false; uint32 accId = 0; std::string username = ""; std::string status = ""; uint32 security = 0; // get additional information from Player object if (target) { std::string nameLink = playerLink(target_name); if (Group *grp = target->GetGroup()) { if (grp->isRaidGroup()) SendSysMessage("----------------Raid Group----------------"); else if (grp->isBGGroup()) SendSysMessage("----------------BG Group-----------------"); else if (grp->isLFGGroup()) SendSysMessage("----------------LFG Group----------------"); else SendSysMessage("------------------Group------------------"); for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { Player *pl = itr->getSource(); if (!pl || pl == m_session->GetPlayer() || !pl->GetSession()) continue; accId = pl->GetSession()->GetAccountId(); nameLink = playerLink(pl->GetName()); QueryResult result = LoginDatabase.PQuery("SELECT aa.gmlevel, a.username " "FROM account a " "LEFT JOIN account_access aa " "ON (a.id = aa.id) " "WHERE a.id = '%u'",accId); if (result) { Field* fields = result->Fetch(); security = fields[0].GetUInt32(); username = fields[1].GetString(); } if (grp->IsLeader(pl->GetGUID())) { status = "[Leader]"; } else if (grp->IsAssistant(pl->GetGUID())) { status = "[Assistant]"; } PSendSysMessage(LANG_PARTYINFO_PLAYER, (pl?"":GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), username.c_str(), accId, security, status.c_str()); } SendSysMessage("----------------------------------------"); } else { PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); SetSentErrorMessage(true); return false; } } return true; }
//show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); if (sObjectMgr->GetPlayerNameByGUID(parseGUID, target_name)) { target = sObjectMgr->GetPlayerByLowGUID(parseGUID); target_guid = parseGUID; } else if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; uint32 accId = 0; uint32 money = 0; uint32 total_player_time = 0; uint8 level = 0; uint32 latency = 0; uint8 race; uint8 Class; int64 muteTime = 0; int64 banTime = -1; uint32 mapId; uint32 areaId; uint32 phase = 0; uint32 votepoints = 0; uint32 donationpoints = 0; std::string cheatcooldown = ""; std::string cheatcasttime = ""; std::string cheatpower = ""; // get additional information from Player object if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; QueryResult resultTwo = LoginDatabase.PQuery("SELECT vp, dp FROM fusion.account_data WHERE id = '%u' AND vp >= '0'", target->GetSession()->GetAccountId()); if (!resultTwo) // check return false; Field *fields = resultTwo->Fetch(); votepoints = fields[0].GetUInt32(); donationpoints = fields[1].GetUInt32(); accId = target->GetSession()->GetAccountId(); money = target->GetMoney(); total_player_time = target->GetTotalPlayedTime(); level = target->getLevel(); latency = target->GetSession()->GetLatency(); race = target->getRace(); Class = target->getClass(); muteTime = target->GetSession()->m_muteTime; mapId = target->GetMapId(); areaId = target->GetAreaId(); phase = target->GetPhaseMask(); if(target->GetCommandStatus(CHEAT_COOLDOWN)) cheatcooldown = "ON"; else cheatcooldown = "OFF"; if(target->GetCommandStatus(CHEAT_CASTTIME)) cheatcasttime = "ON"; else cheatcasttime = "OFF"; if(target->GetCommandStatus(CHEAT_POWER)) cheatpower = "ON"; else cheatpower = "OFF"; } // get additional information from DB else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO); stmt->setUInt32(0, GUID_LOPART(target_guid)); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return false; Field* fields = result->Fetch(); total_player_time = fields[0].GetUInt32(); level = fields[1].GetUInt8(); money = fields[2].GetUInt32(); accId = fields[3].GetUInt32(); race = fields[4].GetUInt8(); Class = fields[5].GetUInt8(); mapId = fields[6].GetUInt16(); areaId = fields[7].GetUInt16(); } std::string username = GetTrinityString(LANG_ERROR); std::string email = GetTrinityString(LANG_ERROR); std::string last_ip = GetTrinityString(LANG_ERROR); uint32 security = 0; std::string last_login = GetTrinityString(LANG_ERROR); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO); stmt->setInt32(0, int32(realmID)); stmt->setUInt32(1, accId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (result) { Field* fields = result->Fetch(); username = fields[0].GetString(); security = fields[1].GetUInt8(); email = fields[2].GetString(); muteTime = fields[5].GetUInt64(); if (email.empty()) email = "-"; if (!m_session || m_session->GetSecurity() >= AccountTypes(security)) { last_ip = fields[3].GetString(); last_login = fields[4].GetString(); uint32 ip = inet_addr(last_ip.c_str()); #if TRINITY_ENDIAN == BIGENDIAN EndianConvertReverse(ip); #endif PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY); stmt->setUInt32(0, ip); PreparedQueryResult result2 = WorldDatabase.Query(stmt); if (result2) { Field* fields2 = result2->Fetch(); last_ip.append(" ("); last_ip.append(fields2[0].GetString()); last_ip.append(")"); } } else { last_ip = "-"; last_login = "******"; } } std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(target_guid), username.c_str(), accId, email.c_str(), security, last_ip.c_str(), last_login.c_str(), latency, donationpoints, votepoints); std::string bannedby = "unknown"; std::string banreason = ""; stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS); stmt->setUInt32(0, accId); PreparedQueryResult result2 = LoginDatabase.Query(stmt); if (!result2) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS); stmt->setUInt32(0, GUID_LOPART(target_guid)); result2 = CharacterDatabase.Query(stmt); } if (result2) { Field* fields = result2->Fetch(); banTime = int64(fields[1].GetBool() ? 0 : fields[0].GetUInt32()); bannedby = fields[2].GetString(); banreason = fields[3].GetString(); } if (muteTime > 0) PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str()); if (banTime >= 0) PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str()); std::string race_s, Class_s; switch (race) { case RACE_HUMAN: race_s = "Human"; break; case RACE_ORC: race_s = "Orc"; break; case RACE_DWARF: race_s = "Dwarf"; break; case RACE_NIGHTELF: race_s = "Night Elf"; break; case RACE_UNDEAD_PLAYER: race_s = "Undead"; break; case RACE_TAUREN: race_s = "Tauren"; break; case RACE_GNOME: race_s = "Gnome"; break; case RACE_TROLL: race_s = "Troll"; break; case RACE_GOBLIN: race_s = "Goblin"; break; case RACE_BLOODELF: race_s = "Blood Elf"; break; case RACE_DRAENEI: race_s = "Draenei"; break; case RACE_NAGA: race_s = "Naga"; break; case RACE_BROKEN: race_s = "Broken"; break; case RACE_VRYKUL: race_s = "Vrykul"; break; } switch (Class) { case CLASS_WARRIOR: Class_s = "Warrior"; break; case CLASS_PALADIN: Class_s = "Paladin"; break; case CLASS_HUNTER: Class_s = "Hunter"; break; case CLASS_ROGUE: Class_s = "Rogue"; break; case CLASS_PRIEST: Class_s = "Priest"; break; case CLASS_DEATH_KNIGHT: Class_s = "Death Knight"; break; case CLASS_SHAMAN: Class_s = "Shaman"; break; case CLASS_MAGE: Class_s = "Mage"; break; case CLASS_WARLOCK: Class_s = "Warlock"; break; case CLASS_DRUID: Class_s = "Druid"; break; } std::string timeStr = secsToTimeString(total_player_time, true, true); uint32 gold = money /GOLD; uint32 silv = (money % GOLD) / SILVER; uint32 copp = (money % GOLD) % SILVER; PSendSysMessage(LANG_PINFO_LEVEL, race_s.c_str(), Class_s.c_str(), timeStr.c_str(), level, gold, silv, copp); // Add map, zone, subzone and phase to output int locale = GetSessionDbcLocale(); std::string areaName = "<unknown>"; std::string zoneName = ""; MapEntry const* map = sMapStore.LookupEntry(mapId); AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); if (area) { areaName = area->area_name[locale]; AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); if (zone) zoneName = zone->area_name[locale]; } if (target) { if (!zoneName.empty()) PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase); else PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase); } else PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str()); if (target) { PSendSysMessage(LANG_PINFO_CHEATS, cheatcooldown.c_str(), cheatcasttime.c_str(), cheatpower.c_str()); //PSendSysMessage(LANG_PINFO_TOGGLE, summon.c_str(), appear.c_str()); } return true; }
bool ChatHandler::HandleSpectateCommand(const char *args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; Player* _player = m_session->GetPlayer(); if (target == _player || target_guid == _player->GetGUID()) { SendSysMessage(LANG_CANT_TELEPORT_SELF); SetSentErrorMessage(true); return false; } // check online security if (HasLowerSecurity(target, 0)) return false; std::string chrNameLink = playerLink(target_name); if (_player->isInCombat()) { SendSysMessage(LANG_YOU_IN_COMBAT); SetSentErrorMessage(true); return false; } if (!target) { SendSysMessage(LANG_PLAYER_NOT_EXIST_OR_OFFLINE); SetSentErrorMessage(true); return false; } if (_player->GetMap()->IsBattlegroundOrArena() && !_player->isSpectator()) { PSendSysMessage("You are already on battleground or arena."); SetSentErrorMessage(true); return false; } Map* cMap = target->GetMap(); if (!cMap->IsBattlegroundOrArena()) { PSendSysMessage("Player didnt found in arena."); SetSentErrorMessage(true); return false; } if (_player->GetMap()->IsBattleground()) { PSendSysMessage("Cant do that while you are on battleground."); SetSentErrorMessage(true); return false; } // all's well, set bg id // when porting out from the bg, it will be reset to 0 _player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId()); // remember current position as entry point for return at bg end teleportation if (!_player->GetMap()->IsBattlegroundOrArena()) _player->SetBattlegroundEntryPoint(); if (target->isSpectator()) { PSendSysMessage("Can`t do that. Your target is spectator."); SetSentErrorMessage(true); return false; } PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str()); // stop flight if need if (_player->isInFlight()) { _player->GetMotionMaster()->MovementExpired(); _player->CleanupAfterTaxiFlight(); } // save only in non-flight case else _player->SaveRecallPosition(); // to point to see at target with same orientation float x, y, z; target->GetContactPoint(_player, x, y, z); _player->SetSpectate(true); _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE); _player->SetPhaseMask(target->GetPhaseMask(), true); return true; }
//mute player for some times bool ChatHandler::HandleMuteCommand(const char* args) { std::string announce; char* nameStr; char* delayStr; extractOptFirstArg((char*)args, &nameStr, &delayStr); if (!delayStr) return false; char *mutereason = strtok(NULL, "\r"); std::string mutereasonstr = "No reason"; if (mutereason != NULL) mutereasonstr = mutereason; if(!mutereason) { PSendSysMessage("You must enter a reason of mute"); SetSentErrorMessage(true); return false; } Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid); // find only player from same account if any if (!target) if (WorldSession* session = sWorld->FindSession(accountId)) target = session->GetPlayer(); uint32 notspeaktime = (uint32) atoi(delayStr); // must have strong lesser security level if (HasLowerSecurity (target, target_guid, true)) return false; PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); if (target) { // Target is online, mute will be in effect right away. int64 muteTime = time(NULL) + notspeaktime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str()); } else { // Target is offline, mute will be in effect starting from the next login. int32 muteTime = -int32(notspeaktime * MINUTE); stmt->setInt64(0, muteTime); } stmt->setUInt32(1, accountId); LoginDatabase.Execute(stmt); std::string nameLink = playerLink(target_name); PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str()); announce = "The character '"; announce += nameStr; announce += "' was muted for "; announce += delayStr; announce += " minutes by the character '"; announce += m_session->GetPlayerName(); announce += "'. The reason is: "; announce += mutereason; HandleAnnounceCommand(announce.c_str()); return true; }
//show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { Player* target; uint64 target_guid; std::string target_name; uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); if (sObjectMgr->GetPlayerNameByGUID(parseGUID, target_name)) { target = sObjectMgr->GetPlayerByLowGUID(parseGUID); target_guid = parseGUID; } else if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) return false; uint32 accId = 0; uint32 money = 0; uint32 total_player_time = 0; uint8 level = 0; uint32 latency = 0; uint8 race; uint8 Class; int64 muteTime = 0; int64 banTime = -1; uint32 mapId; uint32 areaId; uint32 phase = 0; bool p_jail_isjailed; uint32 p_jail_guid; std::string p_jail_char; uint32 p_jail_release; bool p_jail_amnestietime; std::string p_jail_reason; uint32 p_jail_times; uint32 p_jail_gmacc; std::string p_jail_gmchar; std::string p_jail_lasttime; uint32 p_jail_duration; std::string gmname; // get additional information from Player object if (target) { // check online security if (HasLowerSecurity(target, 0)) return false; accId = target->GetSession()->GetAccountId(); money = target->GetMoney(); total_player_time = target->GetTotalPlayedTime(); level = target->getLevel(); latency = target->GetSession()->GetLatency(); race = target->getRace(); Class = target->getClass(); muteTime = target->GetSession()->m_muteTime; mapId = target->GetMapId(); areaId = target->GetAreaId(); phase = target->GetPhaseMask(); p_jail_isjailed = target->m_jail_isjailed; p_jail_guid = target->m_jail_guid; p_jail_char = target->m_jail_char; p_jail_release = target->m_jail_release; p_jail_amnestietime = target->m_jail_amnestietime; p_jail_reason = target->m_jail_reason; p_jail_times = target->m_jail_times; p_jail_gmacc = target->m_jail_gmacc; p_jail_gmchar = target->m_jail_gmchar; p_jail_lasttime = target->m_jail_lasttime; p_jail_duration = target->m_jail_duration; gmname = target->GetName(); } // get additional information from DB else { // check offline security if (HasLowerSecurity(NULL, target_guid)) return false; // 0 1 2 3 4 5 6 7 QueryResult result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account, race, class, map, zone FROM characters " "WHERE guid = '%u'", GUID_LOPART(target_guid)); if (!result) { return false; } else { Field* fields = result->Fetch(); total_player_time = fields[0].GetUInt32(); level = fields[1].GetUInt32(); money = fields[2].GetUInt32(); accId = fields[3].GetUInt32(); race = fields[4].GetUInt8(); Class = fields[5].GetUInt8(); mapId = fields[6].GetUInt16(); areaId = fields[7].GetUInt16(); } QueryResult row = CharacterDatabase.PQuery("SELECT * FROM `jail` WHERE `guid`='%u' LIMIT 1", GUID_LOPART(target_guid)); if (!row) { p_jail_isjailed = false; } else { Field *data = row->Fetch(); p_jail_isjailed = true; p_jail_guid = data[0].GetUInt32(); p_jail_char = data[1].GetString(); p_jail_release = data[2].GetUInt32(); p_jail_amnestietime = data[3].GetUInt32(); p_jail_reason = data[4].GetString(); p_jail_times = data[5].GetUInt32(); p_jail_gmacc = data[6].GetUInt32(); p_jail_gmchar = data[7].GetString(); p_jail_lasttime = data[8].GetString(); p_jail_duration = data[9].GetUInt32(); gmname = ""; } } std::string username = GetTrinityString(LANG_ERROR); std::string email = GetTrinityString(LANG_ERROR); std::string last_ip = GetTrinityString(LANG_ERROR); uint32 security = 0; std::string last_login = GetTrinityString(LANG_ERROR); QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel, a.email, a.last_ip, a.last_login, a.mutetime " "FROM account a " "LEFT JOIN account_access aa " "ON (a.id = aa.id AND (aa.RealmID = -1 OR aa.RealmID = %u)) " "WHERE a.id = '%u'", realmID, accId); if (result) { Field* fields = result->Fetch(); username = fields[0].GetString(); security = fields[1].GetUInt32(); email = fields[2].GetString(); muteTime = fields[5].GetUInt64(); if (email.empty()) email = "-"; if (!m_session || m_session->GetSecurity() >= AccountTypes(security)) { last_ip = fields[3].GetString(); last_login = fields[4].GetString(); } else { last_ip = "-"; last_login = "******"; } } std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(target_guid), username.c_str(), accId, email.c_str(), security, last_ip.c_str(), last_login.c_str(), latency); std::string bannedby = "unknown"; std::string banreason = ""; if (QueryResult result2 = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned " "WHERE id = '%u' AND active ORDER BY bandate ASC LIMIT 1", accId)) { Field* fields = result2->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); bannedby = fields[2].GetString(); banreason = fields[3].GetString(); } else if (QueryResult result3 = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned " "WHERE guid = '%u' AND active ORDER BY bandate ASC LIMIT 1", GUID_LOPART(target_guid))) { Field* fields = result3->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); bannedby = fields[2].GetString(); banreason = fields[3].GetString(); } if (muteTime > 0) PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str()); if (banTime >= 0) PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str()); std::string race_s, Class_s; switch (race) { case RACE_HUMAN: race_s = "Human"; break; case RACE_ORC: race_s = "Orc"; break; case RACE_DWARF: race_s = "Dwarf"; break; case RACE_NIGHTELF: race_s = "Night Elf"; break; case RACE_UNDEAD_PLAYER: race_s = "Undead"; break; case RACE_TAUREN: race_s = "Tauren"; break; case RACE_GNOME: race_s = "Gnome"; break; case RACE_TROLL: race_s = "Troll"; break; case RACE_BLOODELF: race_s = "Blood Elf"; break; case RACE_DRAENEI: race_s = "Draenei"; break; } switch (Class) { case CLASS_WARRIOR: Class_s = "Warrior"; break; case CLASS_PALADIN: Class_s = "Paladin"; break; case CLASS_HUNTER: Class_s = "Hunter"; break; case CLASS_ROGUE: Class_s = "Rogue"; break; case CLASS_PRIEST: Class_s = "Priest"; break; case CLASS_DEATH_KNIGHT: Class_s = "Death Knight"; break; case CLASS_SHAMAN: Class_s = "Shaman"; break; case CLASS_MAGE: Class_s = "Mage"; break; case CLASS_WARLOCK: Class_s = "Warlock"; break; case CLASS_DRUID: Class_s = "Druid"; break; } std::string timeStr = secsToTimeString(total_player_time, true, true); uint32 gold = money /GOLD; uint32 silv = (money % GOLD) / SILVER; uint32 copp = (money % GOLD) % SILVER; PSendSysMessage(LANG_PINFO_LEVEL, race_s.c_str(), Class_s.c_str(), timeStr.c_str(), level, gold, silv, copp); // Add map, zone, subzone and phase to output int locale = GetSessionDbcLocale(); std::string areaName = "<unknown>"; std::string zoneName = ""; MapEntry const* map = sMapStore.LookupEntry(mapId); AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); if (area) { areaName = area->area_name[locale]; AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); if (zone) zoneName = zone->area_name[locale]; } if (target) { if (!zoneName.empty()) PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase); else PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase); } else PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str()); if (p_jail_times > 0) { if (p_jail_release > 0) { time_t localtime; localtime = time(NULL); uint32 min_left = (uint32)floor(float(p_jail_release - localtime) / 60); if (min_left <= 0) { p_jail_release = 0; CharacterDatabase.PExecute("UPDATE `jail` SET `release`='%u' WHERE `guid`='%u' LIMIT 1", p_jail_release, p_jail_guid); PSendSysMessage(LANG_JAIL_GM_INFO, p_jail_char.c_str(), p_jail_times, 0, p_jail_gmchar.c_str(), p_jail_reason.c_str()); return true; } else { PSendSysMessage(LANG_JAIL_GM_INFO, p_jail_char.c_str(), p_jail_times, min_left, p_jail_gmchar.c_str(), p_jail_reason.c_str()); return true; } } else { PSendSysMessage(LANG_JAIL_GM_INFO, p_jail_char.c_str(), p_jail_times, 0, p_jail_gmchar.c_str(), p_jail_reason.c_str()); return true; } } else { PSendSysMessage(LANG_JAIL_GM_NOINFO, gmname.c_str()); return true; } return true; }