Player reboot implementation issue

I’ve implemented a player reboot mechanism, where every player has 2 reboots - which i track using a map.

For some specific players, it will consistently not work in game, they will not be respawned .
Even through different game sessions, those players will not reboot on elimination.
For most players, it will work every time.

The reboot function

   RebootPlayer(Player: player)<suspends>: void=

        PlayerRebootCount := RebootPerPlayer[Player] or 0

        if(PlayerRebootCount >= MAX_REBOOTS_PER_PLAYER):

            Print("Reboot - reached max reboots")

            return


        if(set RebootPerPlayer[Player] = PlayerRebootCount + 1) {}

        Sleep(1.0)

        

        RemainingReboots := MAX_REBOOTS_PER_PLAYER - PlayerRebootCount - 1

        TeleporterCount := RebootTeleporters.Length

        TeleportedIDX := GetRandomInt(0,TeleporterCount - 1)

        if:

            Teleporter := RebootTeleporters[TeleportedIDX]

        then:

            Player.Respawn(Teleporter.GetTransform().Translation, Teleporter.GetTransform().Rotation)

            Teleporter.Teleport(Player)

        else:

            Print("Reboot2 FAIL")

            AnalyticsDebugReboot1.Submit(Player)

The reason I’m teleporting after the respawn is to have the player sky dive into the map.
Any idea why this would consistently fail for specific players?

AnalyticsDebugReboot1.Submit(Player) - does not appear in my analytics.

Hello @King_Calculator how are you?

I’ve been checking and your code looks fine. It is probably an issue with the player not being active at the moment of respawning of teleporting it.

Are you getting the “Reboot2 FAIL” print?

You can check if the player is valid by adding the following code before “if(set RebootPerPlayer[Player] = PlayerRebootCount + 1) {}” and putting the rest of the funtion inside that check

if (Player.IsValid()):
    # the rest of your function here
else:
    Print("Reboot FAIL - invalid player reference")

It could be also a problem with the timing, maybe “Sleep(1.0)” is not enough.

Another thing you could try is to comment “Teleporter.Teleport(Player)” and check if it works only respawning the player but not teleporting it.

After those sugestions, I have a question that could help me understand the problem better: where are you calling this function?

Hope this helps you! I’ll be waiting for your answer!

Hey @BRGJuanCruzMK

Player.IsValid[] does not seem to be an existing API, we have Player.IsActive[] but I’m not sure it can verify the readiness of a player to be respawned/teleported/etc.

Player.IsActive[] - # Succeeds when this `player` may be used as a module-scoped `var` `weak_map` key. This coincides with the corresponding player having joined the game and not yet left. Using a `player` as a module-scope `var` `weak_map key when this method fails results in a runtime error.

>>Are you getting the “Reboot2 FAIL” print?

No - I can’t replicate the issue in development mode, only in published version, so i’ve added the analytics event (since Print is available in dev mode only) - that event has never registered.

ISSUE RESOLVED!
The issue was with the subscription to the player elimination event - it turn out that fort_character.EliminatedEvent will not be invoked in some cases of player elimination, depending on which weapon was used to get the elimination. For example the kinetic blade eliminations will not invoke the elimination event.

Switching to tracking eliminations using elimination_manager_device seem to have solved the issue.