Raizel Posted June 24, 2023 Posted June 24, 2023 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..
_SAXI_ Posted June 24, 2023 Posted June 24, 2023 replace: triggerServerEvent("afk", getLocalPlayer()) triggerServerEvent("notafk", getLocalPlayer())
FallenGod Posted July 13, 2023 Posted July 13, 2023 You Can Use onClientMinimize Event (https://wiki.multitheftauto.com/wiki/OnClientMinimize) To Detect Player Minimized And You Can Use onClientRestore Event (https://wiki.multitheftauto.com/wiki/OnClientRestore) To Know When Player Back To Game i'm ErroR ! Telegram : @MrGhazio & @FullOffeD Discord : ErroR#3727 MTA [LUA] Scripter & Developer We Are Arcenics !
Moderators IIYAMA Posted July 13, 2023 Moderators Posted July 13, 2023 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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now