From ee302d76b1c06b05ef361a989b0db6d0308b71e4 Mon Sep 17 00:00:00 2001 From: Mac_Slash Date: Thu, 9 Apr 2020 22:00:45 +0200 Subject: [PATCH] Add Keine Punkte Vergabe ohne FS und keine Minus Punkte --- .../Managers/InteractionManager.cs | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 6ebb1010..1b0be853 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -396,33 +396,47 @@ namespace ReallifeGamemode.Server.Managers Player target = PlayerService.GetPlayerByNameOrId(nameOrId); string playername = NAPI.Player.GetPlayerName(player); string targetname = NAPI.Player.GetPlayerName(target); - using (var dbContext = new DatabaseContext()) + if (target.GetUser().DriverLicenseVehicle == false && target.GetUser().DriverLicenseBike == false) { - 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); - if(target.GetUser().Points >= 8) - { - target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~8/8 ~x~Strafpunkten.", true); - target.SendNotification($"~w~Dir wird ~r~Auo- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); - 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}/8 ~x~Strafpunkten.", true); + if (amount > 0 && amount < 9) + { + 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); + if (target.GetUser().Points >= 8) + { + target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~8/8 ~x~Strafpunkten.", true); + target.SendNotification($"~w~Dir wird ~r~Auo- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); + 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}/8 ~x~Strafpunkten.", true); + } } + else + { + player.SendNotification("~r~Du kannst nur zwischen 1 und 8 Punkte verteilen!"); + } + } + else + { + player.SendNotification("~r~Spieler hat weder Auto- noch Motorradführerschein!"); + } + } #endregion #region Spielerinteraktionen PFEILTASTE-LINKS [RemoteEvent("openTradeInventory")]