Alrighty, done some searches, found some really impressive things that people have created, scoreboard speaking. However I have one small question that i cant seem to find an answer to.
Now, If i create a leaderboard, assign the player column, and add some players. And of course store the leaderboard in a gv.
Hopefully im just blind and missing something very simple, how do i find that players row for use later?
Example, i have added 8 players to the leaderboard. Now a player scores a kill, how do i return the row associated to that player?
I believe that the row associated with a player does not change, all that changes is where it is shown. So if it was player 8 who scored a kill in your game and he got bumped up to position #1, I think you still reach that player through row 8.
Here's what I did (My leaderboard is kinda complex, but here's at least snippets in relations to what you seem to be asking)
I created a global variable called PlayerBoard[], it's an integer with an array size of 16. This variable stores which row on the leaderboard the player is residing in. I wrote this function:
GetBoardIndex
Options: Function
Return Type: Integer
Parameters
PlayerIndex = 0 <Integer>
Grammar Text: GetBoardIndex(PlayerIndex)
Hint Text: (None)
Custom Script Code
Local Variables
x = 0 <Integer>
Actions
General - For each integer x from 0 to 16 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
PlayerBoard[x] == PlayerIndex
Then
General - Return (x + 2)
Else
General - Return -1
My leaderboard is set up where the first two rows show information, and the rest is populated with player related info.
Why do I do this method? Because if Player slot 2 and 4 are used, but not 3, you get visual issues of blank slots if you don't create an "array stack" so to speak.
Then, whenever I want to update a player's information, I do this:
Leaderboard - Set Leaderboard item text at column 4 and row (GetBoardIndex(x)) to "0"
x in this case is the Player Number.
When the map is initiated, I write a check like this.
I loop through each player via variable PlayerIndex and have a local variable called BoardIndex (int), and inside the loop:
Variable - Set PlayerBoard[BoardIndex] = PlayerIndex
Variable - Modify BoardIndex: + 1
This sets up the player's slot on the leaderboard.
In your case, you'd likely want to make the setting of where on the board each player resides in dynamic, which is doable with my system if you do some logic checking on where each player resides and shift them accordingly.
Thank you very much, thats a great framework to start with and i think ill be able to get something working. Was almost at the point where i was gonna say forget leaderboards and script the sorting into dialogs.
Alrighty, done some searches, found some really impressive things that people have created, scoreboard speaking. However I have one small question that i cant seem to find an answer to.
Now, If i create a leaderboard, assign the player column, and add some players. And of course store the leaderboard in a gv.
Hopefully im just blind and missing something very simple, how do i find that players row for use later?
Example, i have added 8 players to the leaderboard. Now a player scores a kill, how do i return the row associated to that player?
I believe that the row associated with a player does not change, all that changes is where it is shown. So if it was player 8 who scored a kill in your game and he got bumped up to position #1, I think you still reach that player through row 8.
@Qancakes: Go
well that's disheartening.
Players are added and removed from my leaderboard through dynamic criteria.
i never declare soemthing like Add player 1 to leaderboard.
Its something like, when unit enters region, add player to board, unit leaves region, remove him etc. :/
I basically need a way to derive the players row on a leaderboard, from a Owner of Unit(Triggering Player)
Here's what I did (My leaderboard is kinda complex, but here's at least snippets in relations to what you seem to be asking)
I created a global variable called PlayerBoard[], it's an integer with an array size of 16. This variable stores which row on the leaderboard the player is residing in. I wrote this function:
GetBoardIndex
Options: Function
Return Type: Integer
Parameters
PlayerIndex = 0 <Integer>
Grammar Text: GetBoardIndex(PlayerIndex)
Hint Text: (None)
Custom Script Code
Local Variables
x = 0 <Integer>
Actions
General - For each integer x from 0 to 16 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
PlayerBoard[x] == PlayerIndex
Then
General - Return (x + 2)
Else
General - Return -1
My leaderboard is set up where the first two rows show information, and the rest is populated with player related info.
Why do I do this method? Because if Player slot 2 and 4 are used, but not 3, you get visual issues of blank slots if you don't create an "array stack" so to speak.
Then, whenever I want to update a player's information, I do this:
Leaderboard - Set Leaderboard item text at column 4 and row (GetBoardIndex(x)) to "0"
x in this case is the Player Number.
When the map is initiated, I write a check like this.
I loop through each player via variable PlayerIndex and have a local variable called BoardIndex (int), and inside the loop:
Variable - Set PlayerBoard[BoardIndex] = PlayerIndex
Variable - Modify BoardIndex: + 1
This sets up the player's slot on the leaderboard.
In your case, you'd likely want to make the setting of where on the board each player resides in dynamic, which is doable with my system if you do some logic checking on where each player resides and shift them accordingly.
@Xackery: Go
Thank you very much, thats a great framework to start with and i think ill be able to get something working. Was almost at the point where i was gonna say forget leaderboards and script the sorting into dialogs.
Even with dialogs I would imagine you'd be ending up doing something like I did to a certain degree. :) Good luck.
nevermind
A great leaderboard tutorial: http://maulware.net/tutorials/leaderboard.html
@Xackery: Go
Aye, i may still fallback to dialogs.
My kingdom for an InsertRow function.
heres what my ideal leaderboard is;
Currently playing with groups to see if i can get the rows to display in the order i want them in.
Some ColSpan and RowSpan would make this easier as well :/ Hell, I just wish this was an html table with sorting functions :D