Tracking Players Using Maps in Verse
You're going to use a map to track the number of eliminations a player has scored. Maps provide a handy association of keys to values, and in this tutorial, you’ll use the player as the key and their associated weapon tier (represented as an int) as the value. That way, you can retrieve a player’s current tier given just a reference to the player. An example of how a map of player-to-weapon tier associations might look is provided below.
| Key | player 1 | player 2 | player 3 |
| Value | 1 | 2 | 2 |
| Weapon in Game | Combat Pistol L1 | Flint-Knock Pistol L1 | Flint-Knock Pistol L1 |
Follow these steps to set up and populate your map of players:
-
Add
[player]intmap namedPlayerMapto theteam_elimination_gameclass. This stores a reference to each player and their weapon tier.Verse
| | | | --- | --- | | | team_elimination_game := class(creative_device): | | | var PlayerMap : [player]int = map{} |team_elimination_game := class(creative_device): var PlayerMap : [player]int = map{}
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.