Good day @Akkariin,
I have noticed that the script still runs when the player is not in a vehicle.
Code to resolve the issue.
Citizen.CreateThread(function()
while true do
Wait(1)
playerPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(playerPed) then
if playerPed and not isHide then
playerCar = GetVehiclePedIsIn(playerPed, false)
if playerCar and GetPedInVehicleSeat(playerCar, -1) == playerPed then
carRPM = GetVehicleCurrentRpm(playerCar)
carSpeed = GetEntitySpeed(playerCar)
carGear = GetVehicleCurrentGear(playerCar)
carIL = GetVehicleIndicatorLights(playerCar)
carHandbrake = GetVehicleHandbrake(playerCar)
carBrakePressure = GetVehicleWheelBrakePressure(playerCar, 0)
carLS_r, carLS_o, carLS_h = GetVehicleLightsState(playerCar)
SendNUIMessage({
ShowHud = true,
CurrentCarRPM = carRPM,
CurrentCarGear = carGear,
CurrentCarSpeed = carSpeed,
CurrentCarKmh = math.ceil(carSpeed * 3.6),
CurrentCarMph = math.ceil(carSpeed * 2.236936),
CurrentCarIL = carIL,
CurrentCarHandbrake = carHandbrake,
CurrentCarBrake = carBrakePressure,
CurrentCarLS_r = carLS_r,
CurrentCarLS_o = carLS_o,
CurrentCarLS_h = carLS_h,
PlayerID = GetPlayerServerId(GetPlayerIndex())
})
else
SendNUIMessage({HideHud = true})
end
end
end
end
end)
After adding a simple if statement to determine if the player is in a vehicle the scripts runtime decreases.
I already made a pull request on the you’re Github.
Have a nice day!