Explanation
I want to decrease the engine torgue while I’m holding down the CTRL key, then restore it once I let go.
Code
Citizen.CreateThread(function()
while true do
while IsControlPressed(0, 326) do
SetVehicleCheatPowerIncrease(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0.2)
Citizen.Wait(0)
end
SetVehicleCheatPowerIncrease(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0)
Citizen.Wait(0)
end
end)
I know this code is buggy but it’ll do for the example.
Problem
When I start the server and join it, it does not work. Once I restart the resource it does though. I’ve checked and technically it should work (eg. using print("test")
to check if it reaches that far) but nothing changes.
Are there any alternatives or maybe something I’m just not seeing? Maybe I could use SetVehicleHandlingField with the torque, but I’m not really good at setting handling values using lua (or rather applying the logic behind getting, saving, setting, and once you get out restoring it etc). Any ideas? Thanks in advance!
Update:
I still don’t know why it didn’t work, but I switched over to SetVehicleEngineTorqueMultiplier
.