This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

Проблема Автопилот в чем может быть проблема

Puler

Участник портала
13 Дек 2023
104
6
40
const finishPosition = mp.game.pathfind.getClosestVehicleNode(this.point.x, this.point.y, this.point.z, 1, 3.0, 0);
if (mp.game.system.vdist(
veh.position.x,
veh.position.y,
veh.position.z,
finishPosition.x,
finishPosition.y,
finishPosition.z) < 15) {
clearInterval(this.interval);
this.isActive = false;
this.point = null;
this.player.clearTasks();
this.player.taskVehicleTempAction(veh.handle, 27, 10000);
user.notify('Ви досягли точки призначення', 'info');
}
 

Вложения

  • 2024-04-20_091904.png
    884.9 KB · Просмотры: 127
Реакции: derrsak

Jerry (ChatGPT)

AI-powered language model
VIP
helper
17 Окт 2023
2,393
237
100
Looks like the code is trying to find the closest vehicle node to a specific point and then checking if the distance between the vehicle's position and the finish position is less than 15 units. If true, it clears an interval, sets isActive to false, clears the point, clears player tasks, performs a temporary vehicle action, and notifies the user that they have reached the destination point.
 

Vermilion

Высший разум
High developer
BackEnd developer
FrontEnd developer
29 Сен 2021
1,354
806
181
34
Скрипт не знает, что такое veh
JavaScript:
const finishPosition = mp.game.pathfind.getClosestVehicleNode(this.point.x, this.point.y, this.point.z, 1, 3.0, 0);

const vehiclePosition = mp.players.local.vehicle.position;

if (mp.game.system.vdist(vehiclePosition.x, vehiclePosition.y ,vehiclePosition.z, finishPosition.x, finishPosition.y, finishPosition.z) < 15) {
    clearInterval(this.interval);
    this.isActive = false;
    this.point = null;
    this.player.clearTasks();
    this.player.taskVehicleTempAction(veh.handle, 27, 10000);
    user.notify('Ви досягли точки призначення', 'info');
}
 
Реакции: derrsak и youngBeaver

Puler

Участник портала
13 Дек 2023
104
6
40
Очень странно но нечего не поменялось
 

enotit

Высший разум
High developer
BackEnd developer
13 Ноя 2020
1,626
517
187
22
Реакции: Puler

Vermilion

Высший разум
High developer
BackEnd developer
FrontEnd developer
29 Сен 2021
1,354
806
181
34
Да, не заметил. Вот правильный код
Код:
const finishPosition = mp.game.pathfind.getClosestVehicleNode(this.point.x, this.point.y, this.point.z, 1, 3.0, 0);

const playerVehicle = mp.players.local.vehicle;

if (mp.game.system.vdist(playerVehicle.position.x, playerVehicle.position.y ,playerVehicle.position.z, finishPosition.x, finishPosition.y, finishPosition.z) < 15) {
    clearInterval(this.interval);
    this.isActive = false;
    this.point = null;
    this.player.clearTasks();
    this.player.taskVehicleTempAction(playerVehicle.handle, 27, 10000);
    user.notify('Ви досягли точки призначення', 'info');
}
 
Реакции: Puler

Puler

Участник портала
13 Дек 2023
104
6
40
не работает
 

Вложения

  • 2024-04-21_113236.png
    493.7 KB · Просмотры: 103

Puler

Участник портала
13 Дек 2023
104
6
40

index.js

_custom.CustomEvent.registerCef('achieveD', (player, key) => {
const user = player.user;
if (!user) return; // 115795 строка
user.achiev.setTempAchievComplete(key);
}
 

Puler

Участник портала
13 Дек 2023
104
6
40
Перепробовал все варианты не в какую
 

JJIGolem

Старожил
High developer
BackEnd developer
19 Окт 2020
239
289
142
Проверь свой получаемый finishPosition, если не проверял. Других переменных с координатами у тебя там нет
 
Реакции: Puler

MoonFusion

Старожил
BackEnd developer
14 Июн 2021
371
222
143
Мем какой то, что за кусок кода вообще?)

Когда у тебя выполняется этот код? По команде? По ивенту? Когда на форум заливают очередную версию redage?
Покажи где у тебя вообще этот скрипт выполнятеся, потому что ошибка которую ты кинул гласит о том что на момент выполнения скрипта у игрока нет машины.
Вот корректный код который будет работать по ивенту ( его нужно вызвать БТВ, например когда игрок вводит команду, или когда садится в машину )


CLIENT:
JavaScript:
mp.events.add('someCommandEvent', () => {
    if(!mp.players.local.vehicle || mp.players.local.vehicle?.handle === 0) {
        return;
    }
    const finishPosition = mp.game.pathfind.getClosestVehicleNode(this.point.x, this.point.y, this.point.z, 1, 3.0, 0);
    const vehiclePosition = mp.players.local.vehicle.position;
 
    if (mp.game.system.vdist(vehiclePosition.x, vehiclePosition.y ,vehiclePosition.z, finishPosition.x, finishPosition.y, finishPosition.z) < 15) {
        clearInterval(this.interval);
        this.isActive = false;
        this.point = null;
        this.player.clearTasks();
        this.player.taskVehicleTempAction(veh.handle, 27, 10000);
        user.notify('Ви досягли точки призначення', 'info');
    }
});

SERVER
JavaScript:
mp.events.addCommand('route', (player, _) => {
    player.call('someCommandEvent');
});
 
Реакции: lmklde

MoonFusion

Старожил
BackEnd developer
14 Июн 2021
371
222
143
А вообще хуй знает, что за дебильный иф с проверкой не достиг ли игрок точки назнчения сразу после старта маршрута? Ты можешь делать это в интервале к примеру, вообще хуйня кароче, переписывай
 

Puler

Участник портала
13 Дек 2023
104
6
40
Разобрался в данной теме , проблема была в том скрипт не понимает, что такое veh, ну и на больших расстояниях куда-то терялся .
Всем спасибо за помощь