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,49 +114,66 @@ 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);
|
||||||
|
|
||||||
|
UserBankAccount bankAccount = u.BankAccount;
|
||||||
|
|
||||||
|
if (bankAccount.Balance < 0)
|
||||||
{
|
{
|
||||||
User u = client.GetUser(dbContext);
|
if (bankAccount.Balance >= -2500)
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput("hat rentals");
|
putInJail = 5;
|
||||||
foreach (var rental in rentals)
|
}
|
||||||
|
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)
|
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,16 +51,16 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
}
|
}
|
||||||
if (user.Wanteds <= 0)
|
if (user.Wanteds <= 0)
|
||||||
return;
|
return;
|
||||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
if (!copPlayer.IsLoggedIn()) continue;
|
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||||
User cop = copPlayer.GetUser();
|
|
||||||
if (cop?.FactionId == 1 || cop?.FactionId == 3)
|
|
||||||
{
|
{
|
||||||
int jailTime = user.Wanteds * 54;
|
if (!copPlayer.IsLoggedIn()) continue;
|
||||||
if (cop.GetData<bool>("duty") && copPlayer.Position.DistanceTo2D(client.Position) <= 200 && (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true))
|
User cop = copPlayer.GetUser();
|
||||||
|
if (cop?.FactionId == 1 || cop?.FactionId == 3)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
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 (!client.HasData("isDead") || client.GetData<bool>("isDead") == false)
|
if (!client.HasData("isDead") || client.GetData<bool>("isDead") == false)
|
||||||
{
|
{
|
||||||
@@ -71,61 +71,67 @@ 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.RemoveAllWeapons();
|
||||||
client.SetData("isDead", false);
|
client.SetSharedData("blipColor", 0);
|
||||||
client.RemoveAllWeapons();
|
Random rnd = new Random();
|
||||||
client.SetSharedData("blipColor", 0);
|
int rndInt = rnd.Next(1, 3);
|
||||||
Random rnd = new Random();
|
if (rndInt == 1)
|
||||||
int rndInt = rnd.Next(1, 3);
|
NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
|
||||||
if (rndInt == 1)
|
if (rndInt == 2)
|
||||||
NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
|
NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail
|
||||||
if (rndInt == 2)
|
if (rndInt == 3)
|
||||||
NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail
|
NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail
|
||||||
if (rndInt == 3)
|
|
||||||
NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail
|
|
||||||
|
|
||||||
client.TriggerEvent("onPlayerRevived");
|
client.TriggerEvent("onPlayerRevived");
|
||||||
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name);
|
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name);
|
||||||
Medic.RemoveTaskFromList(task);
|
Medic.RemoveTaskFromList(task);
|
||||||
client.Health = 100;
|
client.Health = 100;
|
||||||
|
|
||||||
int timeMinutes = 0;
|
int timeMinutes = 0;
|
||||||
|
|
||||||
if (((int)(client.GetUser().JailTime / 60)) <= 1 && client.GetUser().JailTime != 0)
|
if (((int)(client.GetUser().JailTime / 60)) <= 1 && client.GetUser().JailTime != 0)
|
||||||
{
|
{
|
||||||
timeMinutes = 1;
|
timeMinutes = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeMinutes = (int)(client.GetUser().JailTime / 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.TriggerEvent("jailTime", JsonConvert.SerializeObject(timeMinutes));
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (user.FactionId)
|
||||||
|
{
|
||||||
|
case null:
|
||||||
|
client.SetSharedData("blipColor", 0);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
client.SetSharedData("blipColor", 83);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
client.SetSharedData("blipColor", 52);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
client.SetSharedData("blipColor", 5);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeMinutes = (int)(client.GetUser().JailTime / 60);
|
ChatService.BroadcastFaction("!{#8181E9}HQ: Der Verdächtigte " + user.Name + " wurde soeben ins Krankenhaus eingeliefert.", new System.Collections.Generic.List<int>() { 1, 3 });
|
||||||
}
|
}
|
||||||
|
|
||||||
client.TriggerEvent("jailTime", JsonConvert.SerializeObject(timeMinutes));
|
|
||||||
ChatService.SendMessage(client, "!{#FF614A}* Du bist nun im Gefängnis für " + timeMinutes + " Minute/n.");
|
|
||||||
ChatService.BroadcastFaction("!{#8181E9}HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List<int>() { 1, 3 });
|
|
||||||
switch (user.FactionId)
|
|
||||||
{
|
|
||||||
case null:
|
|
||||||
client.SetSharedData("blipColor", 0);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
client.SetSharedData("blipColor", 83);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
client.SetSharedData("blipColor", 52);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
client.SetSharedData("blipColor", 5);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChatService.BroadcastFaction("!{#8181E9}HQ: Der Verdächtigte " + user.Name + " wurde soeben ins Krankenhaus eingeliefert.", new System.Collections.Generic.List<int>() { 1, 3 });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user