From b608ead71de562d0fa9c6479d2bd6076399d63d2 Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 22 Apr 2021 01:39:20 +0200 Subject: [PATCH] FIB/LSPD: Fix Ticketpreis Verteilung --- .../Managers/InteractionManager.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 75ac2599..6bff91b8 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -475,7 +475,7 @@ namespace ReallifeGamemode.Server.Managers var backPrice = (int)(vehPrice * 0.4); player.SetData("SellVehicleDecision", true); player.SetData("VehicleToSell", id); - ChatService.SendMessage(player,"~s~Möchtes du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~$" + backPrice + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen"); + ChatService.SendMessage(player, "~s~Möchtes du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~$" + backPrice + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen"); } } @@ -632,7 +632,7 @@ namespace ReallifeGamemode.Server.Managers using var dbContext = new DatabaseContext(); User targetUser = target.GetUser(dbContext); - if(targetUser == null) + if (targetUser == null) { ChatService.PlayerNotFound(player); return; @@ -703,16 +703,22 @@ namespace ReallifeGamemode.Server.Managers player.SendNotification($"~y~{targetname} ~g~hat das Ticket über ~b~{ticket_amount}$ ~g~angenommen und bezahlt.", true); using (var dbContext = new DatabaseContext()) { - target.GetUser(dbContext).BankAccount.Balance -= ticket_amount; - if (player.GetUser().FactionId == 1) + User user = player.GetUser(dbContext); + User targetUser = target.GetUser(dbContext); + targetUser.BankAccount.Balance -= ticket_amount; + + FactionBankAccount lspdBankAccount = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1).First().BankAccount; + FactionBankAccount fibBankAccount = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 3).First().BankAccount; + + if (user.FactionId == 1) { - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1).First().BankAccount.Balance += (int)(ticket_amount / 100 * 70); - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 3).First().BankAccount.Balance += (int)(ticket_amount / 100 * 30); + lspdBankAccount.Balance += (int)(ticket_amount / 100 * 60); + fibBankAccount.Balance += (int)(ticket_amount / 100 * 40); } - if (player.GetUser().FactionId == 1) + else if (user.FactionId == 3) { - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 3).First().BankAccount.Balance += (int)(ticket_amount / 100 * 70); - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1).First().BankAccount.Balance += (int)(ticket_amount / 100 * 30); + fibBankAccount.Balance += (int)(ticket_amount / 100 * 60); + lspdBankAccount.Balance += (int)(ticket_amount / 100 * 40); } dbContext.SaveChanges(); }