本文整理汇总了C++中playerLink函数的典型用法代码示例。如果您正苦于以下问题:C++ playerLink函数的具体用法?C++ playerLink怎么用?C++ playerLink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了playerLink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PSendSysMessage
//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;
}
示例2: uint16
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;
}
示例3: SendSysMessage
//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;
}
示例4: strtok
//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;
}
示例5: PSendSysMessage
//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;
}
示例6: playerLink
std::string ChatHandler::GetNameLink(Player* chr) const
{
return playerLink(chr->GetName());
}
示例7: SendSysMessage
//.........这里部分代码省略.........
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;
}
示例8: extractOptFirstArg
//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;
}
示例9: extractOptFirstArg
//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;
}
示例10: SendSysMessage
//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
//.........这里部分代码省略.........
示例11: PSendSysMessage
//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);
//.........这里部分代码省略.........
示例12: playerLink
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;
}
示例13: MAKE_NEW_GUID
//.........这里部分代码省略.........
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)
示例14: SendSysMessage
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;
}
示例15: extractOptFirstArg
//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;
}