Compare commits
2 Commits
master
...
non-server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
133d60ffdd | ||
|
|
ee014b2578 |
@@ -163,12 +163,6 @@ function clearLocalPlayerWeapons(clearData) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestVehicle(pos) {
|
||||
return getElementsByType(ELEMENT_VEHICLE).reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setLocalPlayerPosition(position) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`);
|
||||
if (typeof localPlayer.velocity != "undefined") {
|
||||
|
||||
@@ -1086,12 +1086,6 @@ function getVehiclesInRange(position, range) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestVehicle(position) {
|
||||
return getClosestElementByType(ELEMENT_VEHICLE, position);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestElementByType(elementType, position) {
|
||||
return getElementsByType(elementType).reduce((i, j) => (getDistance(position, getElementPosition(i)) <= getDistance(position, getElementPosition(j))) ? i : j);
|
||||
}
|
||||
|
||||
@@ -963,12 +963,6 @@ function getVehiclesInRange(position, range) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestVehicle(position) {
|
||||
return getClosestElementByType(ELEMENT_VEHICLE, position);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestElementByType(elementType, position) {
|
||||
return getElementsByType(elementType).reduce((i, j) => (getDistance(position, getElementPosition(i)) <= getDistance(position, getElementPosition(j))) ? i : j);
|
||||
}
|
||||
|
||||
@@ -1695,4 +1695,19 @@ function getVehicleColourInfoString(colour, isRGBA) {
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestVehicle(position, interior, dimension) {
|
||||
let closest = 0;
|
||||
let vehicles = getServerData().vehicles;
|
||||
|
||||
for(let i in vehicles) {
|
||||
if(getDistance(getVehiclePosition(vehicles[i].vehicle), position) < getDistance(getVehiclePosition(vehicles[closest].vehicle), position) && getVehicleDimension(vehicles[i].vehicle) == dimension && getVehicleInterior(vehicles[i].vehicle) == interior) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user