Hello, im using SetVehicleHandlingFloat but im having trouble to reset it to normal float, how i could do that?
Im using it in a loop
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsPedInAnyVehicle(GetPlayerPed(-1), false) and something == true then
local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1),false)
SetVehicleHandlingFloat(vehicle, "CHandlingData", "fBrakeForce", 0.3)
end
end
end)
The normal value is diffrent for vehicles so i need a simple way to reset it, right now for me it stays at 0.3 all the time.
I don’t believe there is any way to “reset” it but you could store the original value (get it from GetVehicleHandlingFloat) somewhere before you touch it and then set it back when you’re done. Also, as far as I am aware, you should not call SetVehicleHandlingFloat in a loop.
Oh ok i will try to call it once and see if it works, and about storing it in a table im not sure if it will work well, because if player changes the value and gets crash/disconnect there is no way to reset it to the original one, and storing it on the server side is pointless i think. And any idea of a resource that use SetVehicleHandlingFloat ? I might take a look and see if someone had a better idea than me I think i can make a table with the default values when the player join the game but adding it manually will be boring and not worth it
I assume there is like a button or something you need to press or another variable that changes before you apply the handling to whatever vehicle you are in? Just add something before that variable is set which stores the current handling float then when you want to reset it, set it to the value you stored.
But the big problem right now is when exiting the vehicle i expect the vehicle to “reset” because entering it again will again make the value smaller by -0.3 so in the end there is no brake at all in vehicle and it goes into negative value. As you said i can store it client side and return it back when the player leave the vehicle but the another problem im having is when the player crash/disconnect in the vehicle (it cant change back to that default value) and it became weaker than all the other ones, so that is the most important thing for me to fix that
I don’t think you’re understanding how the handling float native works, it’s not an “add” or “subtract”, it sets to whatever you put in. Just do SetVehicleHandlingFloat(vehicle, "CHandlingData", "fBrakeForce", normalBrake) and it will reset