ARares Posted July 31, 2017 Share Posted July 31, 2017 In my DayZ GM, at the start all cars are deleted and are spawned the cars which are in DB, but if i will add a new car which is not in DB, that car is deleted too, so, how i can check if a car is spawned and is not in DB? Code: function loadBackup() for _,v in pairs(getElementsByType("vehicle")) do local p0 = dbPoll(dbQuery(db, "SELECT * FROM `vehicles`"), -1); -- Here i need to make the check local col = getElementData(v, "parent"); if col then destroyElement(col); end destroyElement(v); end local p = dbPoll(dbQuery(db, "SELECT * FROM `vehicles`"), -1); if (#p > 0) then for _,d in pairs(p) do createDayzVeh(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["fuel"], d["engines"], d["moving"], d["parts"], d["items"], d["dayz"], d["health"], d["sx"], d["sy"], d["sz"]); end end local p2 = dbPoll(dbQuery(db, "SELECT * FROM `tents`"), -1); if (#p2 > 0) then for _,d in pairs(p2) do createDayzTent(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["scale"], d["items"]); end end end Link to comment
Mr.Loki Posted July 31, 2017 Share Posted July 31, 2017 setElementData (v,"dayzVehicle",true) When loading the vehicles. If not getElementData(v,"dayzVehicle")then When saving the vehicles. Link to comment
NeXuS™ Posted August 1, 2017 Share Posted August 1, 2017 BTW, you shouldn't use local p0 = dbPoll(dbQuery(db, "SELECT * FROM `vehicles`"), -1); these, with -1. 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