GetTimerDetails: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ {{Server client function}} This function is for getting the details of a running timer. ==Syntax== <syntaxhighlight lang="lua"> int, int, int getTimerDetails ( timer theTimer ) </…')
 
No edit summary
Line 6: Line 6:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int, int, int getTimerDetails ( timer theTimer )
int, int, int [[getTimerDetails]] ( timer theTimer )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 14:08, 8 August 2010

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

Syntax

int, int, int [[getTimerDetails]] ( timer theTimer )

Required Arguments

  • theTimer: A timer element.

Returns

  • Integer one represents the time left in miliseconds (1000th of a second) of the current time left in the loop.
  • Integer two represents the ammount of times the timer has left to execute.
  • Integer three represents the ammount of times the timer will execute.
  • Returns false if the timer doesn't exist or stopped running. Also, debugscript is will say "Bad Arguement @ 'getTimerDetails'"

Example

This example creates a 1 second (1000 ms) timer that will run 1000 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()
	remaining, executesRemaining, totalExecutes = getTimerDetails(theTimer) -- Get the timers details
	if (remaining and executesRemaining and totalExecutes) then
		outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Total executes: "..totalExecutes)
	else
		outputChatBox("Timer no longer exists")
	end
end
addCommandHandler("timerdetails", timerDetails)