Ranking Players
#1

Hi guys,

How do I make the ranking of players in racing?

For Example:

1. Peter
2. Bear
Reply
#2

Create a global variable such as "win = 0;" then in the final checkpoint create a switch:

pawn Код:
switch(win)
            {
                case 0:
                {
                    win++;
                                        //player has won the race
                }
                case 1:
                {
                    win++;
                                        //player is second
                }
                case 2:
                {
                    win++;
                                        //player is third
                }
And so on for the others
Reply
#3

How do I withdraw those names?
Reply
#4

Quote:
Originally Posted by ReshiramZekrom
Посмотреть сообщение
Create a global variable such as "win = 0;" then in the final checkpoint create a switch:

pawn Код:
switch(win)
            {
                case 0:
                {
                    win++;
                                        //player has won the race
                }
                case 1:
                {
                    win++;
                                        //player is second
                }
                case 2:
                {
                    win++;
                                        //player is third
                }
And so on for the others
I have no idea what you wrote in that code.

Sorting an array which contains all players with quicksort would be a good idea:
http://forum.sa-mp.com/showpost.php?...postcount=1737
Reply
#5

The variable names to me, shipping, and I have to take those names.
Reply
#6

Quote:
Originally Posted by dominik523
Посмотреть сообщение
I have no idea what you wrote in that code.

Sorting an array which contains all players with quicksort would be a good idea:
http://forum.sa-mp.com/showpost.php?...postcount=1737
With my code, the first one that takes the last cp is the winner and so the global variable "win" increase by one; so the second one that takes the last cp is the second and the global variable "win" will again increase by one and so on..

So if you want to store the names is quite simple.. Create an other global variable such us:
pawn Код:
new Ranking[3];// arrays contained are 0 1 2

pawn Код:
switch(win)
            {
                new name[24];
                GetPlayerName(playerid,name,sizeof name);
                case 0:
                {
                    win++;
                    Ranking[0] = name;
                                        //player has won the race
                }
                case 1:
                {
                    win++;
                    Ranking[1] = name;
                                        //player is second
                }
                case 2:
                {
                    win++;
                    Ranking[2] = name;
                                        //player is third
                }
            }
I think that in this way the script will works fine although I don't tested it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)