Fix get closest player util
This commit is contained in:
@@ -1186,16 +1186,19 @@ function getClosestCivilian(position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestPlayer(position, exemptClient) {
|
||||
let clients = getClients();
|
||||
let closest = 0;
|
||||
for(let i in clients) {
|
||||
if(exemptClient != clients[i]) {
|
||||
if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return clients[closest];
|
||||
//let clients = getClients();
|
||||
//let closest = 0;
|
||||
//for(let i in clients) {
|
||||
// if(exemptClient != clients[i]) {
|
||||
// if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
|
||||
// closest = i;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return getElementsByType(ELEMENT_PLAYER).filter((fp) => fp != exemptClient).reduce((i, j) => ((i.position.distance(position) <= j.position.distance(position)) ? i : j));
|
||||
|
||||
//return clients[closest];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1569,4 +1572,10 @@ function clearTemporaryPeds() {
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getVehicleTrunkPosition(vehicle) {
|
||||
return getPosBehindPos(getVehiclePosition(vehicle), getVehicleHeading(vehicle), 3);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user