GetPlayerIdleTime: Difference between revisions
Jump to navigation
Jump to search
(→Syntax: OOP syntax added) |
m (→See Also) |
||
(One intermediate revision by one other user not shown) | |||
Line 18: | Line 18: | ||
This example will kick a player if they don't move for 5 minutes and the resource has access to "function.kickPlayer" | This example will kick a player if they don't move for 5 minutes and the resource has access to "function.kickPlayer" | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | setTimer( | ||
function() | |||
for _, player in ipairs(getElementsByType("player"))do -- Loop thru every player | |||
if (getPlayerIdleTime(player) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) | |||
kickPlayer(player, "Idle for 5 minutes") -- Kick the idling player | |||
end | |||
end | end | ||
end | end, | ||
30000, 0) -- Timer to execute every 30 seconds, checking for idlers | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 33: | Line 35: | ||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions|server}} |
Revision as of 22:41, 6 September 2024
This function gets the amount of time in milliseconds that a players position has not changed.
Syntax
int getPlayerIdleTime ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:getIdleTime(...)
- Variable: .idleTime
Required Arguments
- thePlayer: The player you wish to get the idle time of.
Returns
Returns the amount of time in milliseconds that a player has been idle, false otherwise.
Example
Click to collapse [-]
Serverside exampleThis example will kick a player if they don't move for 5 minutes and the resource has access to "function.kickPlayer"
setTimer( function() for _, player in ipairs(getElementsByType("player"))do -- Loop thru every player if (getPlayerIdleTime(player) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) kickPlayer(player, "Idle for 5 minutes") -- Kick the idling player end end end, 30000, 0) -- Timer to execute every 30 seconds, checking for idlers
Requirements
This template will be deleted.
See Also
- getAlivePlayers
- getDeadPlayers
- getPlayerACInfo
- getPlayerAnnounceValue
- getPlayerCount
- getPlayerIdleTime
- getPlayerIP
- getPlayerVersion
- getRandomPlayer
- isPlayerMuted
- redirectPlayer
- resendPlayerACInfo
- resendPlayerModInfo
- setPlayerAnnounceValue
- setPlayerMuted
- setPlayerScriptDebugLevel
- setPlayerTeam
- setPlayerVoiceBroadcastTo
- setPlayerVoiceIgnoreFrom
- setPlayerWantedLevel
- spawnPlayer
- takePlayerScreenShot
- Shared
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState