From b781af9a751fa4fc3ef61ed59e500d5337d164cc Mon Sep 17 00:00:00 2001 From: kookroach <62265045+kookroach@users.noreply.github.com> Date: Sun, 4 Apr 2021 17:31:53 +0200 Subject: [PATCH] Change Nametag Clothes test --- ReallifeGamemode.Client/Gui/nametags.ts | 35 ++++++++++--- .../Interaction/clothes/ClotheShop.ts | 49 +++++++++++++++++-- ReallifeGamemode.Server/Events/Key.cs | 9 ++-- ReallifeGamemode.Server/Events/Login.cs | 10 ++-- 4 files changed, 81 insertions(+), 22 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index df6fc96d..76ce2308 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -5,23 +5,45 @@ 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 + + { id: 0, color: [255, 255, 255, alpha] }, //civil + + //1 to n + { id: 1, color: [0, 95, 190, alpha] }, //pd + { id: 2, color: [200, 0, 0, alpha] }, //lsed + { id: 3, color: [0, 0, 170, alpha] }, //fib + { id: 4, color: [255, 180, 0, alpha] }, //trucker + { id: 5, color: [255, 255, 255, alpha] }, //terroristen + { id: 6, color: [255, 255, 255, alpha] }, //hitman + { id: 7, color: [0, 54, 0, alpha] }, //grove + { id: 8, color: [171, 0, 207, alpha] }, //ballas + { id: 9, color: [0, 166, 133, alpha] }, //news +]; + export default function customNametags() { mp.nametags.enabled = false; - /* + var color = [255, 255, 255, alpha]; + + mp.events.addDataHandler("nameTagColor", (entity, value) => { if (entity.type === "player") { - var color = JSON.parse(value); - entity.setVariable('nametagColor',color) - //mp.gui.chat.push(color); + let temp = colors.find(c => c.id === value); + if (!temp) + return; + color = 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; @@ -43,8 +65,7 @@ export default function customNametags() { mp.game.graphics.drawText(player.name + " (" + player.remoteId + ")", [x, y], { font: 4, - //color: [player.data.nametagColor[0], player.data.nametagColor[1], player.data.nametagColor[2], 200], //Grove //Ballas 171 0 207 //PD 0 95 190 //FIB 0 0 170 LSED 147 0 0 NR 0 166 133 Trucker 255 162 Support 0 255 255 Zivilist 255 255 255 - color: [255, 255, 255, 255], + color: [color[0], color[1], color[2], color[3]], scale: [0.4, 0.4], outline: true, centre: false diff --git a/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts b/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts index 9eb0dccf..5f02e815 100644 --- a/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts +++ b/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts @@ -53,7 +53,11 @@ export default function clotheShopList(globalData: IGlobalData) { var myVar; let mainMenu = null; + let categoryMenu = null; + let categoryMenus = []; + let clotheMenus = []; + let clothingData = []; let currentMenuIdx = -1; let menuTransition = false; // workaround for ItemSelect event being called twice between menu transitions @@ -148,7 +152,6 @@ export default function clotheShopList(globalData: IGlobalData) { } function addClothingItems(type, bannerSprite, key, value, gender) { - var categoryMenu; var cloth = []; var tx = []; @@ -172,7 +175,7 @@ export default function clotheShopList(globalData: IGlobalData) { mainMenu.Item // Fill it - let clotheUpperMenu; + let clotheSubMenu; for (const item of value) { if (item.ComponentId == key) { @@ -183,8 +186,8 @@ export default function clotheShopList(globalData: IGlobalData) { if (txData != undefined && txData.length > 0) { categoryMenu.AddItem(new UIMenuItem(mp.game.ui.getLabelText(txData[0].data[0].GXT), "")); - clotheUpperMenu = new UIMenu(" ", mp.game.ui.getLabelText(txData[0].data[0].GXT), new Point(0, 0), bannerSprite.library, bannerSprite.texture); - clotheUpperMenu.Visible = false; + clotheSubMenu = new UIMenu(" ", mp.game.ui.getLabelText(txData[0].data[0].GXT), new Point(0, 0), bannerSprite.library, bannerSprite.texture); + clotheSubMenu.Visible = false; } @@ -199,7 +202,7 @@ export default function clotheShopList(globalData: IGlobalData) { tempItem.SetRightLabel(`${item.Price > 0 ? `$${item.Price}` : "KOSTENLOS"}`); - clotheUpperMenu.AddItem(tempItem); + clotheSubMenu.AddItem(tempItem); cloth.push(item); tx.push(x); @@ -214,6 +217,13 @@ export default function clotheShopList(globalData: IGlobalData) { item: cloth, texture: tx }); + clotheMenus.push({ + menu: clotheSubMenu, + type: type, + slotIdx: Number(key), + item: cloth, + texture: tx + }); } function submenuItemChangeHandler(newIndex) { @@ -407,6 +417,35 @@ export default function clotheShopList(globalData: IGlobalData) { currentMenuIdx = -1; lastClothing = null; }); + + // Sub menu events + categoryMenu.ItemSelect.on((selectedItem, itemIndex) => { + const nextMenu = clotheMenus[itemIndex]; + const slot = Number(nextMenu.slotIdx); + + lastClothing = { + type: nextMenu.type, + slotIdx: slot, + drawable: (nextMenu.type === "props" ? localPlayer.getPropIndex(slot) : localPlayer.getDrawableVariation(slot)), + texture: (nextMenu.type === "props" ? localPlayer.getPropTextureIndex(slot) : localPlayer.getTextureVariation(slot)), + undershirt: [localPlayer.getDrawableVariation(8), localPlayer.getTextureVariation(8)], + torso: localPlayer.getDrawableVariation(3) + }; + + currentMenuIdx = itemIndex; + mainMenu.Visible = false; + nextMenu.menu.Visible = true; + menuTransition = true; + + submenuItemChangeHandler(nextMenu.menu.CurrentSelection); + }); + + categoryMenu.MenuClose.on(() => { + currentMenuIdx = -1; + mainMenu.Visible = true; + }); + + } }); diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 703b4916..bd5527fe 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -264,7 +264,6 @@ namespace ReallifeGamemode.Server.Events } if (nearestDuty != null)// Duty Point { - var nameTagColor = new Color(0, 0, 0); var factionId = user.FactionId; if (user.GetData("duty") == false) @@ -282,7 +281,7 @@ namespace ReallifeGamemode.Server.Events case 1: //nameTagColor = new Color(28, 134, 238); //player.TriggerEvent("setNameTag", JsonConvert.SerializeObject(new int[] { 28, 134, 238 })); - //player.SetSharedData("nameTagColor", JsonConvert.SerializeObject(new int[] { 28, 134, 238})); + player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 38); break; @@ -290,14 +289,14 @@ namespace ReallifeGamemode.Server.Events case 2: //nameTagColor = new Color(255, 0, 0); //player.TriggerEvent("setNameTag", JsonConvert.SerializeObject(new int[] { 255, 0, 0 })); - //player.SetSharedData("nameTagColor", new int[] { 255, 0, 0}); + player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 79); break; //FBI case 3: //nameTagColor = new Color(173, 0, 118); - //player.SetSharedData("nameTagColor", new int[] { 173, 0, 118}); + player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 72); player.SetAccessories(2, 2, 0); break; @@ -333,7 +332,7 @@ namespace ReallifeGamemode.Server.Events player.TriggerEvent("toggleDutyMode", false); Medic.UpdateDutyMedics(-1); player.SetSharedData("blipColor", 0); - //player.SetSharedData("nameTagColor", new Color[255, 255, 255, 255]); + player.SetSharedData("nameTagColor", 0); UpdateCharacterCloth.LoadCharacterDefaults(player); } } diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index 4667db80..a4cc1551 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -104,22 +104,22 @@ namespace ReallifeGamemode.Server.Events { case null: player.SetSharedData("blipColor", 0); - //player.SetSharedData("nameTagColor", new int[] { 255, 255, 255 }); + player.SetSharedData("nameTagColor", 0); break; case 0: player.SetSharedData("blipColor", 0); - //player.SetSharedData("nameTagColor", new int[] { 255, 255, 255 }); + player.SetSharedData("nameTagColor", 0); break; case 8: player.SetSharedData("blipColor", 83); - //player.SetSharedData("nameTagColor", new int[]{171, 0, 207}); + player.SetSharedData("nameTagColor", user.FactionId); break; case 7: player.SetSharedData("blipColor", 52); - //player.SetSharedData("nameTagColor", new int[] { 0, 54, 0}); + player.SetSharedData("nameTagColor", user.FactionId); break; case 4: @@ -127,7 +127,7 @@ namespace ReallifeGamemode.Server.Events break; case 9: player.SetSharedData("blipColor", 25); - //player.SetSharedData("nameTagColor", new int[] { 0, 166, 133}); + player.SetSharedData("nameTagColor", user.FactionId); break; }