ibootleeg Posted February 10, 2014 Share Posted February 10, 2014 Is possible to create a system in which the player complete the purchase of a car, this car gets saved to your account? Example: I bought this car after I assure him, after I quit the server it will be saved in my account when I get back on the server, I could stick it again somewhere without having to buy again. Like money save Link to comment
myonlake Posted February 10, 2014 Share Posted February 10, 2014 You can use SQLite, MySQL or XML to store such data. There are some community resources made by other people, which do the same thing: https://community.multitheftauto.com/in ... ils&id=252 https://community.multitheftauto.com/in ... ils&id=699 https://community.multitheftauto.com/in ... ls&id=1559 https://community.multitheftauto.com/in ... ls&id=5004 https://community.multitheftauto.com/in ... ls&id=7455 https://community.multitheftauto.com/in ... ls&id=8184 Link to comment
ibootleeg Posted February 10, 2014 Author Share Posted February 10, 2014 I had already searched for it, but now that you mention it, you could give me some example of how I would do to save some data in xml player? In which case, I want to save the car for the player they bought. Link to comment
Damien_Teh_Demon Posted February 11, 2014 Share Posted February 11, 2014 I reccommend you use sqlite. I will show you some basic ways to use it to your advantage. The first thing your gonna need to do is connect to the database, and create the table if it doesnt exist for what you want to start, and include the variables in there, like so addEventHandler ( "onResourceStart", getRootElement(), function(res) db = dbConnect("sqlite", "vehicles.db") dbExec(db, "CREATE TABLE IF NOT EXISTS vehicle(owner TEXT, x INT, y INT, z INT, xr INT, yr INT, zr INT)") end) Basically what we did above is create a database and then chec kif the table exists, and if not create it with those certain collums. Now lets say you want to insert a new line of data when someone buys car ( i wont say how to do this, im just showing you how to save. ). You would do that with a dbquery, heres an example. dbExec(db, "INSERT INTO `vehicles`(`owner`, 'x','y','z','xr','yr','zr') VALUES(?,?,?,?,?,?,?)", playerAccountNameHere, carx, cary, carz, carxrot, caryrot, carzrot) This is pretty self explanitory ^ Now i will show you how to update and remove. Update dbExec(db, "UPDATE `vehicles` SET x = ? WHERE owner=?", ownerDataHere) DELETe dbExec(db, "DELETE FROM 'vehicles' WHERE owner= ?", carOwner ) These are the bare basics but this should be enough to get you started. Just google "Multi theft auto dbexec" and such to learn it better. Link to comment
xXMADEXx Posted February 11, 2014 Share Posted February 11, 2014 @Damien_Teh_Demon - You forgot to add the vehicle model, and it's not a very good method to use INT for x, y, z, rx, ry, and rz. You should use something like FLOAT. Link to comment
Damien_Teh_Demon Posted February 11, 2014 Share Posted February 11, 2014 @Damien_Teh_Demon -You forgot to add the vehicle model, and it's not a very good method to use INT for x, y, z, rx, ry, and rz. You should use something like FLOAT. Again, im not trying to make something for him, but yeah, i just wanna give him a idea on how to save data, not a step by step manual on how to save a vehicle's position , and thanks for the float tip, i just assumed to use int, ill be changing that on my scripts now 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