FIB/LSPD: Fix Ticketpreis Verteilung

This commit is contained in:
hydrant
2021-04-22 01:39:20 +02:00
parent 3546ba7f99
commit b608ead71d

View File

@@ -475,7 +475,7 @@ namespace ReallifeGamemode.Server.Managers
var backPrice = (int)(vehPrice * 0.4);
player.SetData<bool>("SellVehicleDecision", true);
player.SetData<int>("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();
}