Raizel Posted June 24, 2023 Share 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.. Link to comment
_SAXI_ Posted June 24, 2023 Share Posted June 24, 2023 replace: triggerServerEvent("afk", getLocalPlayer()) triggerServerEvent("notafk", getLocalPlayer()) Link to comment
FallenGod Posted July 13, 2023 Share 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 Link to comment
Moderators IIYAMA Posted July 13, 2023 Moderators Share 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 Link to comment
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