- Home /
Displaying only 5 of the high scores
Hello, I am using the high score system from the wiki:http://wiki.unity3d.com/index.php?title=Server_Side_Highscores It works fine i can add high score and I can display it.
my question is: how can i check if the player got a high score greater than the lowest high score--I just want to display five only.
When i do a Debug.Log(hs_get.text);
it gives me name and score for every one not an integer:
how can i do something like this:
if(score>lowestHighestScore){
SHOW THE gui stuff to add the new score and name;
}
else{
just show the score no gui;
}
Thanks
You appear to have two separate questions here:
How do I only display 5 results?
How do I find the value of the lowest high score returned? Your second question has been answered by Fred'sIphone.
In addition to that, the way you would edit the php file to limit the returned highscores is by adding the extra lines:if($num_results > 5) { $num_results = 5; }
after the line:
$num_results = mysql_num_rows($result);
in the display.php file.
This will make sure that you never get more than 5 results and is especially useful when the highscore list is already fairly long, since less data needs to be sent. Happy Holidays!
Answer by fred_gds · Dec 24, 2013 at 03:57 PM
Well just search for scores in the Sring. So basicly check for String[0] if it is number, if so check if String[1] is also a number. and then you just add up all the numbers giving you back your score.
The easier way would be if you'd always enter something like aaa121340bbb while 121340 is your score and the aaa just indicate that your score starts there. And the bbb indicates that the score ends there. So you just need search where a aaa is and then take all the characters between the aaa and the first bbb which comes later on. Take those characters in a separate String and then you can convert that string to an int.
If you do so you should always keep in mind that hackers might find out about that technique so you might want to forbid the player to use aaa and bbb in their username ;)
that's the easiest solution I see.
Otherwise you could just modify the php script on the server side but I can't help you out with that ;)
thank you both>> I decided to go with the second choice modify the php. I created a new php page the pulls one value only..the fifth highest ..then converted it to an int and compared it to the playerscore.. if the score less, the palyer doesnot have a choice to add his else he can.
Your answer
![](https://koobas.hobune.stream/wayback/20220613124809im_/https://answers.unity.com/themes/thub/images/avi.jpg)