[Problem] Leaderboard

Carnerox

The one and only.
Reaction score
84
I'm having a slight problem with my Leaderboard, it pretty much works but it only list one player and doesn't add any other Players to the Leaderboard besides Player(1).

+rep for who helps me. :thup:

Trigger:
  • Count Players
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Player Group - Pick each player in (Active Players) and do (Actions)
        • Actions
          • Variable - Modify Player Count: + 1
      • Trigger - Run Create Leaderboard (Ignore Conditions, Don't Wait until it finishes)


Trigger:
  • Create Leaderboard
    • Events
    • Local Variables
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard with 4 columns and (Player Count + 3) rows, with the name "Leaderboard", and using (100%, 100%, 100%) color.
      • Variable - Set Leaderboard = (Last created leaderboard)
      • Leaderboard - Set Leaderboard item text at column 1 and row 1 to "Players"
      • Leaderboard - Set Leaderboard item icon at column 1 and row 1 to Assets\Textures\btn-ability-terran-scannersweep-color.dds, placing it on the Left side of the text
      • Leaderboard - Set Leaderboard item text at column 2 and row 1 to "Minerals"
      • Leaderboard - Set Leaderboard item icon at column 2 and row 1 to Assets\Textures\icon-mineral.dds, placing it on the Left side of the text
      • Leaderboard - Set Leaderboard item text at column 3 and row 1 to "Kills"
      • Leaderboard - Set Leaderboard item icon at column 3 and row 1 to Assets\Textures\btn-ability-terran-snipe-color.dds, placing it on the Left side of the text
      • Leaderboard - Set Leaderboard item text at column 1 and row (Player Count + 2) to "Level:"
      • Leaderboard - Set Leaderboard item text at column 1 and row (Player Count + 3) to "Lives:"
      • Leaderboard - Set Leaderboard item text at column 2 and row (Player Count + 2) to (Text(Level))
      • Leaderboard - Set Leaderboard item text at column 2 and row (Player Count + 3) to (Text(Lives))
      • Timer - Start Update Timer as a Repeating timer that will expire in 0.04 AI Time seconds
      • Trigger - Turn Update Leaderboard On


Trigger:
  • Update Leaderboard
    • Events
      • Timer - Update Timer expires
    • Local Variables
      • Player = 1 <Integer>
      • Position = 2 <Integer>
    • Conditions
      • Not
        • Conditions
          • Player > Player Count
    • Actions
      • General - For each integer Player from 1 to Player Count with increment 1, do (Actions)
        • Actions
          • Leaderboard - Set Leaderboard item text at column 1 and row Position to (Text (Name of player Player) with color (Color((Current player Player color))))
          • Leaderboard - Set Leaderboard item text at column 2 and row Position to (Text((Player Player Minerals)))
          • Leaderboard - Set Leaderboard item text at column 3 and row Position to (Text(Kills[Player]))
      • Leaderboard - Set Leaderboard item text at column 2 and row (Player Count + 2) to (Text(Level))
      • Leaderboard - Set Leaderboard item text at column 2 and row (Player Count + 3) to (Text(Lives))
      • Variable - Modify Player: + 1
      • Variable - Modify Position: + 1


Variables:

Player Count = 0 <Integer>
Leaderboard = No Leaderboard <Leaderboard>
Update Timer = (New Timer) <Timer>
Kills = 0 <Integer[17]>
Lives = 40 <Integer>
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
In the For-loop in the periodic trigger you forget to add +1 to Position.
You do that after the loop finished, when the variable is not needed anymore.

So you're writing every player into the same row.

PS: I would like to point out that your trigger could behave strangely when players leave. Since you check whether Player > Player Count I guess that you subtract 1 from Player Count everytime a player leaves.
Consider you have players 1,2,3 and 4 in game. Now player 3 leaves the game. Your trigger will now only update 3 players - the FIRST 3 players. So the multiboard disregards player 4.

I would suggest you change your For-loop into a Pick-every-player-from-playergroup to prevent that. Then you don't even need Player Count anymore. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top