ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. resetTimer

Function

resetTimer

Server and clientTimersIdentical to MTA:SA

Restarts counting the timer's interval from this moment.

Syntax

bool resetTimer(timer timer)

Arguments

timertimer
The timer.

Returns

true on success.

Example

Kicks a player after 5 minutes of inactivity; every message restarts the count.

local afk = {}
addEventHandler("onPlayerJoin", root, function()
    local player = source
    afk[player] = setTimer(function() kickPlayer(player, "AFK") end, 300000, 1)
end)
addEventHandler("onPlayerChat", root, function()
    if isTimer(afk[source]) then resetTimer(afk[source]) end
end)
addEventHandler("onPlayerQuit", root, function()
    if isTimer(afk[source]) then killTimer(afk[source]) end
    afk[source] = nil
end)

See also