fahrzeug respawn /respaenvehicle (optional id sonst nächstes fahrzeug)

This commit is contained in:
hydrant
2020-08-02 18:03:31 +02:00
parent df083e0a18
commit 9860d39992
2 changed files with 58 additions and 15 deletions

View File

@@ -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

View File

@@ -179,14 +179,14 @@ namespace ReallifeGamemode.Server.Events
ticket_amount = player.GetData<int>("ticket_amount");
}
if(player.HasData("pay_amount"))
if (player.HasData("pay_amount"))
{
pay_amount = player.GetData<int>("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<FactionWeapon> 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;
}
}
}