本文整理汇总了C++中getSelectedPlayer函数的典型用法代码示例。如果您正苦于以下问题:C++ getSelectedPlayer函数的具体用法?C++ getSelectedPlayer怎么用?C++ getSelectedPlayer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSelectedPlayer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:BlackWolfsDen,项目名称:Justicar-WoW,代码行数:29,代码来源:Level2.cpp
示例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;
}
开发者ID:Deviuss,项目名称:TrinityCore,代码行数:29,代码来源:Level0.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:33,代码来源:Level1.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:35,代码来源:Level2.cpp
示例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);
}
开发者ID:aedansilver,项目名称:CzechFunCore,代码行数:29,代码来源:Level2.cpp
示例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;
}
开发者ID:sanysan,项目名称:ChaosCore-1,代码行数:27,代码来源:Level2.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:34,代码来源:Level1.cpp
示例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;
}
}
开发者ID:mierzc,项目名称:mangos-tbc,代码行数:32,代码来源:LevelCustom.cpp
示例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;
}
开发者ID:cooler-SAI,项目名称:ElunaTrinityWotlk,代码行数:43,代码来源:Chat.cpp
示例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;
}
开发者ID:lauwdude,项目名称:mangos,代码行数:12,代码来源:Level_pe.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:53,代码来源:Level1.cpp
示例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;
}
开发者ID:MiranaStarlight,项目名称:TrinityCore,代码行数:52,代码来源:Chat.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:50,代码来源:Level1.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:49,代码来源:Level1.cpp
示例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;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:16,代码来源:Level1.cpp
示例16: SendSysMessage
bool ChatHandler::HandleModifyASpeedCommand(const char* args)
{
if (!*args)
return false;
float ASpeed = (float)atof((char*)args);
if (ASpeed > 10 || ASpeed < 0.1)
{
SendSysMessage(LANG_BAD_VALUE);
return true;
}
Player *chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
return true;
}
if(chr->isInFlight())
{
PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
return true;
}
PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName());
WorldPacket data;
char buf[256];
sprintf((char*)buf,LANG_YOURS_ASPEED_CHANGED, m_session->GetPlayer()->GetName(), ASpeed);
FillSystemMessageData(&data, m_session, buf);
chr->GetSession()->SendPacket(&data);
chr->SetSpeed(MOVE_WALK, ASpeed,true);
chr->SetSpeed(MOVE_RUN, ASpeed,true);
chr->SetSpeed(MOVE_WALKBACK,ASpeed,true);
chr->SetSpeed(MOVE_SWIM, ASpeed,true);
chr->SetSpeed(MOVE_SWIMBACK,ASpeed,true);
//chr->SetSpeed(MOVE_TURN, ASpeed,true);
chr->SetSpeed(MOVE_FLY, ASpeed,true);
return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:44,代码来源:Level1.cpp
示例17: SendSysMessage
//Enable On\OFF all taxi paths
bool ChatHandler::HandleTaxiCheatCommand(const char* args)
{
if (!*args)
{
SendSysMessage(LANG_USE_BOL);
SetSentErrorMessage(true);
return false;
}
std::string argstr = (char*)args;
Player *chr = getSelectedPlayer();
if (!chr)
{
chr=m_session->GetPlayer();
}
// check online security
else if (HasLowerSecurity(chr, 0))
return false;
if (argstr == "on")
{
chr->SetTaxiCheater(true);
PSendSysMessage(LANG_YOU_GIVE_TAXIS, GetNameLink(chr).c_str());
if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str());
return true;
}
if (argstr == "off")
{
chr->SetTaxiCheater(false);
PSendSysMessage(LANG_YOU_REMOVE_TAXIS, GetNameLink(chr).c_str());
if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str());
return true;
}
SendSysMessage(LANG_USE_BOL);
SetSentErrorMessage(true);
return false;
}
开发者ID:Nedj,项目名称:TrinityCore,代码行数:45,代码来源:Level1.cpp
示例18: HandleSaveCommand
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
{
Player* player = m_session->GetPlayer();
// save GM account without delay and output message
if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity()))
{
if (Player* target = getSelectedPlayer())
target->SaveToDB();
else
player->SaveToDB();
SendSysMessage(LANGUAGE_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;
}
开发者ID:Ervzz,项目名称:SkyFireEMU_406a,代码行数:22,代码来源:Level0.cpp
示例19: HandleSaveCommand
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
{
Player* player = m_session->GetPlayer();
// save GM account without delay and output message (testing, etc)
if (m_session->GetSecurity())
{
if (Player* target = getSelectedPlayer())
target->SaveToDB();
else
player->SaveToDB();
SendSysMessage(LANG_PLAYER_SAVED);
return true;
}
// save or plan save after 20 sec (logout delay) if current next save time more this value and _not_ output any messages to prevent cheat planning
uint32 save_interval = sWorld.getConfig(CONFIG_INTERVAL_SAVE);
if (save_interval == 0 || (save_interval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20 * IN_MILLISECONDS))
player->SaveToDB();
return true;
}
开发者ID:Aminxhm,项目名称:OregonCore,代码行数:22,代码来源:Level0.cpp
示例20: strtok
bool ChatHandler::HandlePInfoCommand(const char* args)
{
Player* target = NULL;
uint64 targetGUID = 0;
char* px = strtok((char*)args, " ");
char* py = NULL;
std::string name;
if (px)
{
name = px;
normalizePlayerName(name);
target = objmgr.GetPlayer(name.c_str());
if (target)
py = strtok(NULL, " ");
else
{
targetGUID = objmgr.GetPlayerGUIDByName(name.c_str());
if(targetGUID)
py = strtok(NULL, " ");
else
py = px;
}
}
if(!target && !targetGUID)
{
target = getSelectedPlayer();
}
if(!target && !targetGUID)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
return true;
}
uint32 accId = 0;
uint32 money = 0;
uint32 total_player_time = 0;
uint32 level = 0;
// get additional information from Player object
if(target)
{
targetGUID = target->GetGUID();
name = target->GetName(); // re-read for case getSelectedPlayer() target
accId = target->GetSession()->GetAccountId();
money = target->GetMoney();
total_player_time = target->GetTotalPlayedTime();
level = target->getLevel();
}
// get additional information from DB
else
{
accId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
Player plr(m_session); // use current session for temporary load
plr.MinimalLoadFromDB(targetGUID);
money = plr.GetMoney();
total_player_time = plr.GetTotalPlayedTime();
level = plr.getLevel();
}
std::string username = "<error>";
std::string last_ip = "<error>";
uint32 security = 0;
QueryResult* result = loginDatabase.PQuery("SELECT `username`,`gmlevel`,`last_ip` FROM `account` WHERE `id` = '%u'",accId);
if(result)
{
Field* fields = result->Fetch();
username = fields[0].GetCppString();
security = fields[1].GetUInt32();
if(m_session->GetSecurity() >= security)
last_ip = fields[2].GetCppString();
else
last_ip = "-";
delete result;
}
PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":"(offline)"), name.c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, security, last_ip.c_str());
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, timeStr.c_str(), level, gold,silv,copp );
if ( py && strncmp(py, "rep", 3) == 0 )
{
if(!target)
{
// rep option not implemented for offline case
SendSysMessage(LANG_PINFO_NO_REP);
return true;
}
static const char* ReputationRankStr[MAX_REPUTATION_RANK] = {"Hated", "Hostile", "Unfriendly", "Neutral", "Friendly", "Honored", "Reverted", "Exalted"};
//.........这里部分代码省略.........
开发者ID:chrayn,项目名称:mangos-06,代码行数:101,代码来源:Level2.cpp
注:本文中的getSelectedPlayer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论