Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] is there a way to get the player object from a players name?

[DiscordArchive] is there a way to get the player object from a players name?

[DiscordArchive] is there a way to get the player object from a players name?

rektbyfaith
Administrator
0
08-14-2022, 05:37 PM
#1
Archived author: Pandaros • Posted: 2022-08-14T17:37:35.525000+00:00
Original source

is there a way to get the player object from a players name?
rektbyfaith
08-14-2022, 05:37 PM #1

Archived author: Pandaros • Posted: 2022-08-14T17:37:35.525000+00:00
Original source

is there a way to get the player object from a players name?

rektbyfaith
Administrator
0
08-14-2022, 05:42 PM
#2
Archived author: Pandaros • Posted: 2022-08-14T17:42:16.936000+00:00
Original source

```
Player* World::FindPlayerInZone(uint32 zone)
{
///- circle through active sessions and return the first player found in the zone
SessionMap::const_iterator itr;
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
{
if (!itr->second)
continue;

Player* player = itr->second->GetPlayer();
if (!player)
continue;

if (player->IsInWorld() && player->GetZoneId() == zone)
return player;
}
return nullptr;
}
```

Why is there code that loops over everything rather than maintaining a map? what if theres 1000s of players?
rektbyfaith
08-14-2022, 05:42 PM #2

Archived author: Pandaros • Posted: 2022-08-14T17:42:16.936000+00:00
Original source

```
Player* World::FindPlayerInZone(uint32 zone)
{
///- circle through active sessions and return the first player found in the zone
SessionMap::const_iterator itr;
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
{
if (!itr->second)
continue;

Player* player = itr->second->GetPlayer();
if (!player)
continue;

if (player->IsInWorld() && player->GetZoneId() == zone)
return player;
}
return nullptr;
}
```

Why is there code that loops over everything rather than maintaining a map? what if theres 1000s of players?

rektbyfaith
Administrator
0
08-14-2022, 05:42 PM
#3
Archived author: Pandaros • Posted: 2022-08-14T17:42:48.730000+00:00
Original source

the would be much more efficient with indexing
rektbyfaith
08-14-2022, 05:42 PM #3

Archived author: Pandaros • Posted: 2022-08-14T17:42:48.730000+00:00
Original source

the would be much more efficient with indexing

rektbyfaith
Administrator
0
08-14-2022, 05:42 PM
#4
Archived author: Revision • Posted: 2022-08-14T17:42:49.710000+00:00
Original source

It stops at the first one it finds
rektbyfaith
08-14-2022, 05:42 PM #4

Archived author: Revision • Posted: 2022-08-14T17:42:49.710000+00:00
Original source

It stops at the first one it finds

rektbyfaith
Administrator
0
08-14-2022, 06:32 PM
#5
Archived author: Nyeriah • Posted: 2022-08-14T18:32:34.669000+00:00
Original source

why'd you need to find it by name specifically? you can find them by guid
rektbyfaith
08-14-2022, 06:32 PM #5

Archived author: Nyeriah • Posted: 2022-08-14T18:32:34.669000+00:00
Original source

why'd you need to find it by name specifically? you can find them by guid

rektbyfaith
Administrator
0
08-14-2022, 06:32 PM
#6
Archived author: Nyeriah • Posted: 2022-08-14T18:32:46.373000+00:00
Original source

you can get their guid through their name
rektbyfaith
08-14-2022, 06:32 PM #6

Archived author: Nyeriah • Posted: 2022-08-14T18:32:46.373000+00:00
Original source

you can get their guid through their name

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)