How to make a top score???
#1

eyy,
i got a question,
hwo can i check wich is higher than other, or wich is the highest.
(hard to explain xD)
euhm..

how can i check if something bigger/higher or lesser then a other 'thing' ( with thing i mean something made with 'new')

i hope u guys can understand xD

Edit:
btw, not with >= or > with only 2 'things'
but with many things, with 'i' (defined with MAX_PLAYERS)
like a top score with 10 players
Reply
#2

Use operators.

https://sampwiki.blast.hk/wiki/Control_Structures#Operators
Reply
#3

Quote:
Originally Posted by randomkid88
Quote:
Originally Posted by [SWA
Nitrous ]
btw, not with >= or > with only 2 'things'
Reply
#4

lol, just wanted to post that, but i read whole page first xD

i want :

there are 23 people online
and i want to make a cmd /top
and then u see the top 10 killers in the server (from people who are online)

now u got enough info i hope D:
Reply
#5

Quote:
Originally Posted by [SWA
Nitrous ]
Edit:
btw, not with >= or > with only 2 'things'
but with many things, with 'i' (defined with MAX_PLAYERS)
like a top score with 10 players
Sorry, that wasn't there when I posted.

So for this case, when someone kills another person, you need to store their total number of kills. Then you would have to make a loop with "i" and max players as you said.
After that, I saw how to do it somewhere else, but I can't remember. Someone else will have to help there.
Reply
#6

maybe some1 knows a script with a top X something has

than i can figure it out i think
Reply
#7

pawn Code:
new List[MAX_PLAYERS][2];
new count;
for(new i=0; i < MAX_PLAYERS; i++)
{
  if(IsPlayerConnected(i))
  {
    List[count][0] = i;
    List[count][1] = GetPlayerScore(i);
    count++;
  }
}
This code will create a list of all playerid's connected and also saves their score.

pawn Code:
new done, temp;
do
{
  done = 1;
  for(new i=0; i < count-1; i++)
  {
    if(List[i][1] < List[i+1][1])
    {
      done = 0;
      temp = List[i][0];
      List[i][0] = List[i+1][0];
      List[i+1][0] = temp;
      temp = List[i][1];
      List[i][1] = List[i+1][1];
      List[i+1][1] = temp;
    }
  }
}
while(!done);
This code will sort the list until it's in order, so the result will look like this:


place playeridscore
1List[0][0] List[0][1]
2List[1][0]List[1][1]
3List[2][0]List[2][1]

... and so on.
Reply
#8

thx realy usefull
but can i also use it with getplayerdistancetopoint( or smth) so i can check who is the nearest player?

(i thought i could figure it out with that list)
Reply
#9

Replace that GetPlayerScore with what you want.
Reply
#10

If you're going to use that you'll need a Floatable array or whatever its called

that will look like something like:

Code:
new Float:x; Float:y; Float:z;

and then the rest of the code here...
(too hard for me to think about the code, it's been a while for me)
Don't forget the Float's
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)