Advertisement
RidwanRF

dxHUD

Feb 10th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.91 KB | None | 0 0
  1. local sx, sy = guiGetScreenSize();
  2. local timer = 500;
  3. local info = {};
  4. local showed = false;
  5.  
  6. local x = sx - 50;
  7. local alpha = 100;
  8.  
  9. addEventHandler('onClientResourceStart', resourceRoot, function()
  10.         bindKey ('i', 'down', showOrHide);
  11.         info.startTime = getTickCount();
  12. end);
  13.  
  14. function showOrHide()
  15.         info.startTime = getTickCount();
  16.         showed = not showed;
  17.  
  18.         if (showed) then
  19.                 removeEventHandler('onClientRender',root,showFunction);
  20.                 addEventHandler('onClientRender',root,hideFunction);
  21.         else
  22.                 addEventHandler('onClientRender',root,showFunction);
  23.                 removeEventHandler('onClientRender',root,hideFunction);
  24.         end;
  25. end;
  26.  
  27. function showFunction()
  28.         local now = getTickCount();
  29.         local elapsedTime = now - info.startTime;
  30.         local duration = timer;
  31.         local progress = elapsedTime / duration;
  32.  
  33.         _, alpha, x = interpolateBetween (
  34.                 0, alpha, x,
  35.                 0, 200, sx - 350,
  36.                 progress, 'InOutQuad');
  37. end;
  38.  
  39. function hideFunction()
  40.         local now = getTickCount();
  41.         local elapsedTime = now - info.startTime;
  42.         local duration = timer;
  43.         local progress = elapsedTime / duration;
  44.  
  45.         _, alpha, x = interpolateBetween (
  46.                 0, alpha, x,
  47.                 0, 100, sx - 50,
  48.                 progress, 'InOutQuad');
  49. end;
  50.  
  51. function drawInfo()
  52.         local posVector = localPlayer.position;
  53.         local rotVector = localPlayer.rotation;
  54.         local zone = getZoneName (posVector.x, posVector.y, posVector.z, false);
  55.         local city = getZoneName (posVector.x, posVector.y, posVector.z, true);
  56.         local vx, vy, vz = 0, 0, 0;
  57.  
  58.         if (localPlayer.inVehicle) then
  59.                 local vehicle = localPlayer.vehicle;
  60.                 velocityVector = vehicle.velocity;
  61.         else
  62.                 velocityVector = localPlayer.velocity;
  63.         end;
  64.  
  65.         if zone == city then
  66.                 zoneString = zone;
  67.         else
  68.                 zoneString = zone..', '..city;
  69.         end;
  70.  
  71.         dxDrawRectangle( x, sy / 2 - 150, 350, 300, tocolor ( 30, 30, 30, alpha ), false);
  72.         dxDrawRectangle( x, sy / 2 - 150, 50, 300, tocolor ( 90, 90, 255, alpha ), false);
  73.         dxDrawImage(x, sy / 2 - 150, 50, 300, 'title.png', 0, 0, 0, tocolor (255, 255, 255, alpha *1.2), false);
  74.  
  75.         dxDrawText(zoneString, x + 60, sy / 2 - 140, sx - 10, sy / 2 - 120, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  76.         dxDrawLine(x + 55, sy / 2 - 121, sx - 10, sy / 2 - 121, tocolor (65, 65, 65, alpha), 1, false);
  77.  
  78.         dxDrawText(math.ceil(posVector.x)..', '..math.ceil(posVector.y)..', '..math.ceil(posVector.z), x + 60, sy / 2 - 120, sx - 10, sy / 2 - 100, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  79.         dxDrawLine(x + 55, sy / 2 - 101, sx - 10, sy / 2 - 101, tocolor (65, 65, 65, alpha), 1, false);
  80.  
  81.         dxDrawText('Rotation: '..math.ceil(rotVector.z)..', Skin: '..localPlayer.model, x + 60, sy / 2 - 100, sx - 10, sy / 2 - 80, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  82.         dxDrawLine(x + 55, sy / 2 - 81, sx - 10, sy / 2 - 81, tocolor (65, 65, 65, alpha), 1, false);
  83.  
  84.         dxDrawText('Health: '..math.floor(localPlayer.health)..', Armor: '..math.ceil(localPlayer.armor), x + 60, sy / 2 - 80, sx - 10, sy / 2 - 60, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  85.         dxDrawLine(x + 55, sy / 2 - 61, sx - 10, sy / 2 - 61, tocolor (65, 65, 65, alpha), 1, false);
  86.  
  87.         dxDrawText('Ping: '..localPlayer.ping, x + 60, sy / 2 - 60, sx - 10, sy / 2 - 40, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  88.         dxDrawLine(x + 55, sy / 2 - 41, sx - 10, sy / 2 - 41, tocolor (65, 65, 65, alpha), 1, false);
  89.  
  90.         dxDrawText(math.ceil(((velocityVector.x^2 + velocityVector.y^2 + velocityVector.z^2)^(0.5)) * 161)..' km/h', x + 60, sy / 2 - 40, sx - 10, sy / 2 - 20, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  91.         dxDrawLine(x + 55, sy / 2 - 21, sx - 10, sy / 2 - 21, tocolor (65, 65, 65, alpha), 1, false);
  92.  
  93.         dxDrawText('$'..localPlayer.money, x + 60, sy / 2 - 20, sx - 10, sy / 2, tocolor ( 0, 220, 0, alpha ), 1, 'default', 'left', 'center', true, false, false);
  94.         dxDrawLine(x + 55, sy / 2 - 1, sx - 10, sy / 2 - 1, tocolor (65, 65, 65, alpha), 1, false);
  95.  
  96.         dxDrawText('Oxygen: '..math.ceil(localPlayer.oxygenLevel/10)..'%', x + 60, sy / 2, sx - 10, sy / 2 + 20, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  97.         dxDrawLine(x + 55, sy / 2 + 19, sx - 10, sy / 2 + 19, tocolor (65, 65, 65, alpha), 1, false);
  98.  
  99.         dxDrawText(('You %s be knocked off bike.'):format(localPlayer:canBeKnockedOffBike() and 'can' or 'can\'t'), x + 60, sy / 2 + 20, sx - 10, sy / 2 + 40, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  100.         dxDrawLine(x + 55, sy / 2 + 39, sx - 10, sy / 2 + 39, tocolor (65, 65, 65, alpha), 1, false);
  101.  
  102.         dxDrawText(('You %shave a jetpack.'):format(doesPedHaveJetPack(localPlayer) and '' or 'don\'t '), x + 60, sy / 2 + 40, sx - 10, sy / 2 + 60, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  103.         dxDrawLine(x + 55, sy / 2 + 59, sx - 10, sy / 2 + 59, tocolor (65, 65, 65, alpha), 1, false);
  104.  
  105.         dxDrawText('Interior: '..localPlayer.interior..', Dimension: '..localPlayer.dimension, x + 60, sy / 2 + 60, sx - 10, sy / 2 + 80, tocolor ( 255, 255, 255, alpha ), 1, 'default', 'left', 'center', true, false, false);
  106.         dxDrawLine(x + 55, sy / 2 + 79, sx - 10, sy / 2 + 79, tocolor (65, 65, 65, alpha), 1, false);
  107. end;
  108.  
  109. addEventHandler('onClientRender', root, drawInfo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement