evtl fix payday
This commit is contained in:
@@ -2719,9 +2719,12 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var target in NAPI.Pools.GetAllPlayers().Select(c => c.GetUser()))
|
foreach (var target in NAPI.Pools.GetAllPlayers())
|
||||||
{
|
{
|
||||||
Economy.SetPaycheck(target.Player, target.Wage);
|
if (target.IsLoggedIn())
|
||||||
|
{
|
||||||
|
Economy.SetPaycheck(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ein Payday gedroppt.");
|
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ein Payday gedroppt.");
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void SetPaycheck(Player client, int wage)
|
public static void SetPaycheck(Player client)
|
||||||
{
|
{
|
||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
|
int wage = user.Wage;
|
||||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||||
float propertyTax = GetPropertyTaxation(client);
|
float propertyTax = GetPropertyTaxation(client);
|
||||||
int vehicleTaxation = GetVehicleTaxation(client);
|
int vehicleTaxation = GetVehicleTaxation(client);
|
||||||
@@ -97,12 +98,20 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
|
|
||||||
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (client == null || paycheck == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
User u = client.GetUser(dbContext);
|
User u = client.GetUser(dbContext);
|
||||||
u.BankAccount.Balance += paycheck.Amount;
|
u.BankAccount.Balance += paycheck.Amount;
|
||||||
u.Wage = 0;
|
u.Wage = 0;
|
||||||
|
|
||||||
|
u.PaydayTimer = 60;
|
||||||
|
|
||||||
var rentals = dbContext.HouseRentals
|
var rentals = dbContext.HouseRentals
|
||||||
.Include(hR => hR.House)
|
.Include(hR => hR.House)
|
||||||
.ThenInclude(h => h.BankAccount)
|
.ThenInclude(h => h.BankAccount)
|
||||||
@@ -110,10 +119,13 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
|
|
||||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
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)
|
foreach (var rental in rentals)
|
||||||
{
|
{
|
||||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -123,41 +135,27 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public static void PaydayTimer()
|
|
||||||
{
|
|
||||||
System.Timers.Timer timer = new System.Timers.Timer(60000);
|
|
||||||
timer.Start();
|
|
||||||
timer.Elapsed += Timer_Elapsed;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public static void Timer_Elapsed()
|
public static void Timer_Elapsed()
|
||||||
{
|
{
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
{
|
{
|
||||||
User user = player.GetUser();
|
User user = player.GetUser(dbContext);
|
||||||
if (player.IsLoggedIn())
|
if (player.IsLoggedIn())
|
||||||
{
|
{
|
||||||
if (user.PaydayTimer <= 0)
|
if (user.PaydayTimer <= 0)
|
||||||
{
|
{
|
||||||
Economy.SetPaycheck(player, user.Wage);
|
Economy.SetPaycheck(player);
|
||||||
using (var dbContext = new DatabaseContext())
|
user.PaydayTimer = 60;
|
||||||
{
|
}
|
||||||
player.GetUser(dbContext).PaydayTimer = 60;
|
else if (user.PaydayTimer > 0)
|
||||||
dbContext.SaveChanges();
|
{
|
||||||
|
user.PaydayTimer -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (user.PaydayTimer > 0)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
player.GetUser(dbContext).PaydayTimer -= 1;
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user