@editable var SM : score_manager_device = score_manager_device{}
var Score : int = 0
var ScoreDefault : int = 1000
PopulatePlayers() : void=
Print(“Beginning to populate players”)
AllPlayers := GetPlayspace().GetPlayers()
for (Agent : AllPlayers, Player := player[Agent], FortCharacter := Player.GetFortCharacter):
SM.SetScoreAward(ScoreDefault)
SM.Activate(Agent)
set Score = SM.GetCurrentScore(Agent)
Print(“Player loaded score is {Score}”)
Runs when the device is started in a running game
OnBegin():void=
PopulatePlayers()
Expected Result
The “var score” should return 1000. It returns zero - but the scoreboard on the map key and the HUD widget for Score from IslandSettings return the correct 1000 value.
And then build verse → in editor, locate your custom verse device → select the score manager device from the drop-down in the Details tab → save and push
put Sleep(0.1) after setting all those scores maybe. You’re running it in an immediate loop and I think the devices struggle with that sometimes. You’ll have to your function and spawn it, but I believe it will solve your problem
Thanks GraemeBB. I’m a big follower of your work (assuming you’re the same Graeme from YouTube :)). So I’ve tried this which is my (limited) understanding of what you’ve put:
game_manager := class(creative_device):
var Score : int = 0
GetScore(Agent:agent)<suspends>:void=
set Score = ScoreManager.GetCurrentScore(Agent)
Sleep(0.5)
OnBegin<override>()<suspends>:void=
UpdateScore():void=
for(Player:PlayersMap):
spawn{GetScore(Player.MyAgentObj)}
Player.UpdateScore(Score)
That will not return to me the Score in the variable - but the Scoreboard on the map key continues to function correctly for my SetScoreAward and Activate events for the Agent. I just for some reason cannot get the ScoreManager to give me the GetCurrentScore back for the Agent.
Is it possible for you to give me an example of how you have it? Perhaps I’m misunderstanding how to use this device - but the GetCurrentScore information on Epic’s website says that if I call it with (Agent) then it will return an :int that is the Agent’s current score.
Thanks GraemeBB. Still doesn’t give me the value back… I remember one of your videos saying about "Setters’ and “Getters” so I created this:
game_manager := class(creative_device):
var DefaultScore : int = 10
var Score : int = 0
GetScore(Agent:agent)<suspends>:void=
Sleep(0.5)
set Score = ScoreManagerAdd.GetCurrentScore(Agent)
Sleep(0.5)
SetScore(Agent:agent, ScoreToSet:int)<suspends>:void=
Sleep(0.5)
ScoreManagerAdd.SetScoreAward(ScoreToSet)
ScoreManagerAdd.Activate(Agent)
Sleep(0.5)
OnBegin<override>()<suspends>:void=
… You’ll recognise the code before this…
NewCustomPlayer:CustomPlayer = CustomPlayer{MyAgentObj:=Agent}
if(set PlayersMap[PlayerObj] = NewCustomPlayer):
spawn{GetScore(Agent)}
if(Score = 0):
Print("Player was loaded as NEW PLAYER")
spawn{SetScore(Agent, DefaultScore)}
spawn{GetScore(Agent)}
NewCustomPlayer.InitPlayer(Score)
It prints and returns the score var back as 0. I just don’t understand how this is not a bug? It shouldn’t be this difficult just to get the current score of the Agent when you pass in SM.GetCurrentScore(Agent) - surely?
OK - so digging further into this issue today, the problem appears to be that the Score Manager cannot return the Score for the Game, and instead can only function on a per-round basis.
So: I can use GetCurrentScore and loop it as Graeme noted, and that will return me for the Scorechanges in the current round.
When the next round starts, that value then gets wiped back to zero (along with the Hud widget from IslandSettings) whilst the M-key Scoreboard continues to hold the score for the Game (which is the Score that I want the Score Manager to return to me so I can align with the Hud widget).
There needs to be a GetRoundCurrentScore and GetGameCurrentScore. The Game Score is also the one that the Save device is holding onto making it even more frustrating.
The only way to save score is with the save device, but supposedly that’s not quite working for score? not sure, but some have reported that, I haven’t tested myself as I have no need for that in the maps I’m working on
Well - it doesn’t return the Score, it just returns the Round Score. So after 1 round the Scoreboard is out of sync (without any code - even the widget from Hud Info Type resets). Doesn’t make sense why it can only manage a round when it’s a score manager? This functionality makes more sense in the Round Manager (if you wanted Round specific score).
To me - Score Manager should return the Game Score.
Can someone from Staff please acknowledge this and/or give feedback? It feels like the Score Manager device should be getting the Game Score for the player - not just the round score.
As it stands GetCurrentScore will not return the Game Score (the Map key allows for it to be shown in the player table). The HUD widget also only follows the Round Score and not the Game Score. This must be broken (unless there is another way to get Game Score?)