From 9f827b476d62a5fca9e36b4d8d69f1431b4ba9b1 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 18 Apr 2020 21:41:14 +0200 Subject: [PATCH] fix scheine zeigen --- .../Interaction/interactionmenu.ts | 5 +++-- .../Commands/AdminCommands.cs | 4 ++++ .../Managers/InteractionManager.cs | 2 ++ ReallifeGamemode.Server/Util/FactionHelper.cs | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/Interaction/interactionmenu.ts b/ReallifeGamemode.Client/Interaction/interactionmenu.ts index 9f5c7579..fbb28f5e 100644 --- a/ReallifeGamemode.Client/Interaction/interactionmenu.ts +++ b/ReallifeGamemode.Client/Interaction/interactionmenu.ts @@ -232,12 +232,13 @@ export default function (globalData: IGlobalData) { } licenseMenu.AddItem(menuItem); - licenseMenu.AddItem(new UIMenuItem("Lizenzen an Spieler zeigen")); + var showItem = new UIMenuItem("Lizenzen an Spieler zeigen"); + licenseMenu.AddItem(showItem); licenseMenu.Visible = false; licenseMenu.ItemSelect.on((item, index) => { - if (index === 4) { + if (item === showItem) { var input = new InputHelper("Welchen Spieler möchtest du deine Lizenzen zeigen (Name / ID)?", globalData); input.show(); input.getValue(name => { diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 6cb74c27..5b2a975d 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1873,6 +1873,8 @@ namespace ReallifeGamemode.Server.Commands User u = target.GetUser(dbContext); + FactionHelper.ResetPlayer(target, u, dbContext); + if (faction != 0) { u.FactionId = f.Id; @@ -1939,6 +1941,8 @@ namespace ReallifeGamemode.Server.Commands User u = target.GetUser(dbContext); + FactionHelper.ResetPlayer(target, u, dbContext); + u.FactionId = f.Id; u.FactionRankId = dbContext.FactionRanks. OrderByDescending(x => x.Order) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index a7710abb..8d9912e5 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -57,6 +57,8 @@ namespace ReallifeGamemode.Server.Managers User u = leader.GetUser(dbContext); User own = player.GetUser(dbContext); + FactionHelper.ResetPlayer(player, own, dbContext); + own.Faction = u.Faction; own.FactionLeader = false; own.FactionRank = dbContext diff --git a/ReallifeGamemode.Server/Util/FactionHelper.cs b/ReallifeGamemode.Server/Util/FactionHelper.cs index 1ab0365c..52d99380 100644 --- a/ReallifeGamemode.Server/Util/FactionHelper.cs +++ b/ReallifeGamemode.Server/Util/FactionHelper.cs @@ -1,7 +1,10 @@ -using GTANetworkAPI; +using System.Linq; +using GTANetworkAPI; using Microsoft.EntityFrameworkCore; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Util { @@ -29,5 +32,16 @@ namespace ReallifeGamemode.Server.Util dbContext.SaveChanges(); } } + + public static void ResetPlayer(Player player, User user, DatabaseContext dbContext) + { + user.SetData("duty", false); + + var userClothes = dbContext.CharacterClothes.Where(c => c.UserId == user.Id && c.Duty == true); + dbContext.CharacterClothes.RemoveRange(userClothes); + + CharacterCreator.ApplyCharacter(player); + Events.UpdateCharacterCloth.LoadCharacterDefaults(player); + } } }