• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Leaderboard problem

Status
Not open for further replies.
Level 7
Joined
Feb 18, 2007
Messages
216
So here's my leaderboard which shows kills of all players:
  • Scoreboard
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard for (All players) titled Kills
      • Set board = (Last created leaderboard)
      • Player Group - Pick every player in (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User))) and do (Leaderboard - Add (Picked player) to board with label (Name of (Picked player)) and value kills[(Player number of (Picked player))])
  • Kill
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) belongs to an enemy of (Owner of (Dying unit))) Equal to True
    • Actions
      • Set kills[(Player number of (Owner of (Killing unit)))] = kills[((Player number of (Owner of (Killing unit))) + 1)]
      • Player Group - Pick every player in (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User))) and do (Leaderboard - Change the value for (Picked player) in board to kills[(Player number of (Picked player))])
My problem is that when unit is killed it's not shown in leaderboard. Kills are always 0.
 
Level 11
Joined
Jul 12, 2005
Messages
764
First of all, use this condition instead:
((Triggering unit) belongs to an enemy of (Owner of (Killing unit))) Equal to True

It's more logical..

Secondly, look at this line:
Set kills[(Player number of (Owner of (Killing unit)))] = kills[((Player number of (Owner of (Killing unit))) + 1)]
You add +1 to the array index and not to the kills[] value.
Correct one:
Set kills[(Player number of (Owner of (Killing unit)))] = kills[(Player number of (Owner of (Killing unit)))] + 1

I also recommend to use a loop instead of the 'pick players' action.
Sthg like this:

For each integer from 1 to <Number of players> do actions:
-If
--Player(Integer A) slot status Equal to Is playing
--Player(Integer A) controller) Equal to User
-Then
--Leaderboard - Change the value for Player(Integer A) in board to kills[Integer A]
 
Level 6
Joined
Feb 2, 2005
Messages
205
hmm looks fine for me, but you can use another Update Thingy

just use this
  • Leaderboard - Change the value for (Owner of (Killing unit)) in board to kills[Player number of (Owner of (Killing unit))]
So you wont need the Player Group stuff in the Kill Trigger
 
Level 7
Joined
Feb 18, 2007
Messages
216
First of all, use this condition instead:
((Triggering unit) belongs to an enemy of (Owner of (Killing unit))) Equal to True

It's more logical..

Secondly, look at this line:
Set kills[(Player number of (Owner of (Killing unit)))] = kills[((Player number of (Owner of (Killing unit))) + 1)]
You add +1 to the array index and not to the kills[] value.
Correct one:
Set kills[(Player number of (Owner of (Killing unit)))] = kills[(Player number of (Owner of (Killing unit)))] + 1
Now it works. Thanks a lot!
 
Status
Not open for further replies.
Top