Files
reallife-gamemode/ReallifeGamemode.Client/Gui/blips.ts
kookroach 3dbd7975f2 Push
2021-04-04 23:08:29 +02:00

42 lines
1.5 KiB
TypeScript

const Natives = {
SET_BLIP_CATEGORY: RageEnums.Natives.Ui.SET_BLIP_CATEGORY,
SHOW_HEADING_INDICATOR_ON_BLIP: RageEnums.Natives.Ui.SHOW_HEADING_INDICATOR_ON_BLIP,
SET_BLIP_AS_SHORT_RANGE: RageEnums.Natives.Ui.SET_BLIP_AS_SHORT_RANGE,
SET_BLIP_DISPLAY: RageEnums.Natives.Ui.SET_BLIP_DISPLAY
};
export default function playerBlips() {
mp.events.add("entityStreamIn", (entity) => {
mp.game.wait(500);
if (entity.type === "player") {
var entityMp = <EntityMp>entity;
let color = parseInt(entity.getVariable("blipColor"));
entity.createBlip(1);
var blip = entity.blip;
entity.setBlipColor(isNaN(color) ? 0 : color);
mp.game.invoke(Natives.SET_BLIP_CATEGORY, entity.blip, 7);
mp.game.invoke(Natives.SHOW_HEADING_INDICATOR_ON_BLIP, entity.blip, true);
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, entity.blip, true);
mp.game.invoke(Natives.SET_BLIP_DISPLAY, entity.blip, 8);
}
});
mp.events.add("entityStreamOut", (entity) => {
if (entity.type === "player") {
entity.blip = null;
}
});
mp.events.addDataHandler("blipColor", (entity, value) => {
if (entity.type === "player") {
//mp.gui.chat.push("Setting Blip color...");
let color = parseInt(value);
entity.setBlipColor(isNaN(color) ? 0 : color);
// mp.gui.chat.push("Player blip color was set.");
}
});
}