maybe fix knast
This commit is contained in:
@@ -33,17 +33,12 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
PositionManager.cuffPoints.Remove(player);
|
PositionManager.cuffPoints.Remove(player);
|
||||||
|
|
||||||
player.SetData("isDead", true);
|
|
||||||
|
|
||||||
using (var userDeath = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User userisdead = player.GetUser(userDeath);
|
|
||||||
userisdead.Dead = true;
|
|
||||||
userDeath.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Zum Full Release entfernen
|
//TODO: Zum Full Release entfernen
|
||||||
if (player.HasData("togdeath"))
|
if (player.HasData("togdeath"))
|
||||||
{
|
{
|
||||||
@@ -88,10 +83,25 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = player.GetUser();
|
bool copNearby = NAPI.Pools.GetAllPlayers().Any(u => u.IsDuty() && u.IsAlive() && u.Position.DistanceToSquared(player.Position) <= 200 * 200);
|
||||||
|
|
||||||
|
if (copNearby)
|
||||||
|
{
|
||||||
|
user.SetJailTime(true);
|
||||||
|
Jail.Check_PutBehindBars(user);
|
||||||
|
ChatService.HQMessage(user.Name + " wurde ins Gefängnis eingeliefert.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChatService.HQMessage(user.Name + " wurde soeben ins Krankenhaus eingeliefert.");
|
||||||
|
}
|
||||||
|
|
||||||
if (user.JailTime <= 0)
|
if (user.JailTime <= 0)
|
||||||
{
|
{
|
||||||
|
player.SetData("isDead", true);
|
||||||
|
|
||||||
|
user.Dead = true;
|
||||||
|
|
||||||
if (!player.HasData("reviveSperre"))
|
if (!player.HasData("reviveSperre"))
|
||||||
{
|
{
|
||||||
//MEDIC AUFTRAG
|
//MEDIC AUFTRAG
|
||||||
@@ -123,10 +133,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||||
|
|
||||||
player.ClearAttachments();
|
player.ClearAttachments();
|
||||||
|
List<UserItem> fItem = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||||
using (var userDeath = new DatabaseContext())
|
|
||||||
{
|
|
||||||
List<UserItem> fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList();
|
|
||||||
foreach (var item in fItem)
|
foreach (var item in fItem)
|
||||||
{
|
{
|
||||||
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
||||||
@@ -147,8 +154,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||||
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
||||||
|
|
||||||
userDeath.Remove(item);
|
dbContext.Remove(item);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var dead = new Database.Entities.Logs.Death
|
var dead = new Database.Entities.Logs.Death
|
||||||
@@ -165,8 +171,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
VictimHeading = player.Heading,
|
VictimHeading = player.Heading,
|
||||||
CauseOfDeath = reason.ToString()
|
CauseOfDeath = reason.ToString()
|
||||||
};
|
};
|
||||||
userDeath.DeathLogs.Add(dead);
|
dbContext.DeathLogs.Add(dead);
|
||||||
userDeath.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Job.JobBase job = Managers.JobManager.GetJob(player.GetUser().JobId ?? -1);
|
Job.JobBase job = Managers.JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||||
@@ -219,9 +225,6 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
//ChatService.SendMessage(player, "Debug10");
|
//ChatService.SendMessage(player, "Debug10");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//JailTime.cs
|
|
||||||
Jail.Check_PutBehindBars(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
player.SetData("dbId", user.Id);
|
||||||
player.Name = username;
|
player.Name = username;
|
||||||
player.TriggerEvent("SERVER:Login_Success");
|
player.TriggerEvent("SERVER:Login_Success");
|
||||||
player.TriggerEvent("CLIENT:StopSound");
|
player.TriggerEvent("CLIENT:StopSound");
|
||||||
@@ -122,7 +123,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Jail.Check_PutBehindBars(player);
|
Jail.Check_PutBehindBars(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
dbContext.Users.Add(user);
|
dbContext.Users.Add(user);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SetData("dbId", user.Id);
|
||||||
player.TriggerEvent("SERVER:Login_Success");
|
player.TriggerEvent("SERVER:Login_Success");
|
||||||
player.TriggerEvent("CLIENT:StopSound");
|
player.TriggerEvent("CLIENT:StopSound");
|
||||||
player.SetData("isLoggedIn", true);
|
player.SetData("isLoggedIn", true);
|
||||||
|
|||||||
@@ -59,6 +59,34 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetJailTime(this User user, bool killed)
|
||||||
|
{
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int time = 26 * user.Wanteds;
|
||||||
|
if (killed)
|
||||||
|
{
|
||||||
|
time *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.Wanteds = 0;
|
||||||
|
user.JailTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnnouncePlayerJailedIn(this User user)
|
||||||
|
{
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string message = user.Name + " wurde ins Gefängnis geliefert";
|
||||||
|
|
||||||
|
ChatService.HQMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt zurück, ob ein Player eingeloggt ist
|
/// Gibt zurück, ob ein Player eingeloggt ist
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -76,8 +104,35 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
|
|
||||||
public static bool IsDuty(this Player player)
|
public static bool IsDuty(this Player player)
|
||||||
{
|
{
|
||||||
var user = player.GetUser();
|
return player.GetServerData("duty", false);
|
||||||
return user.GetData("duty", false);
|
}
|
||||||
|
|
||||||
|
public static bool IsAlive(this Player player)
|
||||||
|
{
|
||||||
|
return !player.HasData("isDead") || (bool)player.GetData("isDead") == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetServerData<T>(this Player player, string key, T defaultValue = default)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
key += "data_";
|
||||||
|
if (!player.HasData(key)) return defaultValue;
|
||||||
|
return JsonConvert.DeserializeObject<T>(player.GetData<dynamic>(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetServerData(this Player player, string key, object value)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
key += "data_";
|
||||||
|
player.SetData(key, JsonConvert.SerializeObject(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsAdminDuty(this Player player)
|
public static bool IsAdminDuty(this Player player)
|
||||||
@@ -98,27 +153,14 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
|
|
||||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||||
{
|
{
|
||||||
if (user == null)
|
return user.Player.GetServerData(key, nullValue);
|
||||||
{
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
key += "data_";
|
|
||||||
if (!user.Player.HasData(key)) return nullValue;
|
|
||||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||||
|
|
||||||
internal static void SetData(this User user, string key, object value)
|
internal static void SetData(this User user, string key, object value)
|
||||||
{
|
{
|
||||||
if (user == null)
|
user.Player.SetServerData(key, value);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
key += "data_";
|
|
||||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
|
|
||||||
if (putInJail != 0 && minusJail)
|
if (putInJail != 0 && minusJail)
|
||||||
{
|
{
|
||||||
Jail.Check_PutBehindBars(client, false);
|
Jail.Check_PutBehindBars(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Services;
|
|||||||
using ReallifeGamemode.Services;
|
using ReallifeGamemode.Services;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using ReallifeGamemode.Server.Managers;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Wanted
|
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
|
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)
|
if (user.JailTime > 0)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
player.RemoveAllWeapons();
|
||||||
client.Health = 100;
|
player.Health = 100;
|
||||||
client.Armor = 0;
|
player.Armor = 0;
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
int rndInt = rnd.Next(1, 3);
|
int rndInt = rnd.Next(1, 3);
|
||||||
if (rndInt == 1)
|
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)
|
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)
|
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
|
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;
|
timeMinutes = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeMinutes = (int)(user.JailTime / 60);
|
timeMinutes = (user.JailTime / 60);
|
||||||
}
|
}
|
||||||
client.TriggerEvent("jailTime", timeMinutes);
|
player.TriggerEvent("jailTime", timeMinutes);
|
||||||
return;
|
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()
|
public static void JailIn_Elapsed()
|
||||||
{
|
{
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
{
|
{
|
||||||
User user = player.GetUser();
|
if (player.Position.DistanceTo(new Vector3(458.9842, -997.2126, 24.91485)) > 7)
|
||||||
if (user != null && !Jailtime.ContainsKey(user.Id))
|
|
||||||
{
|
{
|
||||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
continue;
|
||||||
{
|
|
||||||
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 (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) <= 7)
|
|
||||||
{
|
|
||||||
if (player.Position.DistanceTo2D(copPlayer.Position) < 5)
|
|
||||||
{
|
|
||||||
Check_PutBehindBars(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true)
|
||||||
|
{
|
||||||
|
if (player.Position.DistanceTo(copPlayer.Position) < 5)
|
||||||
|
{
|
||||||
|
user.SetJailTime(false);
|
||||||
|
user.AnnouncePlayerJailedIn();
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
Check_PutBehindBars(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,9 +121,10 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
|
|
||||||
public static void JailOut_Elapsed()
|
public static void JailOut_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 (user != null && Jailtime.ContainsKey(user.Id))
|
if (user != null && Jailtime.ContainsKey(user.Id))
|
||||||
{
|
{
|
||||||
if (user.JailTime <= 0)
|
if (user.JailTime <= 0)
|
||||||
@@ -197,11 +136,7 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
}
|
}
|
||||||
if (user.JailTime > 0)
|
if (user.JailTime > 0)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
user.JailTime -= 60;
|
||||||
{
|
|
||||||
player.GetUser(dbContext).JailTime -= 60;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
int timeMinutes = 0;
|
int timeMinutes = 0;
|
||||||
|
|
||||||
@@ -219,6 +154,7 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("setPrisonerFree")]
|
[RemoteEvent("setPrisonerFree")]
|
||||||
@@ -248,15 +184,15 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
|
|
||||||
public static void Release_Jail_Admin(Player admin, Player target)
|
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))
|
if (Jailtime.ContainsKey(user.Id))
|
||||||
{
|
{
|
||||||
Jailtime.Remove(user.Id);
|
Jailtime.Remove(user.Id);
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
user.JailTime = 0;
|
||||||
target.GetUser(dbContext).JailTime = 0;
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
|
||||||
target.Health = 100;
|
target.Health = 100;
|
||||||
target.Position = new Vector3(427.879, -984.65, 30.71);
|
target.Position = new Vector3(427.879, -984.65, 30.71);
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
|
|
||||||
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 (user != null && user.Wanteds > 0)
|
if (user != null && user.Wanteds > 0)
|
||||||
{
|
{
|
||||||
if (!waTimer.ContainsKey(user.Id))
|
if (!waTimer.ContainsKey(user.Id))
|
||||||
@@ -68,30 +69,10 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
{
|
{
|
||||||
ResetWantedTimeToElapse(player);
|
ResetWantedTimeToElapse(player);
|
||||||
player.SendChatMessage("~y~Du hast erfolgtreich einen Wanted abgetaucht.");
|
player.SendChatMessage("~y~Du hast erfolgtreich einen Wanted abgetaucht.");
|
||||||
using (var dbContext = new DatabaseContext())
|
user.Wanteds -= 1;
|
||||||
|
if (user.Wanteds == 0)
|
||||||
{
|
{
|
||||||
player.GetUser(dbContext).Wanteds -= 1;
|
user.SetBlipAndNametagColor();
|
||||||
if (player.GetUser(dbContext).Wanteds == 0)
|
|
||||||
{
|
|
||||||
switch (player.GetUser(dbContext).FactionId)
|
|
||||||
{
|
|
||||||
case null:
|
|
||||||
player.SetSharedData("blipColor", 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
player.SetSharedData("blipColor", 83);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
player.SetSharedData("blipColor", 52);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
player.SetSharedData("blipColor", 5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user