Gabriel1375 Posted March 18, 2017 Share Posted March 18, 2017 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
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 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
Anubhav Posted March 19, 2017 Share Posted March 19, 2017 https://wiki.multitheftauto.com/wiki/DbConnect You will need to use almost all functions on that page. @NeXuS™ lol you forgot to add the table Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 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. Link to comment
Gabriel1375 Posted March 19, 2017 Author Share Posted March 19, 2017 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... ? Link to comment
Anubhav Posted March 19, 2017 Share Posted March 19, 2017 Check the first post of it, you should get to know everything. Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 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 1 Link to comment
Gabriel1375 Posted March 19, 2017 Author Share Posted March 19, 2017 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
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 Change dbExec(dbConnection, "INSERT INTO accounts VALUES(nomeBackup, patenteBackup, expBackup)", nomeconta, patente, experiencia) to dbExec(dbConnection, "INSERT INTO accounts VALUES(?, ?, ?)", nomeconta, patente, experiencia) Link to comment
Gabriel1375 Posted March 19, 2017 Author Share Posted March 19, 2017 But the "?, ?, ?" isn't where i put the name of the tables ? Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 (edited) No, "?" in SQL executes or querys means a data which will be passed through arguments in the function. Edited March 19, 2017 by NeXuS™ Link to comment
Gabriel1375 Posted March 19, 2017 Author Share Posted March 19, 2017 Oh thank you very much, i'm learning a lot answering, i love this... I'm currently installing again GTA, then i'll check the script... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now