Jump to content

Get Local Vehicle


Recommended Posts

function getNearestVeicle(player) 
    local x, y, z = getElementPosition(player) 
    local prevDistance 
    local nearestVehicle 
    for i, v in ipairs( getElementsByType( "vehicle" ) ) do 
        local dist = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) 
        if dist <= ( prevDistance or dist + 1 )  then 
            prevDistance = dist 
            nearestVehicle = v 
            setElementHealth ( v, 800 ) 
        end 
    end 
    return nearestVehicle or false 
end 
addCommandHandler("repaircar", getNearestVeicle) 

Esse é o script e não está funcionando, peguei na internet e tentei editar algumas coisas más mesmo assim não funciona

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...