How to check dini file for certain amounts
#1

hi,
just wondering how its possible to check e.g. who has got the highest score registered on the server.
All acounts are saved with dini so how to check these e.g. with a command?
I only know how to get the highest score from the players that are currently online.

regards..
Reply
#2

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
hi,
just wondering how its possible to check e.g. who has got the highest score registered on the server.
All acounts are saved with dini so how to check these e.g. with a command?
I only know how to get the highest score from the players that are currently online.

regards..
You need one file where every account-name is listed, else it would not be possible.
I'd suggest to first make a variable with the amount of accounts in this file and then list all accounts with dini like '1=DeathOnastick.ini\n2=Somebody.ini\n etc..'.
Reply
#3

It's kinda easy, you just need to make two new variables on top like:
pawn Код:
new TopScore = 0;
new TopScorer[MAX_PLAYERS] = INVALID_PLAYER_ID;
, then go where you got the
pawn Код:
SetPlayerScore
and add this under it:
pawn Код:
if(GetPlayerScore(playerid) > TopScore)
        {
             TopScorer = playerid;
             TopScore = GetPlayerScore(TopScorer);
             // You can also send some client messages here to announce the new leader.
         }
Then you must save the player's name and his score.
Reply
#4

Much easier: MySQL!
Reply
#5

mhh thx for ur answers.
Im gonna try it out.
Could someone maybe post a link to a tutorial how to do that with MySQL?
Ive never really had to do sth. with MySQL
Reply
#6

or rather, SQLite. It's local so you don't have to get a SQL Server host and it doesn't get internet lag.
Also, it comes with samp server so you don't need to download a plugin

pawn Код:
new tmp[32];
new pname[24];
new DBResult:result=db_query(Database,"SELECT Name, Score FROM Players ORDER BY Score DESC");
db_get_field(result,0,pname,24);
db_get_field(result,1,tmp,64);
printf("%s has the highest score of %d",pname,strval(tmp));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)