KillTimer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(changed the pos example)
(→‎Syntax: argument is actually a timer object, not an int)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool killTimer ( int timerID )
bool killTimer ( timer theTimer )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''timerID:''' The timer you wish to halt.
*'''theTimer:''' The [[timer]] you wish to halt.


===Returns===
===Returns===
Returns ''true'' if a timer was successfully killed, ''false'' if no timer with the ID provided existed.
Returns ''true'' if the timer was successfully killed, ''false'' if no such timer existed.


==Example==  
==Example==  

Revision as of 13:17, 7 February 2008

This function allows you to kill/halt existing timers.

Syntax

bool killTimer ( timer theTimer )

Required Arguments

  • theTimer: The timer you wish to halt.

Returns

Returns true if the timer was successfully killed, false if no such timer existed.

Example

This example kills all timers with a remaining time of less than 1 minute.

-- Find and kill all the timers with less than 1 minute to go
timers = getTimers ( 60000 )
-- Loop through the timer list
for timerKey, timerValue in ipairs(timers) do
	-- kill the timer
      killTimer ( timerValue )
end

See Also