SA-MP Forums Archive
How to make a ranking ? - 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: How to make a ranking ? (/showthread.php?tid=192487)



How to make a top 3 ranking ? - Emirt - 22.11.2010

Hey !
I want to do the ranking for the points, so If i type /top3 the top3 players will came up with there scores. I mean not the top 3 at the moment but at all.

I have done a dudb file thats saves in one flie playes "Name = points" but how to use it ?

Mabye there is a script for it that I can't found ?


Re: How to make a ranking ? - FreshDoubleX - 22.11.2010

Use dini or dudb to save & load ( There's more ways to save - not only dini or dudb ) . And I also suggest you to learn mysql, it's much easier to use, save, and load things from database.


Re: How to make a ranking ? - Emirt - 23.11.2010

I see that you dind't undesrend me.

Lets say that I made something like that:

I create a Kills.cfg:
Код:
if(!dini_Exists("Kills.cfg"))
{
  dini_Create("Kills.cfg");
}
----------------------------------------------------------------
Here I load kills
Код:
public OnPlayerConnect(playerid)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  Kills[playerid] = dini_Int("Kills.cfg", Pname);
  return 1;
}
----------------------------------------------------------------
Here kills are added
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  Kills[killerid]++;
  return 1;
}
----------------------------------------------------------------
And here I save them:
Код:
OnPlayerDisconnect(playerid, reason)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  dini_IntSet("Kills.cfg", Pname, Kills[playerid]);
}
----------------------------------------------------------------
and format shown in 1 flie kills.cfg will be:
Код:
NAME = KILLS


Now porblem is I want to make a ranking, that it will read from it (kills.cfg) and put it in order form the greatest do smallest so if I type /top3 I will see top 3 players with bigest ammount of kills


Re: How to make a ranking ? - Zh3r0 - 23.11.2010

You can do the following:
1. Create a file in a different directory.
2. Create a variable.
3. In that file, set the name and the kill the player has.
Ex: Matthias = 147
Jhonny = 478
4. Then you do a loop and check the kills a player has, checking the highest and the lowest.


Re: How to make a ranking ? - Emirt - 23.11.2010

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
You can do the following:
1. Create a file in a different directory.
2. Create a variable.
3. In that file, set the name and the kill the player has.
Ex: Matthias = 147
Jhonny = 478
Isn't what I've just done ? (Post: #3 - My secend post)

Quote:

4. Then you do a loop and check the kills a player has, checking the highest and the lowest.

Thats what I can't do :P


Re: How to make a ranking ? - Emirt - 23.11.2010

Quote:
Originally Posted by Hoborific
Посмотреть сообщение
Mysql would be such an efficient way to do this. (no offense, dini's fine but'd be slower and much more of a mess.)
Lest stick to that, that I can't use Mysql on my sevrer :P
Any code woudl be nice


Re: How to make a ranking ? - Emirt - 23.11.2010

Any chance for quick help ?


Re: How to make a ranking ? - Steven82 - 23.11.2010

You could easily do this by using the Score points on the tab menu, and then when doing the cmd /top3, you use GetPlayerScore and then yea. I can't explain it that well.


Re: How to make a ranking ? - cessil - 24.11.2010

hope this helps
http://forum.sa-mp.com/showthread.ph...797#post923797


Re: How to make a ranking ? - Emirt - 24.11.2010

It did Thanks alote !