Kill Tracker/Leaderboard

Status
Not open for further replies.
Level 2
Joined
Oct 2, 2021
Messages
10
Does anyone know why this leaderboard will not work (I kill a unit and number remains 0 on scoreboard)? I have tried following every tutorial I have found online to make a leaderboard and I'm not sure why this won't work. All human players are allies, the variables seem to be setup correctly, and the triggers seem like they should be working. I'm not sure what I'm missing here. The board is created after 5 seconds and looks fine, but then it doesn't update when a unit is killed.
This is the tutorial I found that seems so simple: Creating a Leaderboard
and yet it will not work. I tried it exactly as the tutorial said, but no luck, so I even added a variable for the leaderboard so that in the update trigger it directly references the leaderboard instead of 'last created leaderboard'
1634605449106.png
1634605464354.png

1634605617586.png

1634605512624.png

1634606374523.png

Just so you guys can see these three units were just killed, but leaderboard remains at 0 :(

Thank you for any help!
 

Attachments

  • 1634605483150.png
    1634605483150.png
    25.8 KB · Views: 19
Level 25
Joined
Mar 29, 2020
Messages
1,466
I think you added to the player number, not to the score. the +1 should be outside the square brackets that represents the array index .

I copied this from the tutorial you used. notice the difference in the first action between this and yours:

  • Trigger Tally Score
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) belongs to an ally of Player 1 (Red)) Equal to True
    • Actions
      • Set Player_Kills[(Player number of (Owner of (Killing unit)))] = (Player_Kills[(Player number of (Owner of (Killing unit)))] + 1)
      • Leaderboard - Change the value for (Owner of (Killing unit)) in (Last created leaderboard) to Player_Kills[(Player number of (Owner of (Killing unit)))]
      • Leaderboard - Sort (Last created leaderboard) by Value in Descending order
 
Level 2
Joined
Oct 2, 2021
Messages
10
I think you added to the player number, not to the score. the +1 should be outside the square brackets that represents the array index .

I copied this from the tutorial you used. notice the difference in the first action between this and yours:

  • Trigger Tally Score
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) belongs to an ally of Player 1 (Red)) Equal to True
    • Actions
      • Set Player_Kills[(Player number of (Owner of (Killing unit)))] = (Player_Kills[(Player number of (Owner of (Killing unit)))] + 1)
      • Leaderboard - Change the value for (Owner of (Killing unit)) in (Last created leaderboard) to Player_Kills[(Player number of (Owner of (Killing unit)))]
      • Leaderboard - Sort (Last created leaderboard) by Value in Descending order
You sir, were correct. I now see what I was doing wrong. I was putting the arithmetic on the second part of the trigger, I didn't even realize where that +1 was being applied until you pointed it out. Thanks for the reply, it's finally working like it's supposed to.
 
Status
Not open for further replies.
Top