Change Nametag
Clothes test
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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<bool>("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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user