Advertisement
Guest User

1234

a guest
Feb 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. --HideAllHUDElement
  2. setPlayerHudComponentVisible("all", false)
  3. setPlayerHudComponentVisible("crosshair", true)
  4. --InventoryDisplay
  5. keyState = 0;
  6. bindKey("i","down",function()
  7.     if keyState == 0 then
  8.         --létrehoz
  9.         addEventHandler("onClientRender",root,showHUD)
  10.         keyState = 1;
  11.     else
  12.         --Elrejt
  13.         addEventHandler("onClientResourceStart",root,hideHUD)
  14.         keyState = 0;
  15.     end
  16.     outputChatBox(keyState);
  17. end)
  18.  
  19. function showHUD()
  20.     zoomCameraIn();
  21.    
  22.  
  23. end
  24. function hideHUD()
  25.     zoomCameraOut();
  26.     outputChatBox("ELREJT");
  27. end
  28.  
  29. function zoomCameraIn()
  30.     local x, y, z, tx, ty, tz = getCameraMatrix()
  31.     local fov = 70
  32.     Moove()
  33.     createAnimation(70, 60, "InOutQuad", 300, function(value)
  34.         fov = value
  35.         setCameraMatrix(x, y, z, tx, ty, tz, 0, fov)
  36.     end)
  37. end
  38.  
  39. function zoomCameraOut()
  40.     local x, y, z, tx, ty, tz = getCameraMatrix()
  41.     local fov = 60
  42.     createAnimation(60, 70, "InOutQuad", 300, function(value)
  43.         fov = value
  44.         setCameraMatrix(x, y, z, tx, ty, tz, 0, fov)
  45.     end)
  46.     setTimer(function()
  47.     removeEventHandler("onClientRender",root,Moove);
  48.     setCameraTarget(localPlayer)
  49.     end, 300, 1)
  50. end
  51.  
  52.  
  53. local anims, builtins = { }, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce"}
  54.  
  55. function table.find(t, v)
  56.     for k,a in ipairs(t) do
  57.         if a == v then return true end
  58.     end
  59.     return false
  60. end
  61.  
  62. function createAnimation(f, t, easing, duration, onChange, onEnd)
  63.     assert(type(f) == "number", "Bad argument @ 'createAnimation' [expected number at argument 1, got "..type(f).."]")
  64.     assert(type(t) == "number", "Bad argument @ 'createAnimation' [expected number at argument 2, got "..type(t).."]")
  65.     assert(type(easing) == "string" or (type(easing) == "number" and (easing >= 1 or easing <= #builtins)), "Bad argument @ 'createAnimation' [Invalid easing at argument 3]")
  66.     assert(type(duration) == "number", "Bad argument @ 'createAnimation' [expected number at argument 4, got "..type(duration).."]")
  67.     assert(type(onChange) == "function", "Bad argument @ 'createAnimation' [expected function at argument 5, got "..type(onChange).."]")
  68.     return table.insert(anims, {from = f, to = t, easing = table.find(builtins, easing) and easing or builtins[easing], duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd})
  69. end
  70.  
  71. addEventHandler("onClientRender", root, Moove)
  72. function Moove()
  73.     local now = getTickCount( )
  74.     for k,v in ipairs(anims) do
  75.         v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing))
  76.         if now >= v.start+v.duration then
  77.             table.remove(anims, k)
  78.             if type(v.onEnd) == "function" then
  79.                 v.onEnd( )
  80.             end
  81.         end
  82.     end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement