maybe fix knast
This commit is contained in:
@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Services;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
namespace ReallifeGamemode.Server.Wanted
|
||||
{
|
||||
@@ -18,105 +19,37 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
private static Dictionary<int, int> Jailtime { get; set; } = new Dictionary<int, int>(); //time in seconds
|
||||
|
||||
|
||||
public static void Check_PutBehindBars(Player client, bool announceHq = true)
|
||||
public static void Check_PutBehindBars(User user)
|
||||
{
|
||||
User user = client.GetUser();
|
||||
Player player = user.Player;
|
||||
PositionManager.cuffPoints.Remove(player);
|
||||
if (user.JailTime > 0)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.Health = 100;
|
||||
client.Armor = 0;
|
||||
player.RemoveAllWeapons();
|
||||
player.Health = 100;
|
||||
player.Armor = 0;
|
||||
Random rnd = new Random();
|
||||
int rndInt = rnd.Next(1, 3);
|
||||
if (rndInt == 1)
|
||||
NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
|
||||
if (rndInt == 2)
|
||||
NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail
|
||||
if (rndInt == 3)
|
||||
NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail
|
||||
Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||
int timeMinutes = 0;
|
||||
int timeMinutes;
|
||||
|
||||
if (((int)(user.JailTime / 60)) <= 1 && user.JailTime != 0)
|
||||
if ((user.JailTime / 60) <= 1 && user.JailTime != 0)
|
||||
{
|
||||
timeMinutes = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeMinutes = (int)(user.JailTime / 60);
|
||||
timeMinutes = (user.JailTime / 60);
|
||||
}
|
||||
client.TriggerEvent("jailTime", timeMinutes);
|
||||
player.TriggerEvent("jailTime", timeMinutes);
|
||||
return;
|
||||
}
|
||||
if (user.Wanteds <= 0)
|
||||
return;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if (!copPlayer.IsLoggedIn()) continue;
|
||||
User cop = copPlayer.GetUser();
|
||||
if (cop?.FactionId == 1 || cop?.FactionId == 3)
|
||||
{
|
||||
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)
|
||||
{
|
||||
jailTime /= 2;
|
||||
}
|
||||
|
||||
User clientUser = client.GetUser(dbContext);
|
||||
|
||||
clientUser.JailTime = jailTime;
|
||||
Jailtime[user.Id] = jailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||
|
||||
clientUser.Wanteds = 0;
|
||||
client.SetData("isDead", false);
|
||||
client.RemoveAllWeapons();
|
||||
client.SetSharedData("blipColor", 0);
|
||||
Random rnd = new Random();
|
||||
int rndInt = rnd.Next(1, 3);
|
||||
if (rndInt == 1)
|
||||
NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
|
||||
if (rndInt == 2)
|
||||
NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //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");
|
||||
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name);
|
||||
Medic.RemoveTaskFromList(task);
|
||||
client.Health = 100;
|
||||
|
||||
int timeMinutes = 0;
|
||||
|
||||
if (((int)(Jailtime[user.Id] / 60)) <= 1 && Jailtime[user.Id] != 0)
|
||||
{
|
||||
timeMinutes = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeMinutes = (int)(Jailtime[user.Id] / 60);
|
||||
}
|
||||
|
||||
client.TriggerEvent("jailTime", JsonConvert.SerializeObject(timeMinutes));
|
||||
|
||||
clientUser.SetBlipAndNametagColor();
|
||||
|
||||
if (announceHq)
|
||||
{
|
||||
ChatService.BroadcastFaction("!{#8181E9}HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List<int>() { 1, 3 });
|
||||
}
|
||||
}
|
||||
else if (user.Wanteds > 0 && user.JailTime <= 0)
|
||||
{
|
||||
ChatService.BroadcastFaction("!{#8181E9}HQ: Der Verdächtigte " + user.Name + " wurde soeben ins Krankenhaus eingeliefert.", new System.Collections.Generic.List<int>() { 1, 3 });
|
||||
}
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -136,23 +69,28 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
|
||||
public static void JailIn_Elapsed()
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user != null && !Jailtime.ContainsKey(user.Id))
|
||||
if (player.Position.DistanceTo(new Vector3(458.9842, -997.2126, 24.91485)) > 7)
|
||||
{
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||
continue;
|
||||
}
|
||||
|
||||
User user = player.GetUser();
|
||||
|
||||
if (user != null && user.Wanteds > 0 && !Jailtime.ContainsKey(user.Id))
|
||||
{
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers().Where(u => u.IsLoggedIn() && u.IsDuty())
|
||||
{
|
||||
if (!copPlayer.IsLoggedIn()) return;
|
||||
User cop = copPlayer.GetUser();
|
||||
if (cop.GetData<bool>("duty") && copPlayer.Position.DistanceTo2D(player.Position) <= 500 && (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true))
|
||||
if (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true)
|
||||
{
|
||||
if (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) <= 7)
|
||||
if (player.Position.DistanceTo(copPlayer.Position) < 5)
|
||||
{
|
||||
if (player.Position.DistanceTo2D(copPlayer.Position) < 5)
|
||||
{
|
||||
Check_PutBehindBars(player);
|
||||
}
|
||||
user.SetJailTime(false);
|
||||
user.AnnouncePlayerJailedIn();
|
||||
dbContext.SaveChanges();
|
||||
Check_PutBehindBars(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,9 +121,10 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
|
||||
public static void JailOut_Elapsed()
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User user = player.GetUser();
|
||||
User user = player.GetUser(dbContext);
|
||||
if (user != null && Jailtime.ContainsKey(user.Id))
|
||||
{
|
||||
if (user.JailTime <= 0)
|
||||
@@ -197,11 +136,7 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
}
|
||||
if (user.JailTime > 0)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
player.GetUser(dbContext).JailTime -= 60;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
user.JailTime -= 60;
|
||||
|
||||
int timeMinutes = 0;
|
||||
|
||||
@@ -219,15 +154,16 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
}
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("setPrisonerFree")]
|
||||
public void Release_Jail(Player cop, string client)
|
||||
{
|
||||
Player player = PlayerService.GetPlayerByNameOrId(client);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
User user = player.GetUser();
|
||||
if (Jailtime.ContainsKey(user.Id))
|
||||
{
|
||||
@@ -248,15 +184,15 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
|
||||
public static void Release_Jail_Admin(Player admin, Player target)
|
||||
{
|
||||
User user = target.GetUser();
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = target.GetUser(dbContext);
|
||||
if (Jailtime.ContainsKey(user.Id))
|
||||
{
|
||||
Jailtime.Remove(user.Id);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
target.GetUser(dbContext).JailTime = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
user.JailTime = 0;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
target.Health = 100;
|
||||
target.Position = new Vector3(427.879, -984.65, 30.71);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user