wenn minus = knast
This commit is contained in:
@@ -16,6 +16,7 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
@@ -70,7 +71,7 @@ namespace ReallifeGamemode.Server.Finance
|
||||
}
|
||||
|
||||
|
||||
public static void SetPaycheck(Player client)
|
||||
public static void SetPaycheck(Player client, bool minusJail = true)
|
||||
{
|
||||
User user = client.GetUser();
|
||||
int wage = user.Wage;
|
||||
@@ -93,7 +94,7 @@ namespace ReallifeGamemode.Server.Finance
|
||||
|
||||
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount, rentalFees, healthInsurance, factionMoney);
|
||||
Paychecks[user.Id] = paycheck;
|
||||
ReleasePayDay(client, paycheck);
|
||||
ReleasePayDay(client, paycheck, minusJail);
|
||||
}
|
||||
|
||||
private static int GetRentalFees(Player client)
|
||||
@@ -105,7 +106,7 @@ namespace ReallifeGamemode.Server.Finance
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
||||
public static void ReleasePayDay(Player client, Paycheck paycheck, bool minusJail)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("in release payday");
|
||||
if (client == null || paycheck == null)
|
||||
@@ -113,49 +114,66 @@ namespace ReallifeGamemode.Server.Finance
|
||||
return;
|
||||
}
|
||||
|
||||
NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}");
|
||||
int putInJail = 0;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User u = client.GetUser(dbContext);
|
||||
|
||||
UserBankAccount bankAccount = u.BankAccount;
|
||||
|
||||
if (bankAccount.Balance < 0)
|
||||
{
|
||||
User u = client.GetUser(dbContext);
|
||||
NAPI.Util.ConsoleOutput("get user");
|
||||
u.BankAccount.Balance += paycheck.Amount;
|
||||
u.Wage = 0;
|
||||
|
||||
u.PaydayTimer = 60;
|
||||
|
||||
|
||||
NAPI.Util.ConsoleOutput("set sachen");
|
||||
|
||||
var rentals = dbContext.HouseRentals
|
||||
.Include(hR => hR.House)
|
||||
.ThenInclude(h => h.BankAccount)
|
||||
.Where(hR => hR.UserId == u.Id);
|
||||
|
||||
|
||||
NAPI.Util.ConsoleOutput("get rentals");
|
||||
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||
|
||||
if (rentals.Any())
|
||||
if (bankAccount.Balance >= -2500)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("hat rentals");
|
||||
foreach (var rental in rentals)
|
||||
putInJail = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
putInJail = 10;
|
||||
}
|
||||
}
|
||||
|
||||
u.BankAccount.Balance += paycheck.Amount;
|
||||
u.Wage = 0;
|
||||
|
||||
u.PaydayTimer = 60;
|
||||
|
||||
var rentals = dbContext.HouseRentals
|
||||
.Include(hR => hR.House)
|
||||
.ThenInclude(h => h.BankAccount)
|
||||
.Where(hR => hR.UserId == u.Id);
|
||||
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||
|
||||
if (rentals.Any())
|
||||
{
|
||||
foreach (var rental in rentals)
|
||||
{
|
||||
if (rental?.House?.BankAccount != null)
|
||||
{
|
||||
if (rental?.House?.BankAccount != null)
|
||||
{
|
||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||
}
|
||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||
}
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||
else
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||
|
||||
if (putInJail != 0 && minusJail)
|
||||
{
|
||||
u.JailTime = putInJail * 60;
|
||||
ChatService.SendMessage(client, "Du hattest beim PayDay einen negativen Betrag auf deinem Bank-Konto, dafür wirst du eingesperrt.");
|
||||
ChatService.SendMessage(client, "Achte darauf, nicht in einen negativen Geldbetrag zu besitzen.");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
if(putInJail != 0 && minusJail)
|
||||
{
|
||||
Jail.Check_PutBehindBars(client, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Timer_Elapsed()
|
||||
|
||||
Reference in New Issue
Block a user