Andres99907 Posted May 15, 2017 Share Posted May 15, 2017 any resource to save vehicles? I've been investigating this and I have not found anything that works Link to comment
KillaBeatZ Posted May 22, 2017 Share Posted May 22, 2017 Write yourself, not too hard, if u have fantasy Link to comment
Tekken Posted May 23, 2017 Share Posted May 23, 2017 Check this out: addCommandHandler("savecars", function() --Backup function. --You should make an ADMIN rights check. if fileExists("settings.xml") then fileDelete('settings.xml'); end local cars = xmlCreateFile("settings.xml", "cars"); for _,v in ipairs(getElementsByType("vehicle")) do local TheCar = xmlCreateChild(cars, "car"); local x,y,z = getElementPosition(v); local rotX,rotY,rotZ = getElementRotation(v); xmlNodeSetAttribute(TheCar, "model", getElementModel(v)); xmlNodeSetAttribute(TheCar, "x", x); xmlNodeSetAttribute(TheCar, "y", y); xmlNodeSetAttribute(TheCar, "z", z); xmlNodeSetAttribute(TheCar, "rotx", rotX); xmlNodeSetAttribute(TheCar, "roty", rotY); xmlNodeSetAttribute(TheCar, "rotz", rotZ); end outputChatBox("Car backup done!", root, 0, 255, 0, false); xmlSaveFile(cars); xmlUnloadFile(cars); end); addCommandHandler("loadcars", function() --Load function. -- You should make an ADMIN rights check. local cars = xmlLoadFile("settings.xml"); if (cars)then local veh = xmlNodeGetChildren(cars); for _,v in ipairs(veh) do local Model = xmlNodeGetAttribute (v, "model"); local X = xmlNodeGetAttribute (v, "x"); local Y = xmlNodeGetAttribute (v, "y"); local Z = xmlNodeGetAttribute (v, "z"); local Rotx = xmlNodeGetAttribute (v, "rotx"); local Roty = xmlNodeGetAttribute (v, "roty"); local Rotz = xmlNodeGetAttribute (v, "rotz"); createVehicle(tonumber(Model), tonumber(X), tonumber(Y), tonumber(Z), tonumber(Rotx), tonumber(Roty), tonumber(Rotz)); end outputChatBox("All cars loaded!", root, 0, 255, 0, false); end end); 1 Link to comment
Scripting Moderators thisdp Posted May 29, 2017 Scripting Moderators Share Posted May 29, 2017 On 2017-5-23 at 20:51, Tekken said: Check this out: addCommandHandler("savecars", function() --Backup function. --You should make an ADMIN rights check. if fileExists("settings.xml") then fileDelete('settings.xml'); end local cars = xmlCreateFile("settings.xml", "cars"); for _,v in ipairs(getElementsByType("vehicle")) do local TheCar = xmlCreateChild(cars, "car"); local x,y,z = getElementPosition(v); local rotX,rotY,rotZ = getElementRotation(v); xmlNodeSetAttribute(TheCar, "model", getElementModel(v)); xmlNodeSetAttribute(TheCar, "x", x); xmlNodeSetAttribute(TheCar, "y", y); xmlNodeSetAttribute(TheCar, "z", z); xmlNodeSetAttribute(TheCar, "rotx", rotX); xmlNodeSetAttribute(TheCar, "roty", rotY); xmlNodeSetAttribute(TheCar, "rotz", rotZ); end outputChatBox("Car backup done!", root, 0, 255, 0, false); xmlSaveFile(cars); xmlUnloadFile(cars); end); addCommandHandler("loadcars", function() --Load function. -- You should make an ADMIN rights check. local cars = xmlLoadFile("settings.xml"); if (cars)then local veh = xmlNodeGetChildren(cars); for _,v in ipairs(veh) do local Model = xmlNodeGetAttribute (v, "model"); local X = xmlNodeGetAttribute (v, "x"); local Y = xmlNodeGetAttribute (v, "y"); local Z = xmlNodeGetAttribute (v, "z"); local Rotx = xmlNodeGetAttribute (v, "rotx"); local Roty = xmlNodeGetAttribute (v, "roty"); local Rotz = xmlNodeGetAttribute (v, "rotz"); createVehicle(tonumber(Model), tonumber(X), tonumber(Y), tonumber(Z), tonumber(Rotx), tonumber(Roty), tonumber(Rotz)); end outputChatBox("All cars loaded!", root, 0, 255, 0, false); end end); this is too slow, use sqlite instead Link to comment
Tekken Posted May 30, 2017 Share Posted May 30, 2017 23 hours ago, thisdp said: this is too slow, use sqlite instead Not that slow, but yeah SQLite it's a lot better, I have this since I've started to do scripts so I just copy/paste it here Link to comment
Scripting Moderators thisdp Posted May 30, 2017 Scripting Moderators Share Posted May 30, 2017 7 hours ago, Tekken said: Not that slow, but yeah SQLite it's a lot better, I have this since I've started to do scripts so I just copy/paste it here if he wants to save 5000+ vehicles, sqlite is the best solution to his question 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