Get the highest value?
#1

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
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerScore
Reply
#3

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.
Reply
#4

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]);
Reply
#5

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

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

Just use kills instead of score in the example.
Reply
#7

Thanks very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)