From 9860d39992669141cd606530243314f4fe70f138 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 2 Aug 2020 18:03:31 +0200 Subject: [PATCH] =?UTF-8?q?fahrzeug=20respawn=20/respaenvehicle=20(optiona?= =?UTF-8?q?l=20id=20sonst=20n=C3=A4chstes=20fahrzeug)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/AdminCommands.cs | 53 ++++++++++++++++--- ReallifeGamemode.Server/Events/Key.cs | 20 +++---- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 019f7f5d..eab2f1cb 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; @@ -321,12 +322,12 @@ namespace ReallifeGamemode.Server.Commands [Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)] public void CmdAdminO(Player player, string message) { - /* if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - */ + /* if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + */ message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", ""); message = Regex.Replace(message, "#([0-9A-Fa-f]{6})", m => "!{" + m.Groups[0].Value + "}"); @@ -1170,6 +1171,46 @@ namespace ReallifeGamemode.Server.Commands } } + [Command("respawnvehicle")] + public void CmdAdminRespawnVehicle(Player player, int? id = null) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Vehicle veh = null; + + if (id == null) + { + var nearestVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault(); + veh = nearestVeh; + } + else + { + veh = VehicleManager.GetVehicleFromId(id.Value); + } + + if (veh == null) + { + ChatService.ErrorMessage(player, "Dieses Fahrzeug wurde nicht gefunden"); + return; + } + + ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh); + + if (serverVehicle == null) + { + ChatService.ErrorMessage(player, $"Dieses Fahrzeug kann nur gelöscht werden: ~m~/vdestroy {veh.Handle.Value}"); + return; + } + + Vehicle newVeh = serverVehicle.Spawn(veh); + newVeh.Repair(); + newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading); + } + #endregion ALevel1 #region ALevel2 diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index afecbe2b..4e4e9b7f 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -179,14 +179,14 @@ namespace ReallifeGamemode.Server.Events ticket_amount = player.GetData("ticket_amount"); } - if(player.HasData("pay_amount")) + if (player.HasData("pay_amount")) { pay_amount = player.GetData("pay_amount"); } - player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount); - - } + player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount); + + } [RemoteEvent("keyPress:E")] public void KeyPressE(Player player) @@ -399,7 +399,7 @@ namespace ReallifeGamemode.Server.Events List weapons = context.FactionWeapons.Where(w => w.FactionId == user.FactionId).ToList(); Database.Entities.Faction faction = context.Factions.Where(fac => fac.Id == user.FactionId).FirstOrDefault(); - + if (faction.WeaponDealTime > 0) dealTime = "noch " + faction.WeaponDealTime.ToString() + " min. übrig"; @@ -441,13 +441,15 @@ namespace ReallifeGamemode.Server.Events foreach (var weapon in weapons) { if (weapon.WeaponModel == "Pistol") - { + { pistol_Amount = weapon.Ammount; } - else if(weapon.WeaponModel == "Pistol50"){ + else if (weapon.WeaponModel == "Pistol50") + { pistol50_Amount = weapon.Ammount; } - else if(weapon.WeaponModel == "Pistol_MK2") { + else if (weapon.WeaponModel == "Pistol_MK2") + { Pistol_mk2_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Combatpistol") @@ -480,7 +482,7 @@ namespace ReallifeGamemode.Server.Events } else if (weapon.WeaponModel == "Stungun") { - Stungun_Amount = weapon.Ammount; + Stungun_Amount = weapon.Ammount; } } }