Today I used the
setVehicleWheelStates
and If I set my wheels to fallen off, then set then to inflated again, after that if I fix my vehicle the wheels will be invisible, anyone knows a workaround for this?
It only happens in my script (tested with the wiki script and don't happen)
my script is this:
--server--
local tireOff = getElementData(getElementData(veh,"parent"),"Tire_inVehicle") -- check if there is tires in the vehicle (gamemode element)
if tireOff == 0 then
setVehicleWheelStates(veh, 2, 2, 2, 2)
elseif tireOff == 3 then
local wheel = math.random(1, 4)
if wheel == 1 then
setVehicleWheelStates(veh, 0, 0, 2, 0)
elseif wheel == 2 then
setVehicleWheelStates(veh, 2, 0, 0, 0)
elseif wheel == 3 then
setVehicleWheelStates(veh, 0, 0, 0, 2)
elseif wheel == 4 then
setVehicleWheelStates(veh, 0, 2, 0, 0)
end
elseif tireOff == 2 then
local wheel = math.random(1, 4)
if wheel == 1 then
setVehicleWheelStates(veh, 2, 0, 2, 0)
elseif wheel == 2 then
setVehicleWheelStates(veh, 2, 0, 0, 2)
elseif wheel == 3 then
setVehicleWheelStates(veh, 0, 2, 0, 2)
elseif wheel == 4 then
setVehicleWheelStates(veh, 0, 2, 2, 0)
end
elseif tireOff == 1 then
local wheel = math.random(1, 4)
if wheel == 1 then
setVehicleWheelStates(veh, 2, 2, 2, 0)
elseif wheel == 2 then
setVehicleWheelStates(veh, 2, 0, 2, 2)
elseif wheel == 3 then
setVehicleWheelStates(veh, 2, 2, 0, 2)
elseif wheel == 4 then
setVehicleWheelStates(veh, 0, 2, 2, 2)
end
end
Then when the player add the tires I call an trigger event in the server to put back the wheels:
--client--
triggerServerEvent("putwheels", resourceRoot, veh)
This is the function that put back the wheels
--server--
function putwheels (veh)
local frontLeft, rearLeft, frontRight, rearRight = getVehicleWheelStates ( veh ) -- testing the wheels which are missing
if frontLeft == 2 then
setVehicleWheelStates (veh, 0)
elseif rearLeft == 2 then
setVehicleWheelStates (veh, 0, 0)
elseif frontRight == 2 then
setVehicleWheelStates (veh, 0, 0, 0)
elseif rearRight == 2 then
setVehicleWheelStates (veh, 0, 0, 0, 0)
end
end
addEvent("putwheels", true)
addEventHandler("putwheels", resourceRoot, putwheels)
if I fix the vehicle after it put back the wheels, makes the wheels invisible: