Jump to content

Save player stats on another internal file


Recommended Posts

Posted

Hello, im a staff of a server that gets 90 players on, but the internal.db becomes bugged, then we need to remake the server database, because it has A LOOOOT of players inactive, then the server becomes lag...

 

Our server has a rank system, like: general 1, 2, etc...

 

That's what i need:

The player says /savestats, then it save the player rank/experience of internal.db in another .db file

Then after the server database resetting, the server remake, idk how to say, the player register, and says something like: /getstats, then it get the experience/rank back on his account...

 

 

How can i do this ?

I never used to make any database scripts...

 

Ty !!!

Posted

Just make a internal.db and edit it with SQLite, so it has rows for every single data you want to save.

local dbConnection = dbConnect("sqlite", "internal.db")

function saveStat(sourcePlayer)
	local pRank = ...
	local pExp = ...
	local pData = ...
	...
	dbExec(dbConnection, "INSERT INTO accounts VALUES(?, ?, ?, ...)", pRank, pExp, pData)
end
addCommandHandler("savestat", saveStat)

 

Posted
Quote

Just make a internal.db and edit it with SQLite, so it has rows for every single data you want to save.

As I just wrote, edit the internal.db with SQLite, so it means, adding a table, and then doing rows for every single data.

Posted

Hey, thanks for the reply !!!

So in the " ... " what i need to put ? How i have to declare the local variables of the database ? like this ?
local pRank = "Rank"

local pExp = "Experience"

 

Etc... ?

Posted

The ... means that you'll get the data from the player. (Like getElementData, etc. We dont know how you just set them, as you set, you'll get them). You'll have to download DB Browser for SQLite, make a file, and rename it as "internal.db". After that, double click on it, and you'll see the "Create Table" button. Press that, and name it as "accounts" then add fields to it. Rename those fields, and set their types. (See attachments.)
 

Spoiler

a92583d5e2334569857cfb167d1abca6.png

53b0aa9a6b51432582ae1229598c47eb.png

50d21c02acfc40de87cb80873b10a4f5.png

 

  • Like 1
Posted

Do you guys think that's gonna work ?

local dbConnection = dbConnect("sqlite", "backupexprank.db")


function saveStat(sourcePlayer)
	local account = getPlayerAccount(sourcePlayer)
	local nomeconta = getAccountName(account)
	local patente = getAccountData(account, "level")
	local experiencia = getAccountData(account, "experience") 
	dbExec(dbConnection, "INSERT INTO accounts VALUES(nomeBackup, patenteBackup, expBackup)", nomeconta, patente, experiencia)
end
addCommandHandler("savestats", saveStat)

 

Posted

Change

dbExec(dbConnection, "INSERT INTO accounts VALUES(nomeBackup, patenteBackup, expBackup)", nomeconta, patente, experiencia)

to

dbExec(dbConnection, "INSERT INTO accounts VALUES(?, ?, ?)", nomeconta, patente, experiencia)

 

Posted (edited)

No, "?" in SQL executes or querys means a data which will be passed through arguments in the function.

Edited by NeXuS™

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...