diff --git a/ReallifeGamemode.Client/Interaction/clothes/female_hair.json b/ReallifeGamemode.Client/Interaction/friseur/female_hair.json similarity index 100% rename from ReallifeGamemode.Client/Interaction/clothes/female_hair.json rename to ReallifeGamemode.Client/Interaction/friseur/female_hair.json diff --git a/ReallifeGamemode.Client/Interaction/friseur/friseur.ts b/ReallifeGamemode.Client/Interaction/friseur/friseur.ts new file mode 100644 index 00000000..48331aea --- /dev/null +++ b/ReallifeGamemode.Client/Interaction/friseur/friseur.ts @@ -0,0 +1,355 @@ +import * as NativeUI from '../../libs/NativeUI'; +import maleHair from "./male_hair.json"; +import femaleHair from "./female_hair.json"; +import main from '../../Jobs/main'; + +const UIMenu = NativeUI.Menu; +const UIMenuItem = NativeUI.UIMenuItem; +const UIMenuListItem = NativeUI.UIMenuListItem; +const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem; +const BadgeStyle = NativeUI.BadgeStyle; +const Point = NativeUI.Point; +const ItemsCollection = NativeUI.ItemsCollection; +const Color = NativeUI.Color; +const maxHairColor = 64; + +export default function friseurShopList(globalData: IGlobalData) { + const categoryTitles = { + clothes: { + 1: "Masks", + 2: "Frisur", + 3: "Torsos", + 4: "Legs", + 5: "Bags and Parachutes", + 6: "Shoes", + 7: "Accessories", + 8: "Undershirts", + 9: "Body Armors", + 10: "Decals", + 11: "Tops" + }, + + props: { + 0: "Hats", + 1: "Glasses", + 2: "Ears", + 6: "Watches", + 7: "Bracelets" + } + }; + + const localPlayer = mp.players.local; + var playerPos; + var myVar; + + let mainMenu = null; + let categoryMenus = []; + let clothingData = []; + let currentMenuIdx = -1; + let menuTransition = false; // workaround for ItemSelect event being called twice between menu transitions + let lastClothing = null; + + function getClothingName(key, ClotheId, gender) { + var textures = [] + + var hair; + + if (!gender) { + hair = maleHair; + } else { + hair = femaleHair; + } + + switch (key) { + case 2: + for (var i = 0; i < Object.keys(hair[ClotheId]).length; i++) { + if (hair[ClotheId][i].Localized != "NULL") { + const newData = { + id: i, + data: [hair[ClotheId][i]] + } + textures.push(newData); + } + } + break; + + } + return textures; + } + + function addClothingItems(type, bannerSprite, key, value, gender) { + var categoryMenu; + var cloth = []; + var tx = []; + + if (Object.keys(categoryMenus).length > 0) { + for (var i = 0; i < categoryMenus.length; i++) { + if (categoryMenus[i].slotIdx == key) { + return; + } + } + mainMenu.AddItem(new UIMenuItem(categoryTitles[type][key], `${type === "props" ? "Prop category." : "Clothing category."}`)); + // Create category menu + categoryMenu = new UIMenu("", categoryTitles[type][key].toUpperCase(), new Point(0, 0), bannerSprite.library, bannerSprite.texture); + categoryMenu.Visible = false; + } else { + mainMenu.AddItem(new UIMenuItem(categoryTitles[type][key], `${type === "props" ? "Prop category." : "Clothing category."}`)); + // Create category menu + categoryMenu = new UIMenu("", categoryTitles[type][key].toUpperCase(), new Point(0, 0), bannerSprite.library, bannerSprite.texture); + categoryMenu.Visible = false; + } + + + + + mainMenu.Item + + // Fill it + + for (const item of value) { + if (item.ComponentId == key) { + var txData = getClothingName(key, item.ClotheId, gender); + + for (const x of txData) { + //var itemDescription = (key === 11 ? mp.game.ui.getLabelText(x.undershirt[1].GXT) : "Clothing item."); + var itemDescription = (key === 11 ? x.undershirt[1].GXT + " - " + x.id : "Clothing item."); + if (itemDescription == "NULL") { + itemDescription = "Clothing item."; + } + //const tempItem = new UIMenuItem(mp.game.ui.getLabelText(x.data[0].GXT), itemDescription); + const tempItem = new UIMenuItem(x.data[0].GXT + " - " + x.id, itemDescription); + + tempItem.SetRightLabel(`${item.Price > 0 ? `$${item.Price}` : "FREE"}`); + + categoryMenu.AddItem(tempItem); + + cloth.push(item); + tx.push(x); + } + } + } + + categoryMenus.push({ + menu: categoryMenu, + type: type, + slotIdx: Number(key), + item: cloth, + texture: tx + }); + } + + function submenuItemChangeHandler(newIndex) { + const currentMenu = categoryMenus[currentMenuIdx]; + const currentItem = currentMenu.item[newIndex]; + const currentTexture = currentMenu.texture[newIndex].id; + //const currentItem = clothingData[currentMenu.type][currentMenu.slotIdx][newIndex]; + + + mp.players.local.setComponentVariation(currentMenu.slotIdx, currentItem.ClotheId, currentTexture, 2); + + + /* + case "props": + if (currentItem.drawable === -1) { + localPlayer.clearProp(currentMenu.slotIdx); + } else { + localPlayer.setPropIndex(currentMenu.slotIdx, currentItem.drawable, currentItem.texture, true); + } + break; + */ + } + + function resetPreview() { + if (lastClothing) { + switch (lastClothing.type) { + case "clothes": + localPlayer.setComponentVariation(lastClothing.slotIdx, lastClothing.drawable, lastClothing.texture, 2); + + break; + + case "props": + if (lastClothing.drawable === -1) { + localPlayer.clearProp(lastClothing.slotIdx); + } else { + localPlayer.setPropIndex(lastClothing.slotIdx, lastClothing.drawable, lastClothing.texture, true); + } + break; + } + + lastClothing = null; + } + } + + function myTimer() { + let dist = mp.game.gameplay.getDistanceBetweenCoords(localPlayer.position.x, localPlayer.position.y, 0, playerPos.x, playerPos.y, 0, false); + if (dist > 3) { + clearInterval(myVar); + resetPreview(); + if (currentMenuIdx !== -1) categoryMenus[currentMenuIdx].menu.Close(); + if (mainMenu && mainMenu.Visible) mainMenu.Close(); + } + } + + + mp.events.add("FriseurMenu:updateData", (jsonBannerSprite, jsonData, gender) => { + if (!globalData.InMenu) { + globalData.InMenu = true; + playerPos = localPlayer.position; + var bannerSprite = JSON.parse(jsonBannerSprite); + var data = JSON.parse(jsonData); + + // Default menu banner + if (bannerSprite == null) { + bannerSprite = { + library: "commonmenu", + texture: "interaction_bgd" + }; + } else if (bannerSprite == 10) { + bannerSprite = { + library: "shopui_title_barber", + texture: "shopui_title_barber" + }; + } + // Hide the chat + mp.gui.chat.show(false); + + // Reset some variables + categoryMenus = []; + currentMenuIdx = -1; + menuTransition = false; + lastClothing = null; + + // Create a new main menu + mainMenu = new UIMenu("", "Wähle deine Frisur", new Point(0, 0), bannerSprite.library, bannerSprite.texture); + mainMenu.Visible = true; + + // Update clothingData + clothingData = data; + + // Add clothes + + addClothingItems("clothes", bannerSprite, 2, data[0], gender); + myVar = setInterval(myTimer, 100); + // Add props + // for (const [key, value] of Object.entries(clothingData.props)) addClothingItems("props", bannerSprite, key, value); + + let hairColorItem; + let hairHighlightItem; + var creatorHairMenu; + let hairColors = []; + for (let i = 0; i < maxHairColor; i++) hairColors.push(i.toString()); + + + hairColorItem = new UIMenuListItem("Haarfarbe", "Deine Haarfarbe", new ItemsCollection(hairColors)); + mainMenu.AddItem(hairColorItem); + /* hairHighlightItem = new UIMenuListItem("Haarstr\u00e4hnen", "Farbe deiner Haarstr\u00e4hnen", new ItemsCollection(hairColors)); + mainMenu.AddItem(hairHighlightItem); + */ //Wird später hinzugefügt + mainMenu.ListChange.on((item, listIndex) => { + switch (mainMenu.CurrentSelection) { + case 1: // hair color + localPlayer.setHairColor(listIndex, 0); + break; + + /* case 2: // hair highlight color + localPlayer.setHairColor(hairColorItem.Index, listIndex); + break; + */ + } + }); + + + // Submenu events + for (const item of categoryMenus) { + // Preview hovering item + item.menu.IndexChange.on(submenuItemChangeHandler); + + // Buy hovering item + item.menu.ItemSelect.on((item: NativeUI.UIMenuItem, itemIndex) => { + if (menuTransition) { + menuTransition = false; + return; + } + + const currentMenu = categoryMenus[currentMenuIdx]; + const currentItem = currentMenu.item[itemIndex]; + const currentTexture = currentMenu.texture[itemIndex].id; + + var serverData = [currentMenu.slotIdx, currentTexture, currentItem.ClotheId, -1, -1, -1, currentItem.Price]; + if (lastClothing.drawable == currentItem.ClotheId && lastClothing.texture == currentTexture) { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + } else { + mp.events.callRemote("SERVER:BuyCharacterClothes", "clothe", JSON.stringify(serverData), currentItem.CloteID); + mp.events.call("friseurMenu:close"); + } + + + }); + + // Reset preview when player backs out of category menu + item.menu.MenuClose.on(() => { + + + currentMenuIdx = -1; + mainMenu.Visible = true; + if (mainMenu.Visible = true) { + resetPreview(); + } + }); + } + + // Main menu events + mainMenu.ItemSelect.on((selectedItem, itemIndex) => { + if (selectedItem === hairColorItem) { + mp.events.callRemote("SERVER:BuyHairColor", hairColorItem.SelectedValue); + mainMenu.Close(true); + globalData.InMenu = false; + + } + else if (selectedItem === hairHighlightItem) { + mp.events.callRemote("CLIENT:BuyHairlightColor", hairHighlightItem.SelectedValue); + mainMenu.Close(true); + globalData.InMenu = false; + } else { + + const nextMenu = categoryMenus[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); + } + }); + + + mainMenu.MenuClose.on(() => { + globalData.InMenu = false; + mp.gui.chat.show(true); + + currentMenuIdx = -1; + lastClothing = null; + }); + } + }); + mp.events.add("friseurMenu:close", () => { + if (currentMenuIdx !== -1) categoryMenus[currentMenuIdx].menu.Close(); + if (mainMenu && mainMenu.Visible) mainMenu.Close(); + }); + + mp.events.add("frieseurMenu:Error", () => { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/Interaction/clothes/male_hair.json b/ReallifeGamemode.Client/Interaction/friseur/male_hair.json similarity index 100% rename from ReallifeGamemode.Client/Interaction/clothes/male_hair.json rename to ReallifeGamemode.Client/Interaction/friseur/male_hair.json diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index fa460179..183840f0 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -212,6 +212,9 @@ soundUtil(); import clotheShopList from './Interaction/clothes/ClotheShop'; clotheShopList(globalData); +import FriseurShopList from './Interaction/friseur/Friseur'; +FriseurShopList(globalData); + import itemShopList from './Interaction/ItemShop'; itemShopList(globalData); diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index 3aba410d..1b4063f5 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -234,7 +234,6 @@ namespace ReallifeGamemode.Server.Events player.RemoveAllWeapons(); Medic.delReviveTasks(player); NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5), -98.36f); - } } } diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index c3905a01..c600cabc 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -203,6 +203,7 @@ namespace ReallifeGamemode.Server.Events JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData("duty")); ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3)); ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); + FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6); @@ -528,6 +529,10 @@ namespace ReallifeGamemode.Server.Events { nearestItemShopPoint.itemShop.LoadShopNUI(player); } + if (nearestFriseurPoint != null) + { + nearestFriseurPoint.friseurShop.LoadShopNUI(player); + } if (user.FactionLeader) { player.TriggerEvent("CLIENT:StartGangwar"); diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index 727053fa..5b403165 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -285,5 +285,49 @@ namespace ReallifeGamemode.Server.Events client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); } } + + [RemoteEvent("SERVER:BuyHairColor")] + public void BuyHairColor(Player client, byte HairColor) + { + User user = client.GetUser(); + if (user.Handmoney < 100) + { + client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($100)!", true); + return; + } + + using (var dbContext = new DatabaseContext()) + { + User payer = client.GetUser(dbContext); + payer.GetCharacter(dbContext); + payer.Handmoney -= 100; + payer.Character.HairColor = HairColor; + // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); + dbContext.SaveChanges(); + } + } + + [RemoteEvent("SERVER:BuyHairlightColor")] + public void BuyHairlightColor(Player client, byte HairlightColor) + { + User user = client.GetUser(); + if (user.Handmoney < 50) + { + client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($50)!", true); + return; + } + + using (var dbContext = new DatabaseContext()) + { + User payer = client.GetUser(dbContext); + payer.GetCharacter(dbContext); + payer.Handmoney -= 50; + payer.Character.HairHighlightColor = HairlightColor; + // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); + dbContext.SaveChanges(); + } + } + + } } diff --git a/ReallifeGamemode.Server/Events/Vehicle.cs b/ReallifeGamemode.Server/Events/Vehicle.cs index ced5777c..c336fe3f 100644 --- a/ReallifeGamemode.Server/Events/Vehicle.cs +++ b/ReallifeGamemode.Server/Events/Vehicle.cs @@ -65,11 +65,101 @@ namespace ReallifeGamemode.Server.Events } else if (sV is JobVehicle jV) { - if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3)) + if (jV.JobId != player.GetUser().JobId && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && player.IsAdminDuty())) { player.SendNotification("~r~Du hast keinen Schlüssel."); return; } + else + { + if (!jV.GetJob().GetUsersInJob().Contains(player) && !player.IsAdminDuty()) + { + player.SendNotification("~y~[JOB] ~w~Du musst den Job vorher starten!"); + return; + } + else + { + /*if(player.IsAdminDuty()) + { + player.SendChatMessage(""); + }*/ + if (jV.JobId == 3 && player.GetUser().JobId == 3 && jV.GetJob().GetUsersInJob().Contains(player)) + { + Job.PilotJob c = new Job.PilotJob(); + if ((VehicleHash)jV.Model == VehicleHash.Cuban800 && !state) + { + if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) + { + player.SetData("HatRoute", true); + c.StartPilotRoute(player, "RouteStart"); + } + } + if ((VehicleHash)jV.Model == VehicleHash.Velum && !state || (VehicleHash)jV.Model == VehicleHash.Velum2 && !state) + { + if (player.GetUser().PilotSkill >= 300) + { + if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) + { + player.SetData("HatRoute", true); + c.StartPilotRoute(player, "RouteStart"); + } + } + else + { + player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(2) "); + return; + } + } + } + if (jV.JobId == 4 && player.GetUser().JobId == 4 && jV.GetJob().GetUsersInJob().Contains(player)) + { + Job.BusDriverJob c = new Job.BusDriverJob(); + if ((VehicleHash)jV.Model == VehicleHash.Bus && !state) + { + if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) + { + player.SetData("HatRoute", true); + c.StartBusRoute(player, "RouteStart"); + player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); + } + } + if ((VehicleHash)jV.Model == VehicleHash.Coach && !state) + { + if (player.GetUser().BusSkill >= 300) + { + if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) + { + player.SetData("HatRoute", true); + c.StartBusRoute(player, "RouteStart"); + player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); + } + } + else + { + player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(2) "); + return; + } + } + if ((VehicleHash)jV.Model == VehicleHash.Tourbus && !state) + { + if (player.GetUser().BusSkill >= 800) + { + if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) + { + player.SetData("HatRoute", true); + c.StartBusRoute(player, "RouteStart"); + player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); + } + } + else + { + player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(3) "); + return; + } + } + } + } + } } else if (sV is UserVehicle uV) { diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 7ed261ec..3d28e22f 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -136,6 +136,6 @@ namespace ReallifeGamemode.Server.Factions.Medic MedicTask task = ReviveTasks.FirstOrDefault(t => t.Victim == player.Name); RemoveTaskFromList(task); } - } + } diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index 7d9f1a24..e012348c 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -111,6 +111,7 @@ namespace ReallifeGamemode.Server InventoryManager.LoadItems(); ShopManager.LoadClotheShops(); ShopManager.LoadItemShops(); + ShopManager.LoadFriseur(); TuningManager.LoadTuningGarages(); TimeManager.StartTimeManager(); diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index 8f7dfe07..03f7bd22 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -3,6 +3,7 @@ using System.Linq; using GTANetworkAPI; using ReallifeGamemode.Server.Shop.Clothing; using ReallifeGamemode.Server.Shop.SevenEleven; +using ReallifeGamemode.Server.Shop.Friseur; namespace ReallifeGamemode.Server.Managers { @@ -17,6 +18,8 @@ namespace ReallifeGamemode.Server.Managers public static List ElevatorPoints = new List(); public static List clotheshopPoints = new List(); + + public static List friseurPoints = new List(); public static List itemshopPoints = new List(); @@ -233,6 +236,24 @@ namespace ReallifeGamemode.Server.Managers NAPI.TextLabel.CreateTextLabel("Kleiderladen - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); } + foreach (var shop in ShopManager.FriseurStores) + { + shop.LoadClothes(); + FriseurPoint shopPoint = new FriseurPoint() + { + Position = shop.vector, + friseurShop = shop + }; + friseurPoints.Add(shopPoint); + } + + foreach (FriseurPoint s in friseurPoints) + { + NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1), + new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0); + NAPI.TextLabel.CreateTextLabel("Friseur - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); + } + foreach (var shop in ShopManager.itemShops) { shop.LoadItems(); @@ -358,6 +379,12 @@ public class ItemshopPoint public ItemShop itemShop { get; set; } } +public class FriseurPoint +{ + public Vector3 Position { get; set; } + public Friseur friseurShop { get; set; } +} + public class JobPoint { public Vector3 Position { get; set; } diff --git a/ReallifeGamemode.Server/Managers/ShopManager.cs b/ReallifeGamemode.Server/Managers/ShopManager.cs index 2ff820c6..6a94a4af 100644 --- a/ReallifeGamemode.Server/Managers/ShopManager.cs +++ b/ReallifeGamemode.Server/Managers/ShopManager.cs @@ -5,6 +5,7 @@ using ReallifeGamemode.Database.Entities.Saves; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Shop.Clothing; using ReallifeGamemode.Server.Shop.SevenEleven; +using ReallifeGamemode.Server.Shop.Friseur; namespace ReallifeGamemode.Server.Managers { @@ -12,6 +13,7 @@ namespace ReallifeGamemode.Server.Managers { public static List clotheStores = new List(); public static List itemShops = new List(); + public static List FriseurStores = new List(); public static void LoadClotheShops() { @@ -61,5 +63,23 @@ namespace ReallifeGamemode.Server.Managers NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7"); } } + + public static void LoadFriseur() + { + using (var dbContext = new DatabaseContext()) + { + List friseur = dbContext.Blips.ToList().FindAll(s => s.Name == "Friseur"); + + + foreach (var store in friseur) + { + Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); + Friseur newShop = new Friseur(10, pos); + FriseurStores.Add(newShop); + NAPI.Util.ConsoleOutput($"Loading Friseur {store.Name}"); + } + } + } + } } diff --git a/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs b/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs index 6eead2d1..6255c6a2 100644 --- a/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs +++ b/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs @@ -44,13 +44,15 @@ namespace ReallifeGamemode.Server.Shop.Clothing List legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4); List shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6); List accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7); + List frisur = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 2); List clothes = new List { tops.ToArray(), legs.ToArray(), shoes.ToArray(), - accessoires.ToArray() + accessoires.ToArray(), + frisur.ToArray() }; client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender); diff --git a/ReallifeGamemode.Server/Shop/Friseur/Friseur.cs b/ReallifeGamemode.Server/Shop/Friseur/Friseur.cs new file mode 100644 index 00000000..1bf472d7 --- /dev/null +++ b/ReallifeGamemode.Server/Shop/Friseur/Friseur.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using GTANetworkAPI; +using Newtonsoft.Json; +using ReallifeGamemode.Database.Entities; +using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Extensions; + +namespace ReallifeGamemode.Server.Shop.Friseur +{ + public class Friseur + { + public int category { get; set; } + public Vector3 vector { get; set; } + public List frisurList = new List(); + + public Friseur(int category, Vector3 vector) + { + this.category = category; + this.vector = vector; + LoadClothes(); + } + + public void LoadClothes() + { + using (var dbContext = new DatabaseContext()) + { + frisurList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category); + } + } + + public void LoadShopNUI(Player client) + { + User u = client.GetUser(); + + if (u == null) + { + return; + } + + bool gender = u.GetCharacter().Gender; + + List frisur = frisurList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 2); + + List frisuren = new List + { + frisur.ToArray() + }; + + client.TriggerEvent("FriseurMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(frisuren.ToArray()), gender); + } + + + + + } +}