When using IsControlPressed
ive noticed it will capture the event more than once when checking every tick.
Citizen.CreateThread(function()
local times_pressed = 0
while true do
Citizen.Wait(0)
if isControlPressed(0, 206) then --Btn "E" Pressed
times_pressed = times_pressed + 1
print(times_pressed)
end
end
end)
I found the easiest fix is to increase the wait time to lower the chance of double counting the press of a key. I easily get times_pressed
up to 5 by pressing the key once when accessed every tick but increasing the wait could mean missing the event. Also the amount to wait would vary from computer to computer since not all computers are the same.
Looking for best practice here. How are people using this to not execute their code more than once? Additional Flag checks? There is potential for a lot of uneeded execution time for using this native it seems.