Client sided time calculation of how long a button have been pressed?

Hi.

My idea is to edit nitro script, so it will register for how long nitro button have been pressed and if the final value will reach 0 at some point (let’s say start value would be 3000ms), nitro would be deactivated (or another bottle would be injected/used) and after getting out of the car, the inventory value would be updated accordingly (so less burden for the server).

I think I can handle the most of this above, just that timer of some sort gives me wrinkles.

Could anyone give an advice how to pull this of? :slight_smile:

Thank you!

you can check if key was pressed in a frame, so perhaps with a counter and assume 60fps you can see how long they are holding that button for?

Here is my general strategy for knowing how long a control has been pressed:

GetGameTimer() at the beginning of your frame and compare it to the value from the previous frame.
Check if the button is still pressed.
If it is, add the time difference between frames to the total.
When that total reaches the desired value (or above!), do the thing.