3B00DG4MER Posted March 12, 2014 Posted March 12, 2014 (edited) Hello,I made New System AFK IT's Work without Bugs But it doesn't get to Dimension 1 Server : function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) setElementDimension ( thePlayer, 1 ) outputChatBox("AFk Check") end end end setTimer(checkAFKPlayers, 30000, 0) -- Timer to execute every 30 seconds, checking for idlers Edited March 14, 2014 by Guest
Saml1er Posted March 12, 2014 Posted March 12, 2014 function DimensionP (player, dimension) if isPedInVehicle (player) then local veh = getPedOccupiedVehicle (player) setElementDimension ( player, dimension ) setElementDimension ( veh, dimension ) else setElementDimension ( player, dimension ) end return true end function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) DimensionP ( thePlayer, 1 ) outputChatBox("AFk Check") end end end setTimer(checkAFKPlayers, 30000, 0)
3B00DG4MER Posted March 13, 2014 Author Posted March 13, 2014 Can you made it if He Move will Go to Default Dimension setElementDimension ( thePlayer, 0 )
Controlled Posted March 14, 2014 Posted March 14, 2014 function DimensionP (player, dimension) if isPedInVehicle (player) then local veh = getPedOccupiedVehicle (player) setElementDimension ( player, dimension ) setElementDimension ( veh, dimension ) else setElementDimension ( player, dimension ) end return true end function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) DimensionP ( thePlayer, 1 ) outputChatBox("AFk Check") elseif ( getElementDimension ( thePlayer) == 1 ) and (getPlayerIdleTime(thePlayer) < 300000) then setElementDimension ( thePlayer, 0) end end end setTimer(checkAFKPlayers, 30000, 0)
Ab-47 Posted March 14, 2014 Posted March 14, 2014 function checkAFKPlayers() for index, source in ipairs(getElementsByType("player"))do -- Loop all online players if (getPlayerIdleTime(source) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) DimensionP ( source, 1 ) outputChatBox("AFk Check") elseif ( getElementDimension ( source) == 1 ) and (getPlayerIdleTime(source) < 300000) then setElementDimension ( source, 0) end end end setTimer(checkAFKPlayers, 30000, 0) Try this, you haven't defined "thePlayer" either, but I replaced thePlayer with source which should get the local player. Not tested
Moderators Citizen Posted March 14, 2014 Moderators Posted March 14, 2014 you haven't defined "thePlayer" either It was defined in the for loop: for index, thePlayer in ipairs(getElementsByType("player")) do
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