HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Leaderboard and Vairable Help

01-03-2004, 06:02 PM#1
glrunner13
Hi, I need help setting up a leaderboard. I also need help setting up the variables because I don't know how to do that.

My scenario is that I need a leaderboard that counts up kills, and once the player gets to 500 kills special options unlock.
01-03-2004, 08:09 PM#2
Neo_Genesis
Leaderboards are pretty easy, I think there are a couple tutorials on this site, and other post that talk about them, but I'll give you the basic Idea on how to make one anyway.

First you need a trigger. Deside when this trigger will fire, I recomend that you not use the map initalization event and use somthing more like elapsed time equaling 5 seconds.

You dont need any conditions for this, unless you dont want to create a leaderboard in some cases.

(note that all the action below use Leaderboard - "action name here")

To make a leaderboard its really very simple. use the action create new leaderboard

tada new leaderboard created, thought its pretty empty at the moment with the excetion of a title.

So to add some players to it use the add player to leaderboard action. Here you will define which player to add, what label you want to display and the value. The label and value will take the defualt color of the player that you select. When adding a player you want to select (last created leaderboard) this will add the player to the leaderboard you made above. Repeat this step as many times as is needed to get all your players on the board.

Once you have all your players on the leaderboard use the wait command to puase for 1 second game time, and then the display (last created leaderboard) action.

Now we could make a variable for the leadeboard, however unless you are useing more then one there really isnt a point to use up more memory if we dont have to. You can just refure to (last created leaderboard) when ever you need to make changes to it.
(unless specifyed code beyond this point does not use Leaderboard - "action name here")

Okay on to variables, I am going to asume you have never used variables before. to make a variable hit ctrl + b on your keyboard or go to edit--> variable... on your menu bar. Click the new variable button to get a new variable. It will need a unqiue name (note that WE is case senesative so Hello and hello are two diffrent variables).

For your porblem we are going to use an intiger array, now if you've never just arrays before dont worry they arent that hard and they will save you a lot of time. First the varible need that unqiue name, I recomend you make it something you can remeber such as intMonsterKillCount yes it long, but you only have to type it in once in the GUIPL the rest of the time you can just select it from a menu. Now we need to select its type, since this is doing nothing more then keeping track of the number of monsters killed (a counter for lack of a better term) intiger is the best selection, this is all whole number so 0 1 2 3 ect.. The reason that the name starts with int is that we can quickly remember what type of variable this was when we go to look for it, this is not required, its just good programing. now for the final step. Click the check box next to the word array. and TADA, array variable created. See that wasnt too hard now was it?

To use this wonderful variable we have made simple use the set action. For an array all your need to do is access it is type in the number. So think of an array like a gorcery list. The first slot (1) has a defualt value of 0, if we wanted to change that value we would type

set intMonsterKillCount[1] = 200

and if we wanted to change slot 2 then

set intMonsterKillCount[2] = 200

behold! why use the arrray well its just a lot cleaner that the real reason and its going to save you some code time too. For the kill counter here is what you do.

Code:
[b]Event[/b]
  a unit dies
[b]Condition[/b]
[b]Action[/b]
  //[color=green]this is a comment line to help explain what is I am doing[/color] 
  for intiger A 1 to 12 do actions
    //[color=green]this will repeat the following code for all players, if you have less players change the second number to the number of players you have. [/color] 
    if player number of (owner of killing unit) is equal to intiger A then
    //[color=green]this line looks to see which player made the kill[/color] 
       set intMonsterKillCount[intiger A] = intMonsterKillCount[intiger A] + 1
       //[color=green]this line increase our kill counter by 1[/color] 
       leaderboard - change player value for player(intiger A) to intMonsterKillCount[intiger A] on (last Created leader board)
       //[color=green]this updates the value on our leaderboard[/color] 
//[color=green]end trigger[/color]


Thats it it may look like a lot of steps but its actualy not all that hard.

I hope that helps you, if you are still having problems I can make a demo map for you (or you can search for other treads that may already have one in them) That a quick explanation I did it from memory so the syntax is not quite the same but it should be pretty close

Neo_Genesis
01-03-2004, 08:24 PM#3
AllPainful
Neo_genisis..

Your update trigger could use some simplifying....
Code:
Event
  Unit Dies
Conditions
  Owner of (killing unit) not equal to ally of Owner of (dieing unit)
  [color=green]\\You don't really need this, but this is so that players don't get points for killing allies..[/color]
  Owner of (killing unit) not equal to owner of (dieing unit)
  [color=green]\\You don't really need this, but this is so that players don't get points for killing their own units..[/color]
Actions
  Set kills[player number(owner of(killing unit))] = kills[player number(owner of(killing unit))] +1
  Leader board - Change the value of Owner of(killing unit) to Kills[player number(owner of(killing unit))]

