Is it possible to detect if a player is idle or not idle?

I assume so, as that is how a player is put into an idle camera and then taken out of it. Is there a specific native for this?

Asking because currently there exist multiple resources where a player is put into idle animations after a certain period by checking if certain conditions are met (not dead, not moving, etc), but this seems like it’s doing what GTA already does.

For example:

they then need to check if a player has pressed certain keys to cancel the animations. If we can check if a player is idle or not, we wouldn’t need to do this. Been searching through the docs and only thing I could find is:

DisableIdleCamera
InvalidateIdleCam

and other natives for disabling and stopping idle animations. None of them seem to detect if a player is idle and when they are no longer idle.

Probably this guy: IsCinematicIdleCamRendering - FiveM Natives @ Cfx.re Docs
(though I have not tried it yet)

I think that would just tell if the cinematic camera is running no?

Not detect if the player has reached 30 seconds of idle time. I assume there are instances where Rockstar would want to detect if a player was idle without them being in in the cinematic camera.

https://alloc8or.re/gta5/nativedb/

There is “PlayStatsIdle” but I’m not sure how to even use it.

Edit: Possibly Idle is a stat we get can info on?

I’ve never dealt with player stats, but maybe it’s a stat we can get info on? There are natives which check for the time/length of time of a stat.

StatGetNumberOfSeconds

I was going by the name of that function. I would assume that the function I linked properly checks for the “idle” state.

If you just want to check for the cinematic cam, there is another native GetFollowPedCamViewMode - FiveM Natives @ Cfx.re Docs that returns the current active cam mode.

Since these are two different natives, I would expect them to have a different function. You might just have to try it out :smiley:

Hmm I’ll try it out and get back to you.

Hi,
You have two ways of checking idle state.

Either with this native:

Or by capturing mouse location and checking wether or not its mooving:

local sx, sy = GetActiveScreenResolution()
local cx_base, cy_base = GetNuiCursorPosition()
local cx, cy = (cx_base / sx), (cy_base / sy)

print(("Mousepos X: %s, Mousepos Y: %s"):format(cx, cy))

This method is better if you are trying to detect general movement. However you need to note that the mouseposition changes even if you are NOT INGAME. Checking for window Focus is a far more sophiscitated check that you can achieve with clever native usage.

But this should still solve any simple detection. :slight_smile: