From Multi Theft Auto: Wiki
Revision as of 13:34, 15 August 2020 by Srslyyyy (talk | contribs) (Updated details about third returned value. (it was wrong before))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function is for getting the details of a running timer.


int, int, int getTimerDetails ( timer theTimer )

OOP Syntax Help! I don't understand this!

Method: timer:getDetails(...)

Required Arguments

  • theTimer: A timer element.


  • Integer one represents the time left in miliseconds (1000th of a second) of the current time left in the loop.
  • Integer two represents the amount of times the timer has left to execute.
  • Integer three represents the time interval of timer.
  • Returns false if the timer doesn't exist or stopped running. Also, debugscript will say "Bad Argument @ 'getTimerDetails'". To prevent this, you can check if the timer exists with isTimer().


This example creates a 1 second (1000 ms) timer that will run 10 times, and you can see the timer details by using the command: timerdetails.

theTimer = setTimer(function() end, 1000, 10) -- A timer that does nothing.

function timerDetails()
	local remaining, executesRemaining, timeInterval = getTimerDetails(theTimer) -- Get the timers details
	if (remaining and executesRemaining and timeInterval) then
		outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Time interval: "..timeInterval)
		outputChatBox("Timer no longer exists")
addCommandHandler("timerdetails", timerDetails)

See Also