Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. local sx, sy = guiGetScreenSize();
  2. local ch = {};
  3.  
  4. showCursor(true);
  5.  
  6. for i=1,3 do
  7.     ch['x'..i] = sx;
  8.     ch['alpha'..i] = 50;
  9. end
  10.  
  11. local function showAnimation()
  12.     local elapsedTime = getTickCount() - ch.startTime;
  13.     local progress = elapsedTime / 500;
  14.  
  15.     ch['x'..ch.id], ch['alpha'..ch.id], _ = interpolateBetween(ch['x'..ch.id], ch['alpha'..ch.id], 0,
  16.         sx - 300, 200, 0,
  17.         progress, 'InOutQuad');
  18.  
  19.     if progress >= 1 then
  20.         removeEventHandler('onClientRender', root, showAnimation);
  21.     end
  22. end
  23.  
  24. local function hideAnimation()
  25.     local elapsedTime = getTickCount() - ch.startTime;
  26.     local progress = elapsedTime / 500;
  27.  
  28.     ch['x'..ch.id], ch['alpha'..ch.id], _ = interpolateBetween(ch['x'..ch.id], ch['alpha'..ch.id], 0,
  29.         sx, 50, 0,
  30.         progress, 'InOutQuad');
  31.  
  32.     if progress >= 1 then
  33.         removeEventHandler('onClientRender', root, hideAnimation);
  34.     end
  35. end
  36.  
  37. ch[1] = guiCreateLabel(sx - 300, sy / 2 - 200, 300, 100, '', false);
  38. ch[2] = guiCreateLabel(sx - 300, sy / 2 - 50, 300, 100, '', false);
  39. ch[3] = guiCreateLabel(sx - 300, sy / 2 + 100, 300, 100, '', false);
  40.  
  41. local function drawRectangles()
  42.     dxDrawRectangle(sx - 300, sy / 2 - 200, 300, 100, tocolor(0, 0, 0, 100));
  43.     dxDrawRectangle(sx - 300, sy / 2 - 50, 300, 100, tocolor(0, 0, 0, 100));
  44.     dxDrawRectangle(sx - 300, sy / 2 + 100, 300, 100, tocolor(0, 0, 0, 100));
  45.  
  46.     dxDrawRectangle(ch.x1, sy / 2 - 200, sx - ch.x1, 100, tocolor(0, 0, 0, ch.alpha1));
  47.     dxDrawRectangle(ch.x2, sy / 2 - 50, sx - ch.x2, 100, tocolor(0, 0, 0, ch.alpha2));
  48.     dxDrawRectangle(ch.x3, sy / 2 + 100, sx - ch.x3, 100, tocolor(0, 0, 0, ch.alpha3));
  49. end
  50.  
  51. addEventHandler('onClientRender', root, drawRectangles)
  52.  
  53. addEventHandler('onClientMouseEnter', root, function()
  54.     ch.startTime = getTickCount();
  55.     if source == ch[1] then
  56.         ch.id = 1;
  57.         addEventHandler('onClientRender', root, showAnimation);
  58.     end
  59.  
  60.     if source == ch[2] then
  61.         ch.id = 2;
  62.         addEventHandler('onClientRender', root, showAnimation);
  63.     end
  64.  
  65.     if source == ch[3] then
  66.         ch.id = 3;
  67.         addEventHandler('onClientRender', root, showAnimation);
  68.     end
  69. end)
  70.  
  71. addEventHandler('onClientMouseLeave', root, function()
  72.     ch.startTime = getTickCount();
  73.     if source == ch[1] then
  74.         ch.id = 1;
  75.         addEventHandler('onClientRender', root, hideAnimation);
  76.     end
  77.  
  78.     if source == ch[2] then
  79.         ch.id = 2;
  80.         addEventHandler('onClientRender', root, hideAnimation);
  81.     end
  82.  
  83.     if source == ch[3] then
  84.         ch.id = 3;
  85.         addEventHandler('onClientRender', root, hideAnimation);
  86.     end
  87. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement