Me and a friend are trying to make a script where if you land a car in the water, it teleports to the closest vehicle node. We figured out how to detect if it’s in the water, and how to teleport to the vehicle node with the same vehicle just fine. The only issue is the car, once teleported, doesn’t start cause it has been submerged in water before. I still want any cosmetic damage/health to stay, so SetVehicleFixed will not work.
Here’s the script and what we tried
if IsEntityInWater(vehicle) then
print("Your cars in water D:")
local plyPos = GetEntityCoords(cache.ped)
local found, safePos, spawnHeading = GetClosestVehicleNodeWithHeading(plyPos.x, plyPos.y, plyPos.z, 0, 3, 0)
if found then
DoScreenFadeOut(2000)
while not IsScreenFadedOut() do
Wait(5)
end
Wait(500)
SetEntityCoords(vehicle, safePos)
DoScreenFadeIn(2000)
while not IsScreenFadedIn() do
Wait(50)
end
SetVehicleUndriveable(vehicle, false)
-- SetVehicleFixed(vehicle)
SetVehicleBodyHealth(vehicle, 1000.0)
SetVehicleEngineHealth(vehicle, 1000.0)
SetVehiclePetrolTankHealth(vehicle, 1000.0)
SetVehicleEngineOn(vehicle, true, false)
SetVehicleDirtLevel(vehicle, 0)
end
end
This does not work and the car is undriveable.