wenn minus = knast
This commit is contained in:
@@ -3002,7 +3002,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
{
|
{
|
||||||
if (target.IsLoggedIn())
|
if (target.IsLoggedIn())
|
||||||
{
|
{
|
||||||
Economy.SetPaycheck(target);
|
Economy.SetPaycheck(target, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using ReallifeGamemode.Server.Wanted;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Finance
|
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();
|
User user = client.GetUser();
|
||||||
int wage = user.Wage;
|
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);
|
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount, rentalFees, healthInsurance, factionMoney);
|
||||||
Paychecks[user.Id] = paycheck;
|
Paychecks[user.Id] = paycheck;
|
||||||
ReleasePayDay(client, paycheck);
|
ReleasePayDay(client, paycheck, minusJail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetRentalFees(Player client)
|
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");
|
NAPI.Util.ConsoleOutput("in release payday");
|
||||||
if (client == null || paycheck == null)
|
if (client == null || paycheck == null)
|
||||||
@@ -113,33 +114,40 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
return;
|
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);
|
User u = client.GetUser(dbContext);
|
||||||
NAPI.Util.ConsoleOutput("get user");
|
|
||||||
|
UserBankAccount bankAccount = u.BankAccount;
|
||||||
|
|
||||||
|
if (bankAccount.Balance < 0)
|
||||||
|
{
|
||||||
|
if (bankAccount.Balance >= -2500)
|
||||||
|
{
|
||||||
|
putInJail = 5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
putInJail = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u.BankAccount.Balance += paycheck.Amount;
|
u.BankAccount.Balance += paycheck.Amount;
|
||||||
u.Wage = 0;
|
u.Wage = 0;
|
||||||
|
|
||||||
u.PaydayTimer = 60;
|
u.PaydayTimer = 60;
|
||||||
|
|
||||||
|
|
||||||
NAPI.Util.ConsoleOutput("set sachen");
|
|
||||||
|
|
||||||
var rentals = dbContext.HouseRentals
|
var rentals = dbContext.HouseRentals
|
||||||
.Include(hR => hR.House)
|
.Include(hR => hR.House)
|
||||||
.ThenInclude(h => h.BankAccount)
|
.ThenInclude(h => h.BankAccount)
|
||||||
.Where(hR => hR.UserId == u.Id);
|
.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);
|
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||||
|
|
||||||
if (rentals.Any())
|
if (rentals.Any())
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput("hat rentals");
|
|
||||||
foreach (var rental in rentals)
|
foreach (var rental in rentals)
|
||||||
{
|
{
|
||||||
if (rental?.House?.BankAccount != null)
|
if (rental?.House?.BankAccount != null)
|
||||||
@@ -148,14 +156,24 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
if (paycheck.Amount > 0)
|
if (paycheck.Amount > 0)
|
||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||||
else
|
else
|
||||||
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~.");
|
||||||
|
|
||||||
|
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()
|
public static void Timer_Elapsed()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
private static Dictionary<int, int> Jailtime { get; set; } = new Dictionary<int, int>(); //time in seconds
|
private static Dictionary<int, int> Jailtime { get; set; } = new Dictionary<int, int>(); //time in seconds
|
||||||
|
|
||||||
|
|
||||||
public static void Check_PutBehindBars(Player client)
|
public static void Check_PutBehindBars(Player client, bool announceHq = true)
|
||||||
{
|
{
|
||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
if (user.JailTime > 0)
|
if (user.JailTime > 0)
|
||||||
@@ -51,6 +51,8 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
}
|
}
|
||||||
if (user.Wanteds <= 0)
|
if (user.Wanteds <= 0)
|
||||||
return;
|
return;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||||
{
|
{
|
||||||
if (!copPlayer.IsLoggedIn()) continue;
|
if (!copPlayer.IsLoggedIn()) continue;
|
||||||
@@ -59,8 +61,6 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
{
|
{
|
||||||
int jailTime = user.Wanteds * 54;
|
int jailTime = user.Wanteds * 54;
|
||||||
if (cop.GetData<bool>("duty") && copPlayer.Position.DistanceTo2D(client.Position) <= 200 && (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true))
|
if (cop.GetData<bool>("duty") && copPlayer.Position.DistanceTo2D(client.Position) <= 200 && (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true))
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
{
|
||||||
if (!client.HasData("isDead") || client.GetData<bool>("isDead") == false)
|
if (!client.HasData("isDead") || client.GetData<bool>("isDead") == false)
|
||||||
{
|
{
|
||||||
@@ -71,8 +71,6 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
Jailtime[user.Id] = jailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
Jailtime[user.Id] = jailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||||
|
|
||||||
client.GetUser(dbContext).Wanteds = 0;
|
client.GetUser(dbContext).Wanteds = 0;
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
client.SetData("isDead", false);
|
client.SetData("isDead", false);
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.SetSharedData("blipColor", 0);
|
client.SetSharedData("blipColor", 0);
|
||||||
@@ -103,7 +101,12 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
|
|
||||||
client.TriggerEvent("jailTime", JsonConvert.SerializeObject(timeMinutes));
|
client.TriggerEvent("jailTime", JsonConvert.SerializeObject(timeMinutes));
|
||||||
ChatService.SendMessage(client, "!{#FF614A}* Du bist nun im Gefängnis für " + timeMinutes + " Minute/n.");
|
ChatService.SendMessage(client, "!{#FF614A}* Du bist nun im Gefängnis für " + timeMinutes + " Minute/n.");
|
||||||
|
|
||||||
|
if (announceHq)
|
||||||
|
{
|
||||||
ChatService.BroadcastFaction("!{#8181E9}HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List<int>() { 1, 3 });
|
ChatService.BroadcastFaction("!{#8181E9}HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List<int>() { 1, 3 });
|
||||||
|
}
|
||||||
|
|
||||||
switch (user.FactionId)
|
switch (user.FactionId)
|
||||||
{
|
{
|
||||||
case null:
|
case null:
|
||||||
@@ -127,6 +130,9 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user