Hello there, i want to make a function where when the vehicle damages it syncs its health to the sqlite db.. It works quite a bit but the numbers are a bit different in database and in game
Code Below:
addEventHandler("onVehicleDamage", getRootElement(),
function(loss)
local vehHealth = math.floor((getElementHealth(source) / 10) - (loss / 10))
local owner = getElementData(source, "Owner")
local getAccName = getAccountName(getPlayerAccount(owner))
local getPlate = getVehiclePlateText(source)
local checkOwner = dbQuery(vehicleDb,"SELECT * FROM vehicles WHERE ownerName=? AND veh_plate=?", getAccName, getPlate)
local checkOwnerResult = dbPoll(checkOwner, -1)
if checkOwnerResult ~= 0 then
dbExec(vehicleDb,"UPDATE vehicles SET veh_Health=? WHERE ownerName=? AND veh_plate=?", vehHealth, getAccName, getPlate)
end
end)
the database connection works well but i don't know how to calculate exact vehicle health after loss to an integer number, any help appreciated!