Start using IDs instead of element objects

This commit is contained in:
Vortrex
2022-05-31 08:35:40 -05:00
parent eabf63cf86
commit ee014b2578
4 changed files with 15 additions and 18 deletions

View File

@@ -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;
}
// ===========================================================================