Much simpler, and NO LOOP, so less laggy too...

And here it is for your 500 kill bonus....

Code:
Event
  Unit Dies
Conditions
  Owner of (killing unit) not equal to ally of Owner of (dieing unit)
  Owner of (killing unit) not equal to owner of (dieing unit)
Actions
  Set kills[player number(owner of(killing unit))] = kills[player number(owner of(killing unit))] +1
  Leader board - Change the value of Owner of(killing unit) to Kills[player number(owner of(killing unit))]
  If
    Conditions
       Kills[player number(owner of(killing unit))] = 500 [color=red]Integer Comparison[/color]
    Then Actions
       [color=blue]********Put your bonus actions here for the player********[/color]
     Else
        Do nothing
01-20-2004, 04:06 AM#4
shadow)ps(
Set kills[player number(owner of(killing unit))] = kills[player number(owner of(killing unit))] +1


the +1, where does that come from? my trigger so far is Set intiplayerkills[player number(owner of(killing unit)] = intiplayerkills[player number(owner of (killing unit)] theres no space for +1 so where does it come from? please reply asap, i wanna finish this problem soon :D

thanks!
01-20-2004, 04:53 AM#5
Azraelf
He doesnt seem to know triggers well... and ur telling him JASS? :////

Anyway its pretty easy.

In Initialization:

Event
Map initialisation

Actions
Leaderboard- Create a leaderboard for Player (all players) titled Kills
Leaderboard- Add (player 1) to (last created leaderboard) with label (Name of player(Player 1)) and value 0

In your Kill Trigger:

Event
A unit dies.

Leaderboard- change the value of player(owner of(Killing unit)) to Kill(Player number(Owner(killing unit)))


You will need a variablo "Kill" declared as Integer with Array.

As simple as that :D :foot:
01-20-2004, 06:42 AM#6
AllPainful
The +1 is simple.

Where you are choosing what to set the variable to, choose "Arithmatic".
01-22-2004, 12:56 PM#7
Huh
When you specified this line:
"Owner of (killing unit) not equal to ally of Owner of (dieing unit)"

How did you get it to say ally. I figured you want him to use a player comparison but it doesnt list ally under player functions. I thought maybe you can use "(Player((Team Number of (Owner of (Dying Unit)))))" for "ally of Owner of (dieing unit)". Think this would work?

I ask because I have a similar trigger but I had it set up (it still worked just not as clean) as:

Event: A unit dies
Condition: Or- Any conditions are True
Conditions:
(Owner of (Killing unit)) Equal to Player 1
Actions- "and here it sets up the actions"

...etc etc for each player on team 2. It seems to work ok but your trigger seems like it would do the same thing with less values. Ok thanks.

-Huh
01-22-2004, 04:54 PM#8
Milkman
There is a map witha fully functional leaderboard wiht explainations at the link in my sig. It also includes lifes and two differnets teams with differents colors and bla bla.... Check it out if you still havn't got it.
01-22-2004, 04:58 PM#9
AllPainful
  1. Boolean comparison
  2. Click "((Triggering unit) is A structure)"
  3. Choose "Player - Player is an ally of player"

and I think you can figure out the rest.

It actually looks like this:

((Owner of (Killing unit)) is an ally of (Owner of (Dying unit))) Equal to False


Don't forget to set the "False" at the end (it defualts to true)
02-09-2004, 01:33 AM#10
starbuk
Im going crazy.. Ive been on the same trigger part for 2 hours now..

Set kills[player number(owner of(killing unit))] = kills[player number(owner of(killing unit))] +1


I CANT do this line... the only thing I manage to make is:
Set Kills = blabla

I cant make [] []_[]_[] how can I insert these in my arithmetic!!! Help me please I really want to go to sleep but I cant just leave my trigger like this I wont sleep peacefully!!

:bangH: :knife: :cuss:
02-09-2004, 05:07 AM#11
AllPainful
Create new action

Choose "Set variable"

Change the variable before the = to Kills

Click on whats between the brackets

Choose "Convert player number to Integer"

Click on "Player one"

Choose "Owner of unit"

Click on "Triggering unit"

Choose "Killing unit"

Hit ok till your back to the first window

Click on the 1 after the = sign

Choose arithmatic.

Click on the first "1" in the window

Choose "Kills" from your Variable list

Hit Ok

Click on whats between the brackets

Choose "Convert player number to Integer"

Click on "Player one"

Choose "Owner of unit"

Click on "Triggering unit"

Choose "Killing unit"

Hit Ok untill your all the way back to the trigger editor.

And wallah

:ggani:
02-09-2004, 10:35 AM#12
starbuk
and it worked!!! thanks.