Hey everyone, I’m fairly new to coding and Verse and would appreciate some help from the community
Basically, I’m trying to get ALL my Player’s/Team’s, score int values at once to be displayed in a leaderboard or Hud Message. I’m currently not using a Score tracker or score manager as I feel it should be all possible with Verse and I’m here to learn.
Here is some of the relevant code I’ve written so far, I want to make an expression that gets all the player’s score values on a loop so I can update a scoreboard as the game progresses.
Note some bits of code are not here like Subscribe events as they are irrelevant to the question
CustomPlayerVerse := class():
MyAgentObj:agent
Billboard: billboard_device
Sequencer: cinematic_sequence_device
HUD_Device: hud_message_device
var Team<private>:int = 1
var Score<private>:int = 0
SetTeam(T:int):void=
set Team = T
GetTeam():int=
return Team
SetScore(S:int):void=
set Score = S
GetScore():int=
return Score
GameManagerVerse := class(creative_device):
var PlayersMap:[agent]CustomPlayerVerse = map{}
OnBegin<override>()<suspends>:void=
OnP1Spawned(Agent:agent):void=
if (Player := player[Agent]):
InitPlayer(Agent, Billboard_P1, Sequencer_P1, HUD_Device_P1)
Reference_P1.Register(Agent)
UpdateBillboard(Agent)
OnP2Spawned(Agent:agent):void=
if (Player := player[Agent]):
InitPlayer(Agent, Billboard_P2, Sequencer_P2, HUD_Device_P2)
Reference_P2.Register(Agent)
UpdateBillboard(Agent)
#Initiate Player to CustomPlayerVerse Class
InitPlayer(Agent: agent, Billboard: billboard_device, Sequencer: cinematic_sequence_device, HUD_Device: hud_message_device):void=
if(PlayerExists:= PlayersMap[Agent]){} #Do nothing, player already exists
else:
if:
Player := player[Agent]
FC := Agent.GetFortCharacter[]
CP:CustomPlayerVerse = CustomPlayerVerse{
MyAgentObj := Agent,
Billboard := Billboard,
Sequencer := Sequencer,
HUD_Device := HUD_Device}
then:
if (set PlayersMap[Agent] = CP):
CP.Init()
FC.EliminatedEvent().Subscribe(OnPlayerEliminated)
option:
set PlayersMap[Agent] = CP
GetAllTeamScoresLoop()<suspends>:void=
AllPlayers := GetPlayspace().GetPlayers() ........
# Here is where I want to add new expression <-------
Thanks in advance