Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Teleport = createMarker(X, Y, Z, "corona", SIZE, 0, 0, 0)
- addEventHandler("onClientMarkerHit", getRootElement(), function(playerid)
- if playerid == localPlayer then
- if isPedInVehicle(localPlayer) then
- local vehicleid = getPedOccupiedVehicle(localPlayer)
- if source == Teleport then
- fadeCamera(false, 0.7, 0, 0, 0)
- easeGameSpeed(0.2, 1500, function()
- setElementPosition(vehicleid, targetX, targetY, targetZ)
- setElementRotation(vehicleid, targetRotX, targetRotY, targetRotZ)
- setCameraTarget(localPlayer)
- fadeCamera(true, 1.0)
- setTimer(function()
- --setElementVelocity(vehicleid, velX, velY, velZ) -- Optional: Velocity
- --setVehicleTurnVelocity(vehicleid, angularVelX, angularVelY, angularVelZ) -- Optional: Angular Velocity
- easeGameSpeed(1.0, 2000)
- end, 500, 1)
- end)
- end
- end
- end
- end)
- local ease = {}
- function easeGameSpeed(targetSpeed, overTime, callback)
- ease.startedAt = getTickCount()
- ease.startSpeed = getGameSpeed()
- ease.targetSpeed = math.round(targetSpeed, 4, "floor")
- ease.overTime = overTime
- ease.callback = (type(callback) == "function" or type(callback) == "nil") and (type(callback) == "function" and callback or nil) or nil
- ease.isActive = true
- end
- addEventHandler("onClientRender", root, function()
- if ease.isActive then
- local progress = (getTickCount() - ease.startedAt) / ((ease.startedAt + ease.overTime) - ease.startedAt)
- local currentSpeed = math.round(getGameSpeed(), 1, (ease.startSpeed > ease.targetSpeed and "ceil" or "floor"))
- local X, Y, Z = interpolateBetween(currentSpeed, 0.0, 0.0, ease.targetSpeed, 0.0, 0.0, progress, "InOutQuad")
- X = math.round(X, 4, (ease.startSpeed > ease.targetSpeed and "floor" or "ceil"))
- if ease.startSpeed > ease.targetSpeed and X <= ease.targetSpeed then
- X = math.round(X, 1, "ceil")
- elseif ease.startSpeed < ease.targetSpeed and X >= ease.targetSpeed then
- X = math.round(X, 1, "floor")
- end
- setGameSpeed(X)
- if X == ease.targetSpeed then
- ease.isActive = false
- if type(ease.callback) == "function" then
- ease.callback();
- end
- end
- end
- end)
- function math.round(number, decimals, method)
- decimals = decimals or 0
- local factor = 10 ^ decimals
- if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
- else return tonumber(("%."..decimals.."f"):format(number)) end
- end
Advertisement
Add Comment
Please, Sign In to add comment