So I am looking for a little help with banks.
I am trying to make a top 10 highscore system. For that I need to store a players score and their handle.
My map has 5 players, each players bank has the 10 highest scoring players they have played against stored in their bank. I load those values into an integer array. That fills up 50 slots of the array with scores(10 per bank), then at the bottom of it I add each actual players own top score as well. So 55 slots.
I then run the array through a sorting algorithm to get all the scores in order, and then I simply overwrite everyones highscores in their banks with the 1-10 slots of the array. That all is working fine.
The problem I am having is the player handles. I would like each score to have a name beside it. So you know who got the score. I have created a second string array of size 55, and to the best of my knowledge I am able to keep the players handles(strings) and their scores(integers) sorted together as it runs though the algorithm. Although without a proper way of storing the handles I can only assume it's working as intended and cannot actually test it.
When I look at my bank, I have a sections, keys, and values...
From my perspective, the easiest way I see to do this is to have a "highscore" section with 10 keys, one for each placement. And then each key would hold a integer value for the score and a string value for the handle?
Is there a better way to do this? Can a key even hold two values? Is there a way to set the name of the keys to the players handle and then easily load it?
To be perfectly honest the bank storing/loading makes no sense to me and I have a very incomplete understanding of it. This is the first map I have made where scoring will be an important aspect of it, or even where banks will be an important part for that matter. Any help would be appreciated.
Everything you said makes pretty much perfect sense.
Quote:
When I look at my bank, I have a sections, keys, and values... From my perspective, the easiest way I see to do this is to have a "highscore" section with 10 keys, one for each placement. And then each key would hold a integer value for the score and a string value for the handle?
Is there a better way to do this? Can a key even hold two values? Is there a way to set the name of the keys to the players handle and then easily load it? To be perfectly honest the bank storing/loading makes no sense to me and I have a very incomplete understanding of it. This is the first map I have made where scoring will be an important aspect of it, or even where banks will be an important part for that matter. Any help would be appreciated.
There are various ways of doing it.
A key can't hold two values, however you could for example use a String and then put the score and player handle together, then when reading out the values you could split that string up and convert one part into highscore and the other part into the player handle.
It should also be possible to set the key name to the player handle name and then use an integer key type and just store the score. Im just not sure if bank keys get stored/read in a fixed order (I think they do) or if its random. There might also be problems with certain characters conflicting with XML Syntax, eventually.
Long story short, do what you personally like best. I would probably go for the string approach and then split them up when loading the values.
I must be doing something wrong, because if say one player has a 10 letter handle, and a second player has a 8 letter handle, then the first 2 digits of his score would become part of his handle?
Put a space between handle and score then you can use the "Word of String" function to identify both values no matter how long they are
(Handle would then be word #1 and score word #2).
So I am looking for a little help with banks. I am trying to make a top 10 highscore system. For that I need to store a players score and their handle.
My map has 5 players, each players bank has the 10 highest scoring players they have played against stored in their bank. I load those values into an integer array. That fills up 50 slots of the array with scores(10 per bank), then at the bottom of it I add each actual players own top score as well. So 55 slots.
I then run the array through a sorting algorithm to get all the scores in order, and then I simply overwrite everyones highscores in their banks with the 1-10 slots of the array. That all is working fine.
The problem I am having is the player handles. I would like each score to have a name beside it. So you know who got the score. I have created a second string array of size 55, and to the best of my knowledge I am able to keep the players handles(strings) and their scores(integers) sorted together as it runs though the algorithm. Although without a proper way of storing the handles I can only assume it's working as intended and cannot actually test it.
When I look at my bank, I have a sections, keys, and values... From my perspective, the easiest way I see to do this is to have a "highscore" section with 10 keys, one for each placement. And then each key would hold a integer value for the score and a string value for the handle?
Is there a better way to do this? Can a key even hold two values? Is there a way to set the name of the keys to the players handle and then easily load it? To be perfectly honest the bank storing/loading makes no sense to me and I have a very incomplete understanding of it. This is the first map I have made where scoring will be an important aspect of it, or even where banks will be an important part for that matter. Any help would be appreciated.
Everything you said makes pretty much perfect sense.
There are various ways of doing it.
A key can't hold two values, however you could for example use a String and then put the score and player handle together, then when reading out the values you could split that string up and convert one part into highscore and the other part into the player handle.
It should also be possible to set the key name to the player handle name and then use an integer key type and just store the score. Im just not sure if bank keys get stored/read in a fixed order (I think they do) or if its random. There might also be problems with certain characters conflicting with XML Syntax, eventually.
Long story short, do what you personally like best. I would probably go for the string approach and then split them up when loading the values.
From what I understand of what you said, if I use this, assuming "i" iterates from 1-10, this would combine the handle and score into a single value.
Then to retrieve that value and separate it again I would use something like this?
I must be doing something wrong, because if say one player has a 10 letter handle, and a second player has a 8 letter handle, then the first 2 digits of his score would become part of his handle?
@AstralCV: Go
Put a space between handle and score then you can use the "Word of String" function to identify both values no matter how long they are (Handle would then be word #1 and score word #2).
@Talon0815: Go
Ah! Perfect. That makes a lot more sense. Ty. Ty both.