//Teleport to Playerbool ChatHandler::HandleGonameCommand(const char* args){ if(!*args) return false; Player* _player = m_session->GetPlayer(); if(_player->isInFlight()) { SendSysMessage(LANG_YOU_IN_FLIGHT); return true; } std::string name = args; normalizePlayerName(name); //sDatabase.escape_string(name); // prevent SQL injection - normal name don't must changed by this call Player *chr = objmgr.GetPlayer(name.c_str()); if (chr) { if (MapManager::Instance().GetMap(chr->GetMapId(), chr)->Instanceable()) { if ( (MapManager::Instance().GetMap(_player->GetMapId(), _player)->Instanceable()) && (MapManager::Instance().GetMap(chr->GetMapId(), chr)->GetInstanceId() != MapManager::Instance().GetMap(_player->GetMapId(), _player)->GetInstanceId()) ) { // cannot go from instance to instance PSendSysMessage(LANG_CANNOT_GO_INST_INST,chr->GetName()); return true; } // 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() != chr->GetGroup()) { PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName()); return true; } } else { // we are not in group, let's verify our GM mode if (!_player->isGameMaster()) { PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName()); return true; } } // bind us to the players instance BoundInstancesMap::iterator i = chr->m_BoundInstances.find(chr->GetMapId()); // error, the player has no instance bound!!! if (i == chr->m_BoundInstances.end()) return true; _player->m_BoundInstances[chr->GetMapId()] = std::pair < uint32, uint32 >(i->second.first, i->second.second); _player->SetInstanceId(chr->GetInstanceId()); } PSendSysMessage(LANG_APPEARING_AT, chr->GetName()); if (_player->IsVisibleGloballyFor(chr)) { char buf0[256]; sprintf((char*)buf0,LANG_APPEARING_TO, _player->GetName()); WorldPacket data; FillSystemMessageData(&data, m_session, buf0); chr->GetSession()->SendPacket(&data); } _player->SetRecallPosition(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation()); // to point to see at target with same orientation float x,y,z; chr->GetContactPoint(m_session->GetPlayer(),x,y,z); _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), true, true, true); return true; } if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) { PSendSysMessage(LANG_APPEARING_AT, name.c_str()); // to point where player stay (if loaded) float x,y,z,o; uint32 map; if(Player::LoadPositionFromDB(map,x,y,z,o,guid)) { _player->SetRecallPosition(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation()); _player->TeleportTo(map, x, y, z,_player->GetOrientation()); return true; } } PSendSysMessage(LANG_NO_PLAYER, args); return true;}