diff --git a/ReallifeGamemode.Client/Gui/blips.ts b/ReallifeGamemode.Client/Gui/blips.ts index c465c548..41a62fbd 100644 --- a/ReallifeGamemode.Client/Gui/blips.ts +++ b/ReallifeGamemode.Client/Gui/blips.ts @@ -7,6 +7,43 @@ export default function playerBlips() { + + var playerBlipMap: Map; + + mp.events.add("render", async () => { + if (!playerBlipMap) playerBlipMap = new Map(); + + mp.players.forEachInStreamRange( + (player) => { + if (!playerBlipMap.has(player)) { + let pBlip = mp.blips.new(1, player.position); + + let color = player.getVariable("blipColor"); + pBlip.setColour(isNaN(color) ? 0 : color); + + mp.game.invoke(Natives.SET_BLIP_CATEGORY, pBlip, 7); + mp.game.invoke(Natives.SHOW_HEADING_INDICATOR_ON_BLIP, pBlip, true); + mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, pBlip, true); + mp.game.invoke(Natives.SET_BLIP_DISPLAY, pBlip, 8); + playerBlipMap.set(player, pBlip); + } + let pBlip = playerBlipMap.get(player); + pBlip.setPosition(player.position.x, player.position.y, player.position.z); + pBlip.setRotation(player.heading); + }); + }); + + mp.events.add("entityStreamOut", (entity) => { + if (playerBlipMap && entity.type === "player") { + if (playerBlipMap.has(entity)) { + var pBlip = playerBlipMap.get(entity); + pBlip.destroy(); + playerBlipMap.delete(entity); + } + } + }); + + /* mp.events.add("entityStreamIn", async (entity) => { await mp.game.waitAsync(100); if (entity.type === "player") { @@ -22,6 +59,7 @@ export default function playerBlips() { } }); + */ mp.events.addDataHandler("blipColor", (entity, value) => {