本文整理汇总了C++中getSelectedPlayer函数的典型用法代码示例。如果您正苦于以下问题:C++ getSelectedPlayer函数的具体用法?C++ getSelectedPlayer怎么用?C++ getSelectedPlayer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSelectedPlayer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSelectedPlayer
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
{
std::string ip;
int32 limit;
char* limit_str;
Player *chr = getSelectedPlayer();
if (!*args)
{
// NULL only if used from console
if (!chr || chr == GetSession()->GetPlayer())
return false;
ip = chr->GetSession()->GetRemoteAddress();
limit = -1;
}
else
{
ip = strtok ((char*)args, " ");
limit_str = strtok (NULL, " ");
limit = limit_str ? atoi (limit_str) : -1;
}
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
stmt->setString(0, ip);
PreparedQueryResult result = LoginDatabase.Query(stmt);
return LookupPlayerSearchCommand(result, limit);
}
示例2: SendSysMessage
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
{
Player* player = m_session->GetPlayer();
// Jail by WarHead edited by Vlad
if (player->m_jail_isjailed)
{
SendSysMessage(LANG_JAIL_DENIED);
return true;
}
// save GM account without delay and output message
if (m_session->GetSecurity() > SEC_PLAYER)
{
if (Player *target = getSelectedPlayer())
target->SaveToDB();
else
player->SaveToDB();
SendSysMessage(LANG_PLAYER_SAVED);
return true;
}
// save if the player has last been saved over 20 seconds ago
uint32 save_interval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
if (save_interval == 0 || (save_interval > 20*IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20*IN_MILLISECONDS))
player->SaveToDB();
return true;
}
示例3: SendSysMessage
bool ChatHandler::HandleModifyScaleCommand(const char* args)
{
WorldPacket data;
if (!*args)
return false;
float Scale = (float)atof((char*)args);
if (Scale > 3 || Scale <= 0)
{
SendSysMessage(LANG_BAD_VALUE);
return true;
}
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName());
char buf[256];
sprintf((char*)buf,LANG_YOURS_SIZE_CHANGED, m_session->GetPlayer()->GetName(), Scale);
FillSystemMessageData(&data, m_session, buf);
chr->GetSession()->SendPacket(&data);
chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
return true;
}
示例4: strtok
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
char* kickName = strtok((char*)args, " ");
if (!kickName)
{
Player* player = getSelectedPlayer();
if(player==m_session->GetPlayer())
{
SendSysMessage("You can't kick self, logout instead");
return true;
}
player->GetSession()->KickPlayer();
}
else
{
std::string name = kickName;
normalizePlayerName(name);
if(name==m_session->GetPlayer()->GetName())
{
SendSysMessage("You can't kick self, logout instead");
return true;
}
if(sWorld.KickPlayer(name))
{
PSendSysMessage("Player %s kicked.",name.c_str());
}
else
PSendSysMessage("Player %s not found.",name.c_str());
}
return true;
}
示例5: getSelectedPlayer
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
{
std::string ip;
int32 limit;
char* limit_str;
Player *chr = getSelectedPlayer();
if (!*args)
{
// NULL only if used from console
if (!chr || chr == GetSession()->GetPlayer())
return false;
ip = chr->GetSession()->GetRemoteAddress();
limit = -1;
}
else
{
ip = strtok ((char*)args, " ");
limit_str = strtok (NULL, " ");
limit = limit_str ? atoi (limit_str) : -1;
}
LoginDatabase.EscapeString(ip);
QueryResult result = LoginDatabase.PQuery("SELECT id, username FROM account WHERE last_ip = '%s'", ip.c_str());
return LookupPlayerSearchCommand(result, limit);
}
示例6: getSelectedPlayer
//kick player
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{
Player* target = getSelectedPlayer();
std::string playerName;
if (!extractPlayerTarget((char*)args, &target, NULL, &playerName))
return false;
char *szAcc = strtok((char*)args, " ");
char *szPassword = strtok(NULL, " ");
if (m_session && target == m_session->GetPlayer())
{
SendSysMessage(LANG_COMMAND_KICKSELF);
SetSentErrorMessage(true);
return false;
}
// check online security
if (HasLowerSecurity(target, 0))
return false;
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
target->GetSession()->KickPlayer();
return true;
}
示例7: SendSysMessage
bool ChatHandler::HandleModifyBWalkCommand(const char* args)
{
WorldPacket data;
if (!*args)
return false;
float BSpeed = (float)atof((char*)args);
if (BSpeed > 10 || BSpeed < 0.1)
{
SendSysMessage(LANG_BAD_VALUE);
return true;
}
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName());
char buf[256];
sprintf((char*)buf,LANG_YOURS_BACK_SPEED_CHANGED, m_session->GetPlayer()->GetName(), BSpeed);
FillSystemMessageData(&data, m_session, buf);
chr->GetSession()->SendPacket(&data);
chr->SetSpeed(MOVE_WALKBACK,BSpeed,true);
return true;
}
示例8: strtok
bool ChatHandler::HandleUnsicknessCommand(char* args)
{
std::string name;
Player* player;
char* TargetName = strtok((char*)args, " "); //get entered #name
if (!TargetName) //if no #name entered use target
{
player = getSelectedPlayer();
if (player) //prevent crash with creature as target
{
name = player->GetName();
normalizePlayerName(name);
}
}
else // if #name entered
{
name = TargetName;
normalizePlayerName(name);
player = sObjectMgr.GetPlayer(name.c_str()); //get player by #name
}
//effect
if ((player) && (!(player == m_session->GetPlayer())))
{
if (player->HasSpell(15007)) // 15007 SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
player->RemoveAurasDueToSpell(15007); // SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
else
PSendSysMessage("You not a Ressurection Sickness!", name.c_str());
return true;
}
}
示例9: PSendSysMessage
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
{
player = NULL;
guid.Clear();
if (cname)
{
std::string name = cname;
if (!name.empty())
{
if (!normalizePlayerName(name))
{
PSendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
player = ObjectAccessor::FindPlayerByName(name);
if (offline)
guid = sObjectMgr->GetPlayerGUIDByName(name.c_str());
}
}
if (player)
{
group = player->GetGroup();
if (!guid || !offline)
guid = player->GetGUID();
}
else
{
if (getSelectedPlayer())
player = getSelectedPlayer();
else
player = m_session->GetPlayer();
if (!guid || !offline)
guid = player->GetGUID();
group = player->GetGroup();
}
return true;
}
示例10: getSelectedPlayer
bool ChatHandler::LockMove(char* args)
{
Player *player = getSelectedPlayer();
if (!player)
player = m_session->GetPlayer();
WorldPacket data;
data.Initialize( SMSG_FORCE_MOVE_ROOT );
data.appendPackGUID(player->GetGUID());
data << (uint32)2;
player->GetSession()->SendPacket( &data );
return true;
}
示例11: strtok
bool ChatHandler::HandleModifySpellCommand(const char* args)
{
WorldPacket data;
char* pspellflatid = strtok((char*)args, " ");
if (!pspellflatid)
return false;
char* pop = strtok(NULL, " ");
if (!pop)
return false;
char* pval = strtok(NULL, " ");
if (!pval)
return false;
uint16 mark;
char* pmark = strtok(NULL, " ");
uint8 spellflatid = atoi(pspellflatid);
uint8 op = atoi(pop);
uint16 val = atoi(pval);
if(!pmark)
mark = 65535;
else
mark = atoi(pmark);
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName());
char buf[256];
sprintf((char*)buf,LANG_YOURS_SPELLFLATID_CHANGED, m_session->GetPlayer()->GetName(), spellflatid, val, mark);
FillSystemMessageData(&data, m_session, buf);
chr->GetSession()->SendPacket(&data);
data.Initialize(SMSG_SET_FLAT_SPELL_MODIFIER);
data << uint8(spellflatid);
data << uint8(op);
data << uint16(val);
data << uint16(mark);
chr->GetSession()->SendPacket(&data);
return true;
}
示例12: extractPlayerNameFromLink
bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
{
if (args && *args)
{
std::string name = extractPlayerNameFromLink(args);
if (name.empty())
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
Player* pl = sObjectAccessor->FindPlayerByName(name);
// if allowed player pointer
if (player)
*player = pl;
// if need guid value from DB (in name case for check player existence)
uint64 guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : 0;
// if allowed player guid (if no then only online players allowed)
if (player_guid)
*player_guid = pl ? pl->GetGUID() : guid;
if (player_name)
*player_name = pl || guid ? name : "";
}
else
{
Player* pl = getSelectedPlayer();
// if allowed player pointer
if (player)
*player = pl;
// if allowed player guid (if no then only online players allowed)
if (player_guid)
*player_guid = pl ? pl->GetGUID() : 0;
if (player_name)
*player_name = pl ? pl->GetName() : "";
}
// some from req. data must be provided (note: name is empty if player not exist)
if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
return true;
}
示例13: atoi
bool ChatHandler::HandleTaxiCheatCommand(const char* args)
{
WorldPacket data;
if (!*args)
return false;
int flag = atoi((char*)args);
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
if (flag != 0)
PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName());
else
PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName());
char buf[256];
if (flag != 0)
{
sprintf((char*)buf,LANG_YOURS_TAXIS_ADDED,
m_session->GetPlayer()->GetName());
}
else
{
sprintf((char*)buf,LANG_YOURS_TAXIS_REMOVED,
m_session->GetPlayer()->GetName());
}
FillSystemMessageData(&data, m_session, buf);
chr->GetSession()->SendPacket(&data);
for (uint8 i=0; i<8; i++)
{
if (flag != 0)
{
m_session->GetPlayer()->SetTaximask(i, 0xFFFFFFFF);
}
else
{
m_session->GetPlayer()->SetTaximask(i, 0);
}
}
return true;
}
示例14: getSelectedPlayer
bool ChatHandler::HandleRecallCommand(const char* args)
{
Player* chr = NULL;
if(!*args)
{
chr = getSelectedPlayer();
if(!chr)
{
chr = m_session->GetPlayer();
if(chr->isInFlight())
{
SendSysMessage(LANG_YOU_IN_FLIGHT);
return true;
}
}
}
else
{
std::string name = args;
normalizePlayerName(name);
//sDatabase.escape_string(name); // prevent SQL injection - normal name don't must changed by this call
chr = objmgr.GetPlayer(name.c_str());
if(!chr)
{
PSendSysMessage(LANG_NO_PLAYER, args);
return true;
}
}
if(chr->IsBeingTeleported())
{
PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
return true;
}
if(chr->isInFlight())
{
PSendSysMessage(LANG_CHAR_IN_FLIGHT, chr->GetName());
return true;
}
chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
return true;
}
示例15: atoi
bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
{
uint32 titles = atoi((char*)args);
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
chr->SetUInt32Value(PLAYER_FIELD_KNOWN_TITLES, titles);
SendSysMessage(LANG_DONE);
return true;
}