Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] Is there a way to fetch a valid player object across maps? It seems that when a player casts a spell

[DiscordArchive] Is there a way to fetch a valid player object across maps? It seems that when a player casts a spell

[DiscordArchive] Is there a way to fetch a valid player object across maps? It seems that when a player casts a spell

rektbyfaith
Administrator
0
12-09-2024, 10:49 AM
#1
Archived author: Qeme • Posted: 2024-12-09T10:49:51.841000+00:00
Original source

Is there a way to fetch a valid player object across maps? It seems that when a player casts a spell and their target is on a different map, the server doesn't recognize the target or provide access to their Player object. For example, calling GetSelectedPlayer() or similar methods fails. How can I reliably fetch the target player object across maps? Is there an alternative approach or workaround to handle such cases?
rektbyfaith
12-09-2024, 10:49 AM #1

Archived author: Qeme • Posted: 2024-12-09T10:49:51.841000+00:00
Original source

Is there a way to fetch a valid player object across maps? It seems that when a player casts a spell and their target is on a different map, the server doesn't recognize the target or provide access to their Player object. For example, calling GetSelectedPlayer() or similar methods fails. How can I reliably fetch the target player object across maps? Is there an alternative approach or workaround to handle such cases?

rektbyfaith
Administrator
0
12-09-2024, 11:03 AM
#2
Archived author: Nyeriah • Posted: 2024-12-09T11:03:25.758000+00:00
Original source

FindConnectedPlayer()
rektbyfaith
12-09-2024, 11:03 AM #2

Archived author: Nyeriah • Posted: 2024-12-09T11:03:25.758000+00:00
Original source

FindConnectedPlayer()

rektbyfaith
Administrator
0
12-09-2024, 11:30 AM
#3
Archived author: walkline • Posted: 2024-12-09T11:30:51.918000+00:00
Original source

If you want to access a player from another map while you are in the map thread, make sure you understand what you are doing, as it can lead to a race condition.
rektbyfaith
12-09-2024, 11:30 AM #3

Archived author: walkline • Posted: 2024-12-09T11:30:51.918000+00:00
Original source

If you want to access a player from another map while you are in the map thread, make sure you understand what you are doing, as it can lead to a race condition.

rektbyfaith
Administrator
0
12-09-2024, 11:52 AM
#4
Archived author: Qeme • Posted: 2024-12-09T11:52:25.539000+00:00
Original source

Thank you both
rektbyfaith
12-09-2024, 11:52 AM #4

Archived author: Qeme • Posted: 2024-12-09T11:52:25.539000+00:00
Original source

Thank you both

rektbyfaith
Administrator
0
12-09-2024, 12:16 PM
#5
Archived author: Qeme • Posted: 2024-12-09T12:16:10.552000+00:00
Original source

Yeah I still can't get the object across maps. To use FindConnectedPlayer I need their GUID, I can't get the target GUID because there is no target object when the player is on a different map.

I guess I'm having the same issue as with the .appear command. If you are not on the same map, you'll need to provide the players name.

https://github.com/azerothcore/azerothco...c.cpp#L737
rektbyfaith
12-09-2024, 12:16 PM #5

Archived author: Qeme • Posted: 2024-12-09T12:16:10.552000+00:00
Original source

Yeah I still can't get the object across maps. To use FindConnectedPlayer I need their GUID, I can't get the target GUID because there is no target object when the player is on a different map.

I guess I'm having the same issue as with the .appear command. If you are not on the same map, you'll need to provide the players name.

https://github.com/azerothcore/azerothco...c.cpp#L737

rektbyfaith
Administrator
0
12-09-2024, 12:19 PM
#6
Archived author: Qeme • Posted: 2024-12-09T12:19:36.156000+00:00
Original source

Basically, I am trying to cast a spell on a party member, when that party member is the players target, regardless of range or map.
rektbyfaith
12-09-2024, 12:19 PM #6

Archived author: Qeme • Posted: 2024-12-09T12:19:36.156000+00:00
Original source

Basically, I am trying to cast a spell on a party member, when that party member is the players target, regardless of range or map.

rektbyfaith
Administrator
0
12-09-2024, 12:20 PM
#7
Archived author: Qeme • Posted: 2024-12-09T12:20:44.419000+00:00
Original source

I can't do it with a spell script either, because the target is invalid if they're not on the same map.
rektbyfaith
12-09-2024, 12:20 PM #7

Archived author: Qeme • Posted: 2024-12-09T12:20:44.419000+00:00
Original source

I can't do it with a spell script either, because the target is invalid if they're not on the same map.

rektbyfaith
Administrator
0
12-09-2024, 01:20 PM
#8
Archived author: Takenbacon • Posted: 2024-12-09T13:20:57.335000+00:00
Original source

You can hook into the set_selection opcode which is called when you change your target, this also gives you the ObjectGuid of said target as well.

As already mentioned, this opcode and most other ways you'd accomplish this is going to be unsafe for the servers threading model - you may run into occasional undefined behavior (including crashes).
rektbyfaith
12-09-2024, 01:20 PM #8

Archived author: Takenbacon • Posted: 2024-12-09T13:20:57.335000+00:00
Original source

You can hook into the set_selection opcode which is called when you change your target, this also gives you the ObjectGuid of said target as well.

As already mentioned, this opcode and most other ways you'd accomplish this is going to be unsafe for the servers threading model - you may run into occasional undefined behavior (including crashes).

rektbyfaith
Administrator
0
12-09-2024, 01:22 PM
#9
Archived author: Takenbacon • Posted: 2024-12-09T13:22:56.814000+00:00
Original source

A relatively simple fix would be to change the processing status of the set selection opcode to process_threadsafe
rektbyfaith
12-09-2024, 01:22 PM #9

Archived author: Takenbacon • Posted: 2024-12-09T13:22:56.814000+00:00
Original source

A relatively simple fix would be to change the processing status of the set selection opcode to process_threadsafe

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