[JS] Get Closest Vehicle

Started by Vortrex, July 06, 2019, 11:54:58 PM

Previous topic - Next topic

Vortrex

Works both client and server side.function getClosestVehicle(pos) {
    return getVehicles().reduce((i, j) => (i.position.distance(pos) <= j.position.distance(pos)) ? i : j);
}