diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index 169a070b..4601cb67 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -133,11 +133,14 @@ export default function animationSync() { mp.events.callRemote("CLIENT:ClearAnimationData", false); } + const blockInputControls = [12, 13, 14, 15, 22, 24, 25, 37, 261, 262]; + mp.events.add("render", () => { + mp.gui.chat.push("blockInput = " + blockInput); if (blockInput) { - mp.game.controls.disableControlAction(32, 25, true); - mp.game.controls.disableControlAction(32, 24, true); - mp.game.controls.disableControlAction(32, 22, true); + blockInputControls.forEach((ctrl) => { + mp.game.controls.disableControlAction(32, ctrl, true); + }); } }); diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index c810c4ff..afcd7ad6 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -94,6 +94,8 @@ namespace ReallifeGamemode.Server.Events } } + Medic.delHealTask(player); + if (user.JailTime <= 0) { user.Dead = true; @@ -113,7 +115,6 @@ namespace ReallifeGamemode.Server.Events MedicName = "none" }; Medic.AddTaskToList(reviveTask); - Medic.delHealTask(player); ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " ist soeben verstorben.", new List() { 2 }); } diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 9bba8fc6..8872b5a5 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -438,6 +438,7 @@ namespace ReallifeGamemode.Server.Extensions return; player.SyncAnimation("hup"); + NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed); if (player.GetUser().Wanteds > 0) PositionManager.cuffPoints.Add(player); diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 7bb2fd2d..f5c27650 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -263,7 +263,7 @@ namespace ReallifeGamemode.Server.Factions.Medic { player.SetData("healauftrag", false); var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName); - if (task.MedicName != "none") + if (medicPlayer != null) { medicPlayer.TriggerEvent("destroyMedicTaskCheckpoint"); } diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index d7684129..f8872d99 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -486,7 +486,7 @@ namespace ReallifeGamemode.Server.Managers using var dbContext = new DatabaseContext(); var user = player.GetUser(dbContext); - if(user.FactionId == null) + if (user.FactionId == null) { return; } @@ -517,7 +517,7 @@ namespace ReallifeGamemode.Server.Managers } var factionVehicleCount = dbContext.FactionVehicles.ToList().Where(v => v.Id == id && v.GetOwners().Contains(user.FactionId.Value)).Count(); - if(factionVehicleCount <= 6) + if (factionVehicleCount <= 6) { ChatService.ErrorMessage(player, "Die Fraktion braucht mindestens 6 Fahrzeuge"); return; @@ -589,85 +589,76 @@ namespace ReallifeGamemode.Server.Managers public void InteractionMenu_LSPD_Points3(Player player, string jsonNameOrId, string jsoAmount, string jsonReason) { string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId); - int amount = Int32.Parse((string)JsonConvert.DeserializeObject(jsoAmount)); string reason = (string)JsonConvert.DeserializeObject(jsonReason); Player target = PlayerService.GetPlayerByNameOrId(nameOrId); string playername = NAPI.Player.GetPlayerName(player); string targetname = NAPI.Player.GetPlayerName(target); + + if (!int.TryParse((string)JsonConvert.DeserializeObject(jsoAmount), out int amount)) + { + player.SendNotification("~r~Es muss eine gültige Zahl für die Punkte angegeben werden!"); + return; + } + if (target == null || !target.IsLoggedIn()) { ChatService.PlayerNotFound(player); return; } - else if (target.GetUser().DriverLicenseVehicle == false && target.GetUser().DriverLicenseBike == false) - { - player.SendNotification("~r~Spieler hat weder Auto- noch Motorradführerschein!"); - } - else if (target == player) + + if (target == player) { player.SendNotification("~r~Du kannst dir selbst keine Punkte setzen!"); + return; + } + + using var dbContext = new DatabaseContext(); + User targetUser = target.GetUser(dbContext); + + if(targetUser == null) + { + ChatService.PlayerNotFound(player); + return; + } + + if (targetUser.DriverLicenseVehicle == false && targetUser.DriverLicenseBike == false) + { + player.SendNotification("~r~Spieler hat weder Auto- noch Motorradführerschein!"); + return; + } + + if (amount < -13 || amount > 13) + { + player.SendNotification("~r~Du kannst nur zwischen 1 und 12 Punkte verteilen!"); + return; + } + + targetUser.Points += amount; + + player.SendNotification($"~w~Du hast ~y~{targetname} ~b~{amount} ~w~Strafpunkte gegeben. Grund: ~g~{reason}~w~."); + target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ~y~{amount} ~w~Strafpunkte gegeben.", true); + ChatService.HQMessage(targetname + " hat von " + playername + " " + amount + " Strafpunkt(e) erhalten. Gesamt: " + targetUser.Points); + + if (targetUser.Points < 0) + { + targetUser.Points = 0; + dbContext.SaveChanges(); + } + else if (targetUser.Points >= 12) + { + target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~12/12 ~x~Strafpunkten.", true); + target.SendNotification($"~w~Dir wird ~r~Auto- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); //FlashNotif + + ChatService.HQMessage(targetname + " besitzt nun keinen Führerschein mehr."); + + targetUser.Points = 0; + targetUser.DriverLicenseVehicle = false; + targetUser.DriverLicenseBike = false; + dbContext.SaveChanges(); } else { - if (amount > -13 && amount < 13) - { - using (var dbContext = new DatabaseContext()) - { - User target2 = target.GetUser(dbContext); - target2.Points += amount; - dbContext.SaveChanges(); - } - player.SendNotification($"~w~Du hast ~y~{targetname} ~b~{amount} ~w~Strafpunkte gegeben. Grund: ~g~{reason}~w~."); - target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ~y~{amount} ~w~Strafpunkte gegeben.", true); - ChatService.BroadcastFaction("!{#8181E9}HQ: " + targetname + " hat von " + playername + " " + amount + " Strafpunkt(e) erhalten. Gesamt: " + target.GetUser().Points, new List() { 1, 3 }); - if (target.GetUser().Points < 0) - { - using (var dbContext = new DatabaseContext()) - { - User target2 = target.GetUser(dbContext); - target2.Points = 0; - dbContext.SaveChanges(); - } - } - else if (target.GetUser().Points >= 12) - { - target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~12/12 ~x~Strafpunkten.", true); - target.SendNotification($"~w~Dir wird ~r~Auto- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); //FlashNotif - ChatService.HQMessage(targetname + "hat von" + playername + " " + amount + " Strafpunkt erhalten(e). Gesamt: " + target.GetUser().Points); - foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) - { - User copUser = copPlayer.GetUser(); - if (copUser == null) - { - continue; - } - - if (copUser.FactionId == 1 || copUser.FactionId == 3) - { - if (copUser.GetData("duty") == true) - { - ChatService.HQMessage(targetname + " besitzt nun keinen Führerschein mehr."); - } - } - } - using (var dbContext = new DatabaseContext()) - { - User target2 = target.GetUser(dbContext); - target2.Points = 0; - target2.DriverLicenseVehicle = false; - target2.DriverLicenseBike = false; - dbContext.SaveChanges(); - } - } - else - { - target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~y~{target.GetUser().Points}/12 ~x~Strafpunkten.", true); - } - } - else - { - player.SendNotification("~r~Du kannst nur zwischen 1 und 12 Punkte verteilen!"); - } + target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~y~{targetUser.Points}/12 ~x~Strafpunkten.", true); } }