Use INT and VW in closest NPC util

This commit is contained in:
Vortrex
2022-06-12 09:19:39 -05:00
parent 6c0bf2d881
commit 50f6ebe6a6

View File

@@ -297,7 +297,7 @@ function spawnAllNPCs() {
// ===========================================================================
function deleteNPCCommand(command, params, client) {
let closestNPC = getClosestNPC(getPlayerPosition(client));
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
if (!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
@@ -333,7 +333,7 @@ function setNPCAnimationCommand(command, params, client) {
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
let animationId = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
@@ -370,7 +370,7 @@ function setNPCNameCommand(command, params, client) {
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
let name = params;
if (!getNPCData(closestNPC)) {
@@ -389,7 +389,7 @@ function setNPCNameCommand(command, params, client) {
// ===========================================================================
function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
let closestNPC = getClosestNPC(getPlayerPosition(client));
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
if (!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
@@ -471,12 +471,9 @@ function getNPCInfoCommand(command, params, client) {
// ===========================================================================
function getClosestNPC(position) {
function getClosestNPC(position, interior, dimension) {
let npcs = getServerData().npcs;
let interior = getPlayerInterior(client);
let dimension = getPlayerDimension(client);
let closest = 0;
for (let i in npcs) {
if (getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {