diff --git a/Client/Player/dutycloth.js b/Client/Player/dutycloth.js index ca12eae2..53548ee2 100644 --- a/Client/Player/dutycloth.js +++ b/Client/Player/dutycloth.js @@ -19,6 +19,8 @@ var tops; var legs; var shoes; +let screenRes = mp.game.graphics.getScreenResolution(0, 0); + var dutyMenu; let saveItem = new UIMenuItem("Speichern", "Speichert deine Dienstkleidung"); saveItem.BackColor = new Color(13, 71, 161); @@ -33,7 +35,7 @@ mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => { legs = legsArr; shoes = shoesArr; - dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(50, 50)); + dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(0, screenRes.y/2)); dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats))); dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops))); @@ -41,4 +43,48 @@ mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => { dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes))); dutyMenu.AddItem(saveItem); dutyMenu.Visible = true; -}); \ No newline at end of file + + dutyMenu.ListChange.on((item, index) => { + switch (item.Text) { + case "Hut": + if (item.SelectedItem.DisplayText === "Keinen") { + mp.events.callRemote("updateDutyProp", 0, -1); + } else { + mp.events.callRemote("updateDutyProp", 0, parseInt(item.SelectedItem.DisplayText)); + } + break; + case "Top": + mp.events.callRemote("updateDutyCloth", 11, parseInt(item.SelectedItem.DisplayText)); + break; + case "Hose": + mp.events.callRemote("updateDutyCloth", 4, parseInt(item.SelectedItem.DisplayText)); + break; + case "Schuhe": + mp.events.callRemote("updateDutyCloth", 6, parseInt(item.SelectedItem.DisplayText)); + break; + } + }); + + //dutyMenu.ListChange.on((item, index) => { + // switch (item) { + // case "Hut": + // mp.events.callRemote("updateDutyProp", 0, parseInt(index)); + // break; + // case "Top": + // mp.events.callRemote("updateDutyCloth", 11, parseInt(index)); + // break; + // case "Hose": + // mp.events.callRemote("updateDutyCloth", 4, parseInt(index)); + // break; + // case "Schuhe": + // mp.events.callRemote("updateDutyCloth", 6, parseInt(index)); + // break; + // } + //}); + +}); + + +//dutyMenu.ItemSelect.on((item) => { +// switch +//}); \ No newline at end of file diff --git a/Client/index.js b/Client/index.js index a96d3b88..0beb4a31 100644 --- a/Client/index.js +++ b/Client/index.js @@ -12,7 +12,6 @@ let globalData = { require('./CharCreator/index.js'); require('./FactionManagement/main.js'); -require('./FactionManagement/duty.js'); require('./DoorManager/doormanager.js'); diff --git a/Model/DatabaseContext.cs b/Model/DatabaseContext.cs index 5ca62f0a..a360c290 100644 --- a/Model/DatabaseContext.cs +++ b/Model/DatabaseContext.cs @@ -37,6 +37,8 @@ namespace reallife_gamemode.Model public DbSet CharacterProps { get; set; } public DbSet DutyClothes { get; set; } public DbSet DutyProps { get; set; } + public DbSet MaleCombinations { get; set; } + public DbSet FemaleCombinations { get; set; } public DbSet Users { get; set; } public DbSet UserVehicles { get; set; } public DbSet UserBankAccounts { get; set; } diff --git a/Server/Entities/FemaleCombination.cs b/Server/Entities/FemaleCombination.cs new file mode 100644 index 00000000..e5e7fd50 --- /dev/null +++ b/Server/Entities/FemaleCombination.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; +using System.Text; + +/** +* @overview Life of German Reallife - Entities FemaleCombination (FemaleCombination.cs) +* @author VegaZ +* @copyright (c) 2008 - 2018 Life of German +*/ + +namespace reallife_gamemode.Server.Entities +{ + public class FemaleCombination + { + [Key] + public int Id { get; set; } + public int Top { get; set; } + public int Torso { get; set; } + public int Undershirt { get; set; } + } +} diff --git a/Server/Entities/MaleCombination.cs b/Server/Entities/MaleCombination.cs new file mode 100644 index 00000000..30361ee2 --- /dev/null +++ b/Server/Entities/MaleCombination.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; +using System.Text; + +/** +* @overview Life of German Reallife - Entities MaleCombination (MaleCombination.cs) +* @author VegaZ +* @copyright (c) 2008 - 2018 Life of German +*/ + +namespace reallife_gamemode.Server.Entities +{ + public class MaleCombination + { + [Key] + public int Id { get; set; } + public int Top { get; set; } + public int Torso { get; set; } + public int Undershirt { get; set; } + } +} diff --git a/Server/Events/Key.cs b/Server/Events/Key.cs index 66eeb3fa..c9cdc9c9 100644 --- a/Server/Events/Key.cs +++ b/Server/Events/Key.cs @@ -96,24 +96,24 @@ namespace reallife_gamemode.Server.Events if (nearest == null) return; if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId) { - int[] hats; - int[] tops; - int[] legs; - int[] shoes; + string[] hats; + string[] tops; + string[] legs; + string[] shoes; if(user.GetCharacter().Gender == false) //Wenn männlich { - hats = new int[] { -1, 5, 12, 39, 46, 123, 124, 125}; - tops = new int[] { -1, 55, 26}; - legs = new int[] { -1, 24, 28 }; - shoes = new int[] { -1, 24, 25}; + hats = new string[] { "Keinen", "5", "12", "39", "46", "123", "124", "125"}; + tops = new string[] { "55", "26"}; + legs = new string[] { "24", "28" }; + shoes = new string[] { "24", "25"}; } else { - hats = new int[] { -1, 12, 38, 45, 122, 123, 124 }; - tops = new int[] { -1, 48, 43 }; - legs = new int[] { -1, 34, 37, 102 }; - shoes = new int[] { -1, 24, 25 }; + hats = new string[] { "Keinen", "12", "38", "45", "122", "123", "124" }; + tops = new string[] { "48", "43" }; + legs = new string[] { "34", "37", "102" }; + shoes = new string[] { "24", "25" }; } player.TriggerEvent("showDutyClothMenu", hats, tops, legs, shoes); diff --git a/Server/Events/UpdateCharacterComponent.cs b/Server/Events/UpdateCharacterComponent.cs new file mode 100644 index 00000000..93d20b54 --- /dev/null +++ b/Server/Events/UpdateCharacterComponent.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GTANetworkAPI; +using reallife_gamemode.Model; +using reallife_gamemode.Server.Extensions; + +namespace reallife_gamemode.Server.Events +{ + public class UpdateCharacterComponent : Script + { + [RemoteEvent("updateDutyProp")] + public void UpdateDutyProp(Client player, int componentId, int componentVariation) + { + if(componentId != -1) + { + player.SetAccessories(componentId, componentVariation, 0); + } + else + { + player.ClearAccessory(0); + } + + } + + [RemoteEvent("updateDutyCloth")] + public void UpdateDutyCloth(Client player, int componentId, int componentVariation) + { + if(componentId == 11) + { + //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) + using (var context = new DatabaseContext()) + { + if(player.GetUser().GetCharacter().Gender == false) + { + var combination = context.MaleCombinations.FirstOrDefault(c => c.Top == componentVariation); + player.SetClothes(11, componentVariation, 0); + if (combination != null) + { + player.SetClothes(3, combination.Torso, 0); + player.SetClothes(8, combination.Undershirt, 0); + } + } + else + { + var combination = context.FemaleCombinations.FirstOrDefault(c => c.Top == componentVariation); + player.SetClothes(11, componentVariation, 0); + if (combination != null) + { + player.SetClothes(3, combination.Torso, 0); + player.SetClothes(8, combination.Undershirt, 0); + } + } + } + } + else + { + player.SetClothes(componentId, componentVariation, 0); + } + } + } +}