Score Manager Issue or?

Hi All,

I’m having an issue with the Score Manager and can’t seem to get past it. It’s either a bug or I’m doing something super obviously wrong that I can’t see it with my limited Verse knowledge.

Here’s my isolated code (I have this issue replicating in a much wider scope in another project and it’s causing me so much grief):

hello_world_device := class(creative_device):

@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<override>()<suspends>:void=
    
    PopulatePlayers()

As far as I can see - Score should print with the 1000 value. But it prints back with Zero value, however the Scoreboard (Map Key in game) and the Score Manager device (phyiscally in game) show 1000.

What is happening?

Thank you in advance.


Assuming this is a bug? It should be giving me the score back in the variable - right?

I believe you should wait a frame before retrieving the actual score.

Add the <suspends> specifier to your PopulatePlayers() function, then add a Sleep(0.0) before the print

Executing an unknown function (like the ones Epic provides) doesn’t mean it works immediately or that it works at all, like with every function of every devices, you need to not believe what you see and test things by yourself.

But maybe you just didn’t know about Sleep(), well don’t forget about this trick, it will save you multiple times!

Thanks for the reply. It is an issue with the Score Manager (or a misunderstanding of what it should be)… essentially the Score Manager will only give you Round Score back - not Game Score… so if you have a game with multiple Rounds, after the first round the Score Manager and Hud Info Type Widget can’t get the whole score but only the score from inside that round.

Would make more sense to have Round Score coming out of the Round Manager, and Game Score coming out of the Score Manager (or both available from Score Manager)