Top plaers using dini
#1

I was wondering if is possible to list the top 5 players (most kills) when using dini.

I was thinking to do a loop for the "Users" folder (where accounts are placed).

Can someone give me a tip?

Notice: An OFFLINE top players list, not online.
Reply
#2

MYSQL is the best for that.
Reply
#3

Quote:
Originally Posted by Cole_William
Посмотреть сообщение
MYSQL is the best for that.
I know Mysql is the best system for this, but i'll need to re-convert my whole gm. I need to do it with dini.
Reply
#4

You'll be looking at a very very long search delay it's completely impractical.
Reply
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
You'll be looking at a very very long search delay it's completely impractical.
So, almost impossible?
Reply
#6

Quote:
Originally Posted by Face9000
Посмотреть сообщение
So, almost impossible?
it's possible if your User data folders are names like 1.ini 2.ini etc..
Reply
#7

Quote:
Originally Posted by kirollos
Посмотреть сообщение
it's possible if your User data folders are names like 1.ini 2.ini etc..
No, each .ini file has the nick of the player who registered.

Like Face9000.ini - TestAcc.ini - Dragon.ini etc.
Reply
#8

Not impossible by any means, but impractical in the sense that your server would likely be in limbo for undesirable amounts of time.

You could however do this with sqlite very quickly since you only want Top players i'd say it would take about 30 minutes to set up and you wouldn't have to modify your existing system.
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Not impossible by any means, but impractical in the sense that your server would likely be in limbo for undesirable amounts of time.

You could however do this with sqlite very quickly since you only want Top players i'd say it would take about 30 minutes to set up and you wouldn't have to modify your existing system.
Any tip will be appreciated since i never worked using SqlLite.
Reply
#10

Well basically here is what you'll want to get....

You can set up your DB structure in here
http://sourceforge.net/projects/sqlitebrowser/

You'll need this in your code.

pawn Код:
Global Variable

new DB: UserData;

public OnGameModeInit()
{
    UserData = db_open("databases/userdata.db"); // Folder inside of scriptfiles
}
You'll need to check when a user logs out if they're DB is created like this

pawn Код:
new Query[256];
new DBResult:Result;

// This will check if the player is in the DB yet
format(Query, sizeof(Query), "SELECT `PlayerName` FROM `UserData` Where `PlayerName` = '%s'", ReturnName(playerid));

// Send the query
Result = db_query(UserData, Query);

// User has a DB created
if(db_num_rows(Result))
{
    // Update the database with their kills / deaths
    format(Query, sizeof(Query), "UPDATE `UserData` set `Kills` = '%i', `Deaths` = '%i', where `PlayerName` = '%s'",
        PlayerData[kills], PlayerData[Deaths],  ReturnName(playerid));
    Result = db_query(UserData, Query);
}
else
{
    // Create their database entry with kills and deaths will automatically update whatever they already have
    format(Query, sizeof(Query), "INSERT INTO `UserData`(`PlayerName`, `Kills`, `Deaths`) VALUES('%s', '%i', '%i'),
        ReturnName(playerid), PlayerData[kills], PlayerData[Deaths]"
);
    Result = db_query(UserData, Query);
}
// We now free the memory
db_free_result(Result);
So now with that set up you'll be able to make the queries you need to figure out the top players please note you can add more than kills / deaths to the DB in fact you may choose to drop ini all together and just use sqlite it's actually not all that difficult to implement.

I'll post some more code of how to do a query and actually get something out of it once your ready let me know.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)