Jump to content

Check if a vehicle is in DB?


ARares

Recommended Posts

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

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