From 746998a9d585d38870ad849d818594e3adad7345 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 2 Aug 2020 21:16:35 +0200 Subject: [PATCH] fix tuning weg bei /respawnvehicle --- ReallifeGamemode.Server/Commands/AdminCommands.cs | 8 ++++---- .../Extensions/ServerVehicleExtensions.cs | 4 +++- ReallifeGamemode.Server/Managers/VehicleManager.cs | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index eab2f1cb..9976f17f 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1171,8 +1171,8 @@ namespace ReallifeGamemode.Server.Commands } } - [Command("respawnvehicle")] - public void CmdAdminRespawnVehicle(Player player, int? id = null) + [Command("respawnvehicle", "~m~Benutzung: ~s~/respawnvehicle (Db ID)", Alias = "rveh")] + public void CmdAdminRespawnVehicle(Player player, int id = -1) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1182,14 +1182,14 @@ namespace ReallifeGamemode.Server.Commands Vehicle veh = null; - if (id == null) + if (id == -1) { var nearestVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault(); veh = nearestVeh; } else { - veh = VehicleManager.GetVehicleFromId(id.Value); + veh = VehicleManager.GetVehicleFromId(id); } if (veh == null) diff --git a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs index faf9c0a0..5e4c3c38 100644 --- a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs +++ b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs @@ -1,4 +1,4 @@ -using GTANetworkAPI; +using GTANetworkAPI; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Server.Job; using ReallifeGamemode.Server.Managers; @@ -74,6 +74,8 @@ namespace ReallifeGamemode.Server.Extensions NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate); veh.NumberPlate = numberplate; + TuningManager.ApplyTuningToServerVehicle(veh); + return newVeh; } } diff --git a/ReallifeGamemode.Server/Managers/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index 9f61cb23..5ea9b10f 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -832,6 +832,11 @@ namespace ReallifeGamemode.Server.Managers public static Vehicle GetVehicleFromServerVehicle(ServerVehicle serverVehicle) { + if (serverVehicle == null) + { + return null; + } + if (!_serverVehicles.ContainsKey(serverVehicle.Id)) { return null;