Top plaers using dini
#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


Messages In This Thread
Top plaers using dini - by Face9000 - 30.05.2013, 22:28
Re: Top plaers using dini - by Cole_William - 30.05.2013, 22:29
Re: Top plaers using dini - by Face9000 - 30.05.2013, 22:31
Re: Top plaers using dini - by Pottus - 30.05.2013, 22:33
Re: Top plaers using dini - by Face9000 - 30.05.2013, 22:33
Re: Top plaers using dini - by Kirollos - 30.05.2013, 22:37
Re: Top plaers using dini - by Face9000 - 30.05.2013, 22:39
Re: Top plaers using dini - by Pottus - 30.05.2013, 22:40
Re: Top plaers using dini - by Face9000 - 30.05.2013, 22:43
Re: Top plaers using dini - by Pottus - 30.05.2013, 22:47

Forum Jump:


Users browsing this thread: 4 Guest(s)