Location & Speed Display
Location + Speed Display 1.1.1 || Расположение + Скорость
Location + Speed Display 1.1.1 || Расположение + Скорость
Небольшой скрипт, который отображает ваше местоположение и скорость автомобиля (если вы в нем) на мини-карте.
Чтобы использовать его:
- Создайте каталог playerlocation в client_packages.
- Создайте в нём файл index.js и вставьте в него следующий код.
- После вызовите его в вашем скрипте client_packages / index.js с помощью require ('playerlocation');.
Код данного скрипта:
PHP:
const useSpeedo = true;
const updateInterval = 500; // milliseconds, lower value = more accurate, at the cost of performance
const Natives = {
IS_RADAR_HIDDEN: "0x157F93B036700462",
IS_RADAR_ENABLED: "0xAF754F20EB5CD51A",
SET_TEXT_OUTLINE: "0x2513DFB0FB8400FE"
};
let streetName = null;
let zoneName = null;
let isMetric = false;
let minimap = {};
// https://github.com/glitchdetector/fivem-minimap-anchor
function getMinimapAnchor() {
let sfX = 1.0 / 20.0;
let sfY = 1.0 / 20.0;
let safeZone = mp.game.graphics.getSafeZoneSize();
let aspectRatio = mp.game.graphics.getScreenAspectRatio(false);
let resolution = mp.game.graphics.getScreenActiveResolution(0, 0);
let scaleX = 1.0 / resolution.x;
let scaleY = 1.0 / resolution.y;
let minimap = {
width: scaleX * (resolution.x / (4 * aspectRatio)),
height: scaleY * (resolution.y / 5.674),
scaleX: scaleX,
scaleY: scaleY,
leftX: scaleX * (resolution.x * (sfX * (Math.abs(safeZone - 1.0) * 10))),
bottomY: 1.0 - scaleY * (resolution.y * (sfY * (Math.abs(safeZone - 1.0) * 10))),
};
minimap.rightX = minimap.leftX + minimap.width;
minimap.topY = minimap.bottomY - minimap.height;
return minimap;
}
function drawText(text, drawXY, font, color, scale, alignRight = false) {
mp.game.ui.setTextEntry("STRING");
mp.game.ui.addTextComponentSubstringPlayerName(text);
mp.game.ui.setTextFont(font);
mp.game.ui.setTextScale(scale, scale);
mp.game.ui.setTextColour(color[0], color[1], color[2], color[3]);
mp.game.invoke(Natives.SET_TEXT_OUTLINE);
if (alignRight) {
mp.game.ui.setTextRightJustify(true);
mp.game.ui.setTextWrap(0, drawXY[0]);
}
mp.game.ui.drawText(drawXY[0], drawXY[1]);
}
setInterval(() => {
// only do stuff if radar is enabled and visible
if (mp.game.invoke(Natives.IS_RADAR_ENABLED) && !mp.game.invoke(Natives.IS_RADAR_HIDDEN)) {
isMetric = mp.game.gameplay.getProfileSetting(227) == 1;
minimap = getMinimapAnchor();
const position = mp.players.local.position;
let getStreet = mp.game.pathfind.getStreetNameAtCoord(position.x, position.y, position.z, 0, 0);
zoneName = mp.game.ui.getLabelText(mp.game.zone.getNameOfZone(position.x, position.y, position.z));
streetName = mp.game.ui.getStreetNameFromHashKey(getStreet.streetName);
if (getStreet.crossingRoad && getStreet.crossingRoad != getStreet.streetName) streetName += ` / ${mp.game.ui.getStreetNameFromHashKey(getStreet.crossingRoad)}`;
} else {
streetName = null;
zoneName = null;
}
}, updateInterval);
mp.events.add("render", () => {
if (streetName && zoneName) {
drawText(streetName, [minimap.rightX + 0.01, minimap.bottomY - 0.065], 4, [255, 255, 255, 255], 0.55);
drawText(zoneName, [minimap.rightX + 0.01, minimap.bottomY - 0.035], 4, [255, 255, 255, 255], 0.5);
let vehicle = mp.players.local.vehicle;
if (useSpeedo && vehicle) drawText(`${(vehicle.getSpeed() * (isMetric ? 3.6 : 2.236936)).toFixed(0)} ${(isMetric) ? "KM/H" : "MPH"}`, [minimap.rightX - 0.003, minimap.bottomY - 0.0485], 4, [255, 255, 255, 255], 0.45, true);
}
});
Также можете просто скачать:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
Последнее редактирование: