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) => {
        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") {
            var blip = <BlipMp>entity.blip
            blip.destroy();
        }
    });

    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.");
        }
    });
}