From f80c0b7f64c86904487e20ef9957184ea91e581f Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Sat, 20 Jul 2019 14:02:37 +0200 Subject: [PATCH] Fix Jail --- ReallifeGamemode.Server/Events/Death.cs | 37 ++++++++++++++----------- ReallifeGamemode.Server/Wanted/Jail.cs | 21 +++++++++----- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index eac4fce0..32cd2f1b 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -1,5 +1,6 @@ using System; using GTANetworkAPI; +using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Models; @@ -76,24 +77,28 @@ namespace ReallifeGamemode.Server.Events } } - - - //MEDIC AUFTRAG - MedicTask reviveTask = new MedicTask() + User user = player.GetUser(); + if(user.JailTime <= 0) { - Victim = player.Name, - Position = player.Position, - CauseOfDeath = reason.ToString(), - Caller = null, - Description = "Gestorben", - Time = DateTime.Now, - Type = MedicTaskType.REVIVE, - MedicName = "none" - }; - Medic.AddTaskToList(reviveTask); + //MEDIC AUFTRAG + MedicTask reviveTask = new MedicTask() + { + Victim = player.Name, + Position = player.Position, + CauseOfDeath = reason.ToString(), + Caller = null, + Description = "Gestorben", + Time = DateTime.Now, + Type = MedicTaskType.REVIVE, + MedicName = "none" + }; + Medic.AddTaskToList(reviveTask); + + //TODO PICTURE NOTIFICATION + SOUND für Medics + } + + - //TODO PICTURE NOTIFICATION + SOUND für Medics - using (var userDeath = new DatabaseContext()) { var dead = new Entities.Logs.Death diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 979aa1c2..2ab0ec17 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -21,14 +21,22 @@ namespace ReallifeGamemode.Server.Wanted User user = client.GetUser(); if (user.JailTime > 0) { + + client.SetData("isDead", false); + client.RemoveAllWeapons(); Random rnd = new Random(); int rndInt = rnd.Next(1, 3); if (rndInt == 1) - client.Position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail + NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail if (rndInt == 2) - client.Position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail + NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail if (rndInt == 3) - client.Position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail + 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; Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds return; @@ -57,6 +65,8 @@ namespace ReallifeGamemode.Server.Wanted dbContext.SaveChanges(); } + } + client.SetData("isDead", false); client.RemoveAllWeapons(); Random rnd = new Random(); @@ -73,11 +83,8 @@ namespace ReallifeGamemode.Server.Wanted Medic.RemoveTaskFromList(task); client.Health = 100; - - ChatService.BroadcastFaction("~r~HQ: " + user.Name + " wurde im Gefängnis zugewiesen.", new List() { 1, 3 }); - ChatService.SendMessage(client, "Du bist im Gefängnis für " + jailTime + " Sekunden."); - + ChatService.BroadcastFaction("~r~HQ: " + user.Name + " wurde ins Gefängnis geliefert.", new List() {1,3}); } } }