Jump to content

[help] trying to detect if a player is afk


Raizel

Recommended Posts

hello! I'm trying to detect if a player is afk and if he is afk then put him in a animation

client:

function isLocalPlayerActive ()
    if isMainMenuActive() then
       setElementData(getLocalPlayer(),"status","afk", true)
       triggerServerEvent("afk", source)
    else
       setElementData(getLocalPlayer(),"status","playing", true)
       triggerServerEvent("notafk", source)
    end
 end

server:

addEvent('afk', true)
addEventHandler('afk', root, function()
    setPedAnimation(source, "BEACH", "Lay_Bac_Loop", -1, true, false, false )
end)

addEvent('notafk', true)
addEventHandler('notafk', root, function()
    setPedAnimation(source)
end)

 

it doesn't do anything and the debugscript says nothing so idk what to do..

Link to comment
  • 3 weeks later...
  • Moderators
On 24/06/2023 at 09:10, Raizel said:

I'm trying to detect if a player is afk

There is also this serverside function:

https://wiki.multitheftauto.com/wiki/GetPlayerIdleTime

Quote

This function gets the amount of time in milliseconds that a players position has not changed.

Or check when the player is pressing a button:

https://wiki.multitheftauto.com/wiki/OnClientKey

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...