Start using data indexes for IV instead of object

This commit is contained in:
Vortrex
2022-08-14 10:54:15 -05:00
parent dc79b4b12a
commit 0142e369c9

View File

@@ -1128,8 +1128,8 @@ function getClosestCivilian(position) {
// =========================================================================== // ===========================================================================
function getVehiclesInRange(position, range) { function getVehiclesInRange(position, range) {
if (getGame() == AGRP_GAME_GTA_IV) { if (!areServerElementsSupported()) {
return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j); return getServerData().vehicles.filter(x => getDistance(position, x.syncPosition) <= distance);
} }
return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range); return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range);
} }
@@ -1137,6 +1137,9 @@ function getVehiclesInRange(position, range) {
// =========================================================================== // ===========================================================================
function getClosestVehicle(position) { function getClosestVehicle(position) {
if (!areServerElementsSupported()) {
getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j);
}
return getClosestElementByType(ELEMENT_VEHICLE, position); return getClosestElementByType(ELEMENT_VEHICLE, position);
} }