# How can you store update the player list if a player joins the game?

**URL:** <https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [April 18, 2023, 6:10pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889 "2023-04-18T18:10:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [April 18, 2023, 6:10pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/1 "2023-04-18T18:10:25Z")

</div>

Hi!

I have this code for a Gun Game:

```auto
 InitPlayers<public>(Agent : ?agent) : void =
        AllPlayers := GetPlayspace().GetPlayers()
        for (Player : AllPlayers, FortCharacter := Player.GetFortCharacter[]):
            if (set PlayerMap[Player] = 0, WeaponTier := PlayerMap[Player]):
                Print("Storing players")
                FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
                Print("Respawning Players, disabling old Spawners")
                DisableLobbySpawns()
                EnableGunGameSpawns()
                #Eliminate player to respawn in the new location
                FortCharacter.Damage(9999.00)
                Print("Trying to GrantWeapon()")
                GrantWeapon(Player, WeaponTier)

```

The Gun Game is working perfectly if all the players are in the pre-lobby, but there is a problem because the players are being stored and subscribing to the event at the begining of the game, so if a player joins in the middle of a game will be not be stored.

There is any function to check if a player joins into the game?

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [April 19, 2023, 10:34pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/2 "2023-04-19T22:34:04Z")

</div>

Self.GetPlayspace().PlayerAddedEvent().Subscribe(myfunction)

---

<div class="post-metadata">

**Author:** ![CosmicDanAU](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cosmicdanau/32/642728_2.png) [@CosmicDanAU](https://forums.unrealengine.com/u/CosmicDanAU)\
**Post date:** [April 20, 2023, 3:56am UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/3 "2023-04-20T03:56:15Z")

</div>

As mentioned, you need to use events for this. Events are how you make your code react to things happening in the game, I highly suggest reading the Verse docs and some of the Verse tutorials for learning how to use them.

For this particular example - keeping track of all players that are added/removed - this particular UEFN tutorial will be of help: [Team Elimination Game](https://dev.epicgames.com/documentation/en-us/uefn/team-elimination-game-in-verse)

EDIT: Apologies if patronizing, you clearly already know how to code - maybe all you needed to know was that Verse/UEFN is Event-based 🙂 if so, do make yourself familiar with all Events - since they’re a pretty major entrypoint for doing your Verse stuff it’s good to keep aware of them. There aren’t so many Events right now but that number will surely grow.

---

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [April 20, 2023, 12:01pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/4 "2023-04-20T12:01:35Z")

</div>

Yes, I was trying to find the function that JoeriDukker says \<3

---

<div class="post-metadata">

**Author:** ![b3rtl3d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@b3rtl3d](https://forums.unrealengine.com/u/b3rtl3d)\
**Post date:** [June 5, 2023, 4:04pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/5 "2023-06-05T16:04:01Z")

</div>

I’m curious how you did your “OnPlayerEliminated”. My gun game unintentionally cycles the player to the next weapon if the player eliminates themselves (fall damage for example without anyone else having already damaged them)! By checking if the eliminator is a fortcharacter I thought it would only promote the player to the next level when another actual player was the eliminator.

OnPlayerEliminated(Result : elimination\_result) : void=  
Eliminator := Result.EliminatingCharacter  
If (FortCharacter := Eliminator?, EliminatingAgent := FortCharacter.GetAgent[]):  
PromotePlayer(FortCharacter, EliminatingAgent)

---

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [June 6, 2023, 7:23pm UTC](https://forums.unrealengine.com/t/how-can-you-store-update-the-player-list-if-a-player-joins-the-game/1115889/6 "2023-06-06T19:23:48Z")

</div>

I just check if the eliminator is the same as the eliminated agent. It works in my gun game

```auto
 OnPlayerEliminated(Result : elimination_result) : void =
        Eliminator := Result.EliminatingCharacter
        Eliminated := Result.EliminatedCharacter

        if (EliminatingFortCharacter := Eliminator?, EliminatingAgent := EliminatingFortCharacter.GetAgent[]):
            if (EliminatedFortCharacter := Eliminated, EliminatedAgent := EliminatedFortCharacter.GetAgent[]):
                    if(EliminatedAgent<>EliminatingAgent):
                        Print("We need to promote player")
                        PromotePlayer(EliminatingAgent)
                        HealPlayer(EliminatingFortCharacter)
                        Print("The Player has been Promoted")
                    else:
                        Print("Error promoting the player: Eliminator and Elimitated are the SAME PLAYER")

```

@b3rtl3d
