diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index a467c29d..462bf1a8 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -1,11 +1,14 @@ -const maxDistance = 25 * 25; +import { IGame, IEntity } from "../game"; +import game from ".."; + + +const maxDistance = 25 * 25; const width = 0.03; const height = 0.0065; const border = 0.001; -const color = [73, 137, 0, 255]; -var faction; -var playerColors = []; + const alpha = 250; + const colors = [ { id: -2, color: [0, 255, 255, alpha] }, //support { id: -1, color: [255, 100, 0, alpha] }, //wanted @@ -28,24 +31,21 @@ const colors = [ export default function customNametags() { mp.nametags.enabled = false; - var color = [255, 255, 255, alpha]; mp.events.addDataHandler("nameTagColor", (entity: EntityMp, value) => { if (entity.type === "player") { + var player = game.players.at(entity.remoteId); + let temp = colors.find(c => c.id === value); if (!temp) { - entity.setVariable("nametagColor", [255, 255, 255, alpha]); + player.nametagColor = [255, 255, 255, alpha]; return; } - entity.setVariable("nametagColor", temp.color); + player.nametagColor = temp.color; } }); - mp.events.add('setNameTag', (value) => { - var color = JSON.parse(value); - mp.gui.chat.push(color); - }); mp.events.add('render', (nametags) => { const graphics = mp.game.graphics; @@ -64,7 +64,7 @@ export default function customNametags() { var armour = player.getArmour() / 100; y -= scale * (0.005 * (screenRes.y / 1080)); - let color = player.data.nametagColor; + let color = game.players.at(player.remoteId).nametagColor; mp.game.graphics.drawText(player.name + " (" + player.remoteId + ")", [x, y], { font: 4, diff --git a/ReallifeGamemode.Client/game.ts b/ReallifeGamemode.Client/game.ts index 1ed19923..05a95326 100644 --- a/ReallifeGamemode.Client/game.ts +++ b/ReallifeGamemode.Client/game.ts @@ -53,6 +53,7 @@ interface IPlayer extends IEntity { inVehicle: boolean; name: string; vehicle: IVehicle; + nametagColor: number[]; } interface IObject extends IEntity { diff --git a/ReallifeGamemode.Client/util/attachmentMngr.ts b/ReallifeGamemode.Client/util/attachmentMngr.ts index 60ba0235..7cb9c80a 100644 --- a/ReallifeGamemode.Client/util/attachmentMngr.ts +++ b/ReallifeGamemode.Client/util/attachmentMngr.ts @@ -1,5 +1,4 @@ -import { IGame, EntityType, IEntity } from "../game"; -import relativeVector from "./relativevector"; +import { IGame, IEntity } from "../game"; var attachId = 0;