• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] [C++] get Player Object by GUID

Status
Not open for further replies.

Rozz

Emulation Addict
Hi,

I must call the player object (other players in world) by their guid.
I've tried it like this:

Code:
uint32 PlayerGUID = XXX;
Player *pPlayer = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, PlayerGUID));
pPlayer ->TeleportTo();

can someone help me?
 
Last edited:

Rozz

Emulation Addict
i want to teleport some random player in the world.
I've stored their guid's in an array

I've tried it so:
Code:
for(i=0; i < maxPlayers; i++)
{
		if(Players[i] != 0)
		{
                  uint32 PlayerGUID = Players[i];
                  Player *pPlayer = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, PlayerGUID));
                  pPlayer ->TeleportTo();;
		}
}
 

Kaev

Super Moderator
Instead of iterating through every GUID, you could just iterate through all online players. You could port him with the player object then.

Code:
SessionMap sessions = sWorld->GetAllSessions();
for( SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr )
{
	if( !itr->second )
		continue;

	Player *plr = itr->second->GetPlayer();
	plr->TeleportTo();
}

if you still want to search by GUID, look at this: http://emudevs.com/showthread.php/3843-Wotlk-Cata-Reset-player-Cooldown-on-boss-kill (Open the link, look at the PlayerIsInGroup function)
 
Last edited:
Status
Not open for further replies.
Top