Jump to content

Save player stats on another internal file


Recommended Posts

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

Link to comment

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)

 

Link to comment

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
Link to comment

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)

 

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