Verse Library verse

09 Reset Round Info On Player Leaving

Tracks player finish order and updates round state when players leave during a match.

extracted-snippets/documentation/en-us/uefn/custom-round-logic-using-verse/09-reset-round-info-on-player-leaving.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/custom-round-logic-using-verse
# Local doc:  epic-docs/documentation/en-us/uefn/custom-round-logic-using-verse.md
# Section:    Reset Round Info on Player Leaving
# A Verse-authored creative device that can be placed in a level
test_round_info_device := class(creative_device):
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
GetPlayspace().PlayerRemovedEvent().Subscribe(OnPlayerRemoved)
Players := GetPlayspace().GetPlayers()
CurrentRound := GetLastCompletedRound(Players) + 1
Print("Current round is {CurrentRound}")
for:
Index -> Player : Players
RecordPlayerFinishOrder(Player, Index)
UpdateRound(Player, CurrentRound)
do:
Print("Recorded finish order {Index} and current round {CurrentRound} for player")

Comments

    Sign in to vote, comment, or suggest an edit. Sign in