Advertisement
RidwanRF

Time remaining

Feb 10th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. local sx, sy = guiGetScreenSize()
  2. local timerTime = 60
  3.  
  4. --Start the timer to decrease the time
  5. function startTimer ()
  6.     timer = setTimer( function ()
  7.         if ( timerTime ~= 0 ) then
  8.             timerTime = timerTime -1
  9.         end
  10.     end, 1000, 0)
  11. end
  12.  
  13. --Stop the timer
  14. function stopTimer ()
  15.     if ( isTimer(timer) ) then killTimer(timer) end
  16. end
  17.  
  18. -- Show the timer
  19. function showTimer ()
  20.     addEventHandler( "onClientRender", root, showDxTimer)
  21. end
  22.  
  23. -- Hide the timer
  24. function hideTimer ()
  25.     removeEventHandler( "onClientRender", root, showDxTimer)
  26. end
  27.  
  28.  
  29.  
  30. function showDxTimer ()
  31.     dxDrawRectangle(sx-( sx*(200/1440) ), sy*(400/900), sx*(200/1440), sy*(100/900), tocolor(0, 0, 0, 135))
  32.     dxDrawBorderedRectangle( sx-( sx*(200/1440) ), sy*(400/900), sx*(200/1440), sy*(100/900), tocolor(0, 0, 0, 255), false )
  33.     dxDrawBorderedText ( "Time remaining:\n"..timerTime, sx*(1240/1440) ,  sy*(400/900) ,  sx, sy*(500/900), tocolor(255, 255, 255), sx*(1.9/1440), "default-bold", "center", "center")
  34. end
  35.  
  36.  
  37. -- Function to draw bordered text
  38. function dxDrawBorderedText ( text, x, y, w, h, color, scale, font, alignX, alignY, borderColor )
  39.     if not ( borderColor ) then borderColor = tocolor ( 0, 0, 0, 255 ) end
  40.     dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, borderColor, scale, font, alignX, alignY, false, false, false, false )
  41.     dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, borderColor, scale, font, alignX, alignY, false, false, false, false )
  42.     dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, borderColor, scale, font, alignX, alignY, false, false, false, false)
  43.     dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, borderColor, scale, font, alignX, alignY, false, false, false, false )
  44.     dxDrawText ( text, x - 1, y, w - 1, h, borderColor, scale, font, alignX, alignY, false, false, false, false)
  45.     dxDrawText ( text, x + 1, y, w + 1, h, borderColor, scale, font, alignX, alignY, false, false, false, false )
  46.     dxDrawText ( text, x, y - 1, w, h - 1, borderColor, scale, font, alignX, alignY, false, false, false, false )
  47.     dxDrawText ( text, x, y + 1, w, h + 1, borderColor, scale, font, alignX, alignY, false, false, false, false )
  48.     dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, false, false, false, false )
  49. end
  50.  
  51. -- Draw bordered rectangle
  52. function dxDrawBorderedRectangle( x, y, width, height, color, postGUI )
  53.     dxDrawLine ( x, y, x+width, y, color, 1, postGUI or false )
  54.     dxDrawLine ( x, y, x, y+height, color, 1, postGUI or false )
  55.     dxDrawLine ( x, y+height, x+width, y+height, color, 1, postGUI or false )
  56.     dxDrawLine ( x+width, y, x+width, y+height, color, 1, postGUI or false )
  57.     return true
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement