Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --HideAllHUDElement
- setPlayerHudComponentVisible("all", false)
- setPlayerHudComponentVisible("crosshair", true)
- --InventoryDisplay
- keyState = 0;
- bindKey("i","down",function()
- if keyState == 0 then
- --létrehoz
- addEventHandler("onClientRender",root,showHUD)
- keyState = 1;
- else
- --Elrejt
- addEventHandler("onClientResourceStart",root,hideHUD)
- keyState = 0;
- end
- outputChatBox(keyState);
- end)
- function showHUD()
- zoomCameraIn();
- end
- function hideHUD()
- zoomCameraOut();
- outputChatBox("ELREJT");
- end
- function zoomCameraIn()
- local x, y, z, tx, ty, tz = getCameraMatrix()
- local fov = 70
- Moove()
- createAnimation(70, 60, "InOutQuad", 300, function(value)
- fov = value
- setCameraMatrix(x, y, z, tx, ty, tz, 0, fov)
- end)
- end
- function zoomCameraOut()
- local x, y, z, tx, ty, tz = getCameraMatrix()
- local fov = 60
- createAnimation(60, 70, "InOutQuad", 300, function(value)
- fov = value
- setCameraMatrix(x, y, z, tx, ty, tz, 0, fov)
- end)
- setTimer(function()
- removeEventHandler("onClientRender",root,Moove);
- setCameraTarget(localPlayer)
- end, 300, 1)
- end
- local anims, builtins = { }, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce"}
- function table.find(t, v)
- for k,a in ipairs(t) do
- if a == v then return true end
- end
- return false
- end
- function createAnimation(f, t, easing, duration, onChange, onEnd)
- assert(type(f) == "number", "Bad argument @ 'createAnimation' [expected number at argument 1, got "..type(f).."]")
- assert(type(t) == "number", "Bad argument @ 'createAnimation' [expected number at argument 2, got "..type(t).."]")
- assert(type(easing) == "string" or (type(easing) == "number" and (easing >= 1 or easing <= #builtins)), "Bad argument @ 'createAnimation' [Invalid easing at argument 3]")
- assert(type(duration) == "number", "Bad argument @ 'createAnimation' [expected number at argument 4, got "..type(duration).."]")
- assert(type(onChange) == "function", "Bad argument @ 'createAnimation' [expected function at argument 5, got "..type(onChange).."]")
- 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})
- end
- addEventHandler("onClientRender", root, Moove)
- function Moove()
- local now = getTickCount( )
- for k,v in ipairs(anims) do
- v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing))
- if now >= v.start+v.duration then
- table.remove(anims, k)
- if type(v.onEnd) == "function" then
- v.onEnd( )
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement