I am playing with SetVehicleHandlingFloat functions and I am trying to be able to set it back when requested (simply by pressing a button for now) by GetVehicleHandlingFloat native.
I am not sure, how should I tell to script I want to save car’s original value for switching it back later.
RegisterCommand("sethandlingfloat", function(source, args, raw) -- or your method
local vehicle = GetVehiclePedIsUsing(PlayerPedId())
if vehicle ~= 0 then
originalValue = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fSteeringLock")
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fSteeringLock", 5.0)
end
end)
RegisterCommand("sethandlingfloattoorigin", function(source, args, raw)
local vehicle = GetVehiclePedIsUsing(PlayerPedId())
if vehicle ~= 0 then
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fSteeringLock", originalValue)
end
end)
I was trying to create toggle button for this thing, but can’t revert the change once I will make it
It says “No such entity”, when exiting vehicle and does not change. Any ideas?
Citizen.CreateThread( function()
while true do
Wait(1)
toggle = false
ped = PlayerPedId()
vehicle = GetVehiclePedIsUsing( ped )
--lastveh = GetPlayersLastVehicle(ped, 1)
if DoesEntityExist( ped ) and not IsEntityDead( ped ) and DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == ped then
originalValuefInitialDragCoeff = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDragCoeff")
if IsControlJustReleased(0, control) then
toggle = not toggle
if toggle then
SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fInitialDragCoeff', 5.22)
else
SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fInitialDragCoeff', originalValuefInitialDragCoeff)
end
end
else
SetVehicleHandlingFloat(lastveh, 'CHandlingData', 'fInitialDragCoeff', originalValuefInitialDragCoeff)
end
end
end )
Edit.: When I’ve tried commands you’ve suggested here, it said “no script guide for vehicle” instead…
I am still unable to figure out how to tell the server this is the very vehicle I want to set the original values to. Something like vehicleId or something.