DizzasTeR-

Untitled

Jan 6th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. dxTimer = {}
  2. dxTimer.__index = dxTimer;
  3.  
  4. function dxTimer:start( position = 0, end = nil )
  5.     self.Time = position;
  6.     self.Update = setTimer( function()
  7.         self.Time = self.Time + 1;
  8.         if( end and self.Time > end ) then
  9.             self:stop();
  10.         end
  11.     end, 1000, 0 );
  12.     self.Display = true;
  13. end
  14.  
  15. function dxTimer:stop()
  16.     destroyTimer( self.Update );
  17.     self.Display = false;
  18. end
  19.  
  20. function onTimerRender()
  21.     if( dxTimer.Display ) then
  22.         local position = dxTimer.Time;
  23.         dxDrawText( position, sW * 0.5, sH * 0.85, sW * 0.5, sH * 0.85, tocolor( 255, 255, 255, 255 ) );
  24.     end
  25. end
  26.  
  27. --[[
  28.     Now just do: dxTimer:start( [StartTime, EndTime ] );
  29.         - StartTime is the time to start the timer from, its optional, leaving blank will start from 0
  30.         - EndTime is optional if you want the timer to disappear after it reaches a certain value
  31.    
  32.     Completely remove timer: dxTimer:stop()
  33. --]]
Add Comment
Please, Sign In to add comment