SA-MP Forums Archive
Get the highest value? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get the highest value? (/showthread.php?tid=236349)



Get the highest value? - XCarBOn - 07.03.2011

Hello,

I'm trying to make a "score" system. I need to check the highest value (Kills) to make a highscore. So that's the question: How can I get the highest value (Like user1 has 124 kills and user2 has 100 kills.. So user1 ist better than user2).


Thanks in advance


Re: Get the highest value? - Davz*|*Criss - 07.03.2011

https://sampwiki.blast.hk/wiki/GetPlayerScore


Re: Get the highest value? - Jeffry - 07.03.2011

pawn Код:
new Highest, Player
for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
         if(Kills[i] > Highest) Highest = Kills[i], Player=i;
    }
}
printf("Player %d (Name) with %d score", Player, Highest);
I hope you understand it.


Re: Get the highest value? - Cameltoe - 07.03.2011

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
pawn Код:
new Highest, Player
for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
         if(Kills[i] > Highest) Highest = Kills[i], Player=i;
    }
}
printf("Player %d (Name) with %d score", Player, Highest);
I hope you understand it.
pawn Код:
new Player;
for(new i=0; i<MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
         if(Kills[i] > Kills[Player]) Player = i;
    }
}
printf("Player %d (Name) with %d score", Player, Kills[Player]);



Re: Get the highest value? - Jeffry - 07.03.2011

@Cameltoe: Yup, that works too. Thanks for the update.


Re: Get the highest value? - RyDeR` - 07.03.2011

This can help you:
http://forum.sa-mp.com/showpost.php?...postcount=1760

Just use kills instead of score in the example.


Re: Get the highest value? - XCarBOn - 07.03.2011

Thanks very much!