Jump to content

Save some player stats on a Sqlite file


Recommended Posts

Hello everyone, i want to make a Ranking System on a MTA DayZ server.

I want it to show: Player Name, Player Guild, Player Murders, Player Death, Player KD...

To make this i need to have an database right ?

 

This is what i want to do:

1 - Connect to the database

2 - Get the player account: player name, guild name, murders, deaths, kd ratio

2 - Save the player account everytime that one of these variables change /\

3 - When player press some button it will show these stats i've said before, and order by player name, player murders, or something

 

My current draft of the project is at this:

Quote

local connection = dbConnect("sqlite", "ranking.db")

-- THIS IS FROM LOGIN.LUA

local playerID = getAccountData(getPlayerAccount(player),"playerID")
account = getPlayerAccount(player)

-- not anymore from login.lua

 

-- A TRY TO MAKE SOME VARIABLE TO STORE THE MURDERS TO SAVE IT LATER ON SQLITE FILE
local killedxplayers = getAccountData(account,"murders")


addEventHandler( "onResourceStart", getRootElement(), function(res)

-- CONNECT TO DATABASE WHEN TE RESOURCE IS STARTED, IF THE TABLE RANKINGS DONT EXIST CREATE
    db = dbConnect("sqlite", "ranking.db")
    dbExec(db, "CREATE TABLE IF NOT EXISTS rankings(nameplayer VARCHAR, guildplayer VARCHAR, murdersplayer INT, deathsplayer INT, kdplayer VARCHAR)")

--INSERT INTO TABLE RANKINGS VARIABLE VALUES
    dbExec(db, "INSERT INTO rankings(nameplayer, guildplayer, murdersplayer, deathsplayer, kdplayer) VALUES(idk_what_variable_here, idk_what_variable_here, idk_what_variable_here, idk_what_variable_here, idk_what_variable_here)")
end)

 

I know that almost all of the things in my script are wrong and in the wrong place, but i really need an help to understand how can i do this...

 

I don't know what scripts i have to edit like: login (to when the player login it saves to the database), etc...

 

And also: The DayZ server has already a database that saves everything i've said before like: player name, player guild, player murders, player deaths, player kd, can i get the data from this database or i really need to create another like in my script ?

 

Thanks !!!

Edited by Gabriel1375
Link to comment

Sorry, but i didn't understand, that's a post  recruiting members to mta dayz creation...

I want a script that get's the database tables/columns like: murders, name, deaths, that already exists in the MTA DayZ resource, and show like the players with the most murders...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...