SA-MP Forums Archive
Ranking Players - 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)
+--- Thread: Ranking Players (/showthread.php?tid=559877)



Ranking Players - Max_Andolini - 25.01.2015

Hi guys,

How do I make the ranking of players in racing?

For Example:

1. Peter
2. Bear


Re: Ranking Players - ReshiramZekrom - 25.01.2015

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


Re: Ranking Players - Max_Andolini - 26.01.2015

How do I withdraw those names?


Re: Ranking Players - dominik523 - 26.01.2015

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


Re: Ranking Players - Max_Andolini - 26.01.2015

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


Re: Ranking Players - ReshiramZekrom - 26.01.2015

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