How to make a ranking ?
#1

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

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

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

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

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

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

Any chance for quick help ?
Reply
#8

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

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

It did Thanks alote !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)