Any way to get the local player?

Imagine the following custom device:


race_device := class(creative_device):

    @editable
    RaceManagerDevice : race_manager_device = race_manager_device{}

    OnBegin<override>()<suspends> : void =
        RaceManagerDevice.RaceBeganEvent.Subscribe(HandleRaceBeganEvent)

    HandleRaceBeganEvent(Agent : agent) : void =
        # called for every participating player on every client

If this is tested on a published island with two players, then HandleRaceBeganEvent will be called twice on each client. Is there any way to figure which of those two calls is for local player?

In other words, is there any way to know which of the players from the playspace is the player on the client that runs that instance of the code?

For example, Pete and Steve want to play UEFN game and they both connect. Pete is on computer X and Steve is on computer Y. Verse code will execute on each computer. (Or is it server side execution??) On the code instance running on X, I expect to get info that Pete is local player and respective info on computer Y.

I dont’t know but I guess there is no way. Cause how would this work in a published version of the map where there is thing as local player

1 Like

I’m pretty sure the code is executed server side, so there’s no local player running an instance of the code.

You have to store the players in a map{} for example and compare them for your use, what are you trying to achieve exactly ?

3 Likes

Yes, that was it. I was wrongly assuming that the code runs client side and that made me suffer for a few days lol

I did as suggested: create a map of agent->my_custom_class that contains player-related data and logic and that works now.

Thanks a bunch!

1 Like