How to identify player sending RaiseEvent - OnEvent

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to identify player sending RaiseEvent - OnEvent

denmla1000
2019-10-01 07:35:47

Player sends RaiseEvent to all players.
How to know who sent this through OnEvent(EventData)?
I can send LocalPlayer object via eventContent but i guess there is a simpler way

Comments

JohnTube
2019-10-01 09:55:11

Hi @denmla1000,

Use EventData.Sender.
If it's 0 then it's the server.
If it's not 0 then it is an actor number. Get the player by its actor number using Room.GetPlayer(int).

denmla1000
2019-10-02 08:44:53

Thanks.
You mean Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(int) or some other Room?

JohnTube
2019-10-02 10:38:55

Yes.

Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(int)

Back to top