Jump to content

How to check if the car is destroyed?


ARares

Recommended Posts

How i can check if the car is destroyed?, because i have an DayZ server and at the backups in db are added and the destroyed cars:

 

	for _,veh in ipairs(getElementsByType("vehicle")) do
		if not getElementData(veh, "helicrash") then
			local col = getElementData(veh, "parent");
			if col then
				local x,y,z = getElementPosition(veh);
				local rX,rY,rZ = getElementRotation(veh);
				local health = getElementHealth(veh);
				if (health < 500) then health = 500; end
				local _,sx,sy,sz = unpack(getElementData(col, "spawn"));
				local items = {};
				vc = vc+1;
				for _,item in ipairs(backupItemsTable) do
					local quantity = getElementData(col, item[1]) or 0;
					if (quantity > 0) then
						table.insert(items, {item[1], quantity});
					end
				end
				dbExec(db, "INSERT INTO `vehicles` (model, x, y, z, rX, rY, rZ, slots, fuel, engines, moving, parts, items, dayz, health, sx, sy, sz, id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 
					getElementModel(veh), x, y, z, rX, rY, rZ, getElementData(col, "MAX_Slots") or 20, getElementData(col, "fuel") or 0, getElementData(col, "Engine_inVehicle") or 0, 
					getElementData(col, "Tire_inVehicle") or 0, getElementData(col, "Parts_inVehicle") or 0, toJSON(items), getElementData(veh, "dayzvehicle") or 0, health, sx, sy, sz, vc);
			end
		end
	end

 

NVM, i solved :D

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