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