Jump to content

Recommended Posts

  • 1 month later...

Hi I Hope I Can Help You :D 

 

--== Script By ErroR (FullOffeD) ==--

-- Set the target position
local targetX, targetY, targetZ = 100, 200, 10

-- Create the vehicle
local vehicle = createVehicle(411, 0, 0, 0) 

-- Get Distance 
function getDistance(x1, y1, z1, x2, y2, z2)
    return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2)
end

function moveVehicleToTarget()
    local x, y, z = getElementPosition(vehicle)
    local distance = getDistance(x, y, z, targetX, targetY, targetZ)

   -- Speed To Move
    local speed = 5

    if distance > 1 then
        local directionX = (targetX - x) / distance
        local directionY = (targetY - y) / distance
        local directionZ = (targetZ - z) / distance

        setElementPosition(vehicle, x + directionX * speed, y + directionY * speed, z + directionZ * speed)

        addEventHandler("onClientRender", root, moveVehicleToTarget)
    else
        removeEventHandler("onClientRender", root, moveVehicleToTarget)
    end
end

Use Thats Code To Move Vehicle To Your Custom x,y,z Without Player ❤️ 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...