This commit is contained in:
hydrant
2021-04-07 23:42:02 +02:00
parent 3f2cdbeea8
commit 0722816765
2 changed files with 5 additions and 3 deletions

View File

@@ -109,7 +109,7 @@ namespace ReallifeGamemode.Server.Extensions
public static bool IsAlive(this Player player) public static bool IsAlive(this Player player)
{ {
return !player.HasData("isDead") || (bool)player.GetData("isDead") == false; return !player.HasData("isDead") || player.GetData<bool>("isDead") == false;
} }
public static T GetServerData<T>(this Player player, string key, T defaultValue = default) public static T GetServerData<T>(this Player player, string key, T defaultValue = default)

View File

@@ -81,9 +81,10 @@ namespace ReallifeGamemode.Server.Wanted
if (user != null && user.Wanteds > 0 && !Jailtime.ContainsKey(user.Id)) if (user != null && user.Wanteds > 0 && !Jailtime.ContainsKey(user.Id))
{ {
foreach (var copPlayer in NAPI.Pools.GetAllPlayers().Where(u => u.IsLoggedIn() && u.IsDuty()) foreach (var copPlayer in NAPI.Pools.GetAllPlayers().Where(u => u.IsLoggedIn() && u.IsDuty() && u.IsAlive()))
{ {
if (!copPlayer.HasData("isDead") || copPlayer.GetData<bool>("isDead") != true) User copUser = copPlayer.GetUser(dbContext);
if (copUser.FactionId == 1 || copUser.FactionId == 3)
{ {
if (player.Position.DistanceTo(copPlayer.Position) < 5) if (player.Position.DistanceTo(copPlayer.Position) < 5)
{ {
@@ -91,6 +92,7 @@ namespace ReallifeGamemode.Server.Wanted
user.AnnouncePlayerJailedIn(); user.AnnouncePlayerJailedIn();
dbContext.SaveChanges(); dbContext.SaveChanges();
Check_PutBehindBars(user); Check_PutBehindBars(user);
break;
} }
} }
} }