neuer knast: punkte geändert

This commit is contained in:
Fabian
2021-04-26 21:18:51 +02:00
parent cd601c4a87
commit 0ab081cccb
4 changed files with 33 additions and 17 deletions

View File

@@ -148,7 +148,7 @@ namespace ReallifeGamemode.Server.Events
if (copNearby) if (copNearby)
{ {
user.SetJailTime(true, dbContext); user.SetJailTime(true, dbContext);
Jail.Check_PutBehindBars(user); Jail.Check_PutBehindBars(user, "cell");
ChatService.HQMessage(user.Name + " wurde ins Gefängnis eingeliefert."); ChatService.HQMessage(user.Name + " wurde ins Gefängnis eingeliefert.");
} }
else else

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -164,7 +164,7 @@ namespace ReallifeGamemode.Server.Events
} }
else else
{ {
Jail.Check_PutBehindBars(user); Jail.Check_PutBehindBars(user, "cell");
} }
player.Dimension = 0; player.Dimension = 0;

View File

@@ -200,7 +200,7 @@ namespace ReallifeGamemode.Server.Finance
if (putInJail != 0 && minusJail) if (putInJail != 0 && minusJail)
{ {
Jail.Check_PutBehindBars(u); Jail.Check_PutBehindBars(u, "cell");
} }
} }

View File

@@ -19,7 +19,18 @@ 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(User user) private static Vector3 JailIn_Point = new Vector3(1690.754, 2591.0464, 45.914402);
private static int JailIn_Range = 3;
private static Vector3 JailOut_Point = new Vector3(1848.3097, 2585.9036, 45.67201);
private static List<Vector3> prisonCells = new List<Vector3>() {
new Vector3(1629.2026, 2569.8057, 45.564846),
new Vector3(1642.7831, 2570.2622, 45.56483),
new Vector3(1651.512, 2570.2249, 45.564907)
};
//positionInJail: ENTWEDER "cell" ODER "outside"
public static void Check_PutBehindBars(User user, String positionInJail)
{ {
user.SetBlipAndNametagColor(); user.SetBlipAndNametagColor();
Player player = user.Player; Player player = user.Player;
@@ -31,15 +42,19 @@ namespace ReallifeGamemode.Server.Wanted
player.ClearAnimation(); player.ClearAnimation();
player.SafeSetHealth(100); player.SafeSetHealth(100);
player.Armor = 0; player.Armor = 0;
Vector3 position = null;
if (positionInJail == "cell")
{
Random rnd = new Random(); Random rnd = new Random();
int rndInt = rnd.Next(1, 3); int rndInt = rnd.Next(1, 3);
Vector3 position = new Vector3(); position = prisonCells[rndInt];
if (rndInt == 1)
position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail } else if (positionInJail == "outside")
if (rndInt == 2) {
position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail position = new Vector3(1691.42, 2562.77, 45.56);
if (rndInt == 3) }
position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail
player.SafeTeleport(position, 0, true); player.SafeTeleport(position, 0, true);
@@ -78,7 +93,7 @@ namespace ReallifeGamemode.Server.Wanted
using var dbContext = new DatabaseContext(); using var dbContext = new DatabaseContext();
foreach (var player in NAPI.Pools.GetAllPlayers()) foreach (var player in NAPI.Pools.GetAllPlayers())
{ {
if (player.Position.DistanceTo(new Vector3(458.9842, -997.2126, 24.91485)) > 7) if (player.Position.DistanceTo(JailIn_Point) > JailIn_Range)
{ {
continue; continue;
} }
@@ -98,7 +113,8 @@ namespace ReallifeGamemode.Server.Wanted
user.SetBlipAndNametagColor(); user.SetBlipAndNametagColor();
user.AnnouncePlayerJailedIn(); user.AnnouncePlayerJailedIn();
dbContext.SaveChanges(); dbContext.SaveChanges();
Check_PutBehindBars(user); //HERE: Freilauf
Check_PutBehindBars(user, "outside");
break; break;
} }
} }
@@ -139,7 +155,7 @@ namespace ReallifeGamemode.Server.Wanted
if (user.JailTime <= 0) if (user.JailTime <= 0)
{ {
Jailtime.Remove(user.Id); Jailtime.Remove(user.Id);
player.SafeTeleport(new Vector3(427.879, -984.65, 30.71)); player.SafeTeleport(JailOut_Point);
player.TriggerEvent("jailTime", 0); player.TriggerEvent("jailTime", 0);
return; return;
} }