vehicle respawn if vehicleIsDead
This commit is contained in:
@@ -1116,10 +1116,52 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
InventoryManager.RemoveAllItemsfromVehicleInventory(vehicle);
|
||||
|
||||
serverVehicle.Spawn(vehicle);
|
||||
vehicle.Repair();
|
||||
CheckVehicleDeath(vehicle.Id);
|
||||
}
|
||||
|
||||
public static void CheckVehicleDeath(int id)
|
||||
{
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
Vehicle vehicle = NAPI.Pools.GetAllVehicles().Find(v => v.Id == id);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV is UserVehicle)
|
||||
{
|
||||
|
||||
foreach (VehicleRespawnPoint point in VehicleRespawnPoints)
|
||||
{
|
||||
if (NAPI.Pools.GetAllVehicles().Any(v => v.Position.DistanceTo(point.Position) < 1))
|
||||
{
|
||||
ChatService.Broadcast("Fahrzeug zu nah");
|
||||
}
|
||||
else
|
||||
{
|
||||
sV.PositionX = point.Position.X;
|
||||
sV.PositionY = point.Position.Y;
|
||||
sV.PositionZ = point.Position.Z;
|
||||
sV.Heading = point.Heading;
|
||||
dbContext.SaveChanges();
|
||||
break;
|
||||
}
|
||||
}
|
||||
vehicle.Delete();
|
||||
Vehicle newVeh = sV.Spawn(vehicle);
|
||||
newVeh.Repair();
|
||||
}
|
||||
|
||||
if (sV is FactionVehicle || sV is GroupVehicle)
|
||||
{
|
||||
vehicle.Delete();
|
||||
Vehicle newVeh = sV.Spawn(vehicle);
|
||||
newVeh.Repair();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("CLIENT:setMarkerBehindVehicle")]
|
||||
public void setVectorBehindVehicle(Player player, int id, string jsonX, string jsonY, string jsonZ)
|
||||
{
|
||||
@@ -1279,47 +1321,9 @@ namespace ReallifeGamemode.Server.Managers
|
||||
#endregion spawnpositions-vehicleInWater
|
||||
|
||||
[RemoteEvent("CheckWater")]
|
||||
public void CheckWater(Player player, int id)
|
||||
public static void CheckWater(Player player, int id)
|
||||
{
|
||||
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
Vehicle vehicle = NAPI.Pools.GetAllVehicles().Find(v => v.Id == id);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV is UserVehicle)
|
||||
{
|
||||
|
||||
foreach (VehicleRespawnPoint point in VehicleRespawnPoints)
|
||||
{
|
||||
if (NAPI.Pools.GetAllVehicles().Any(v => v.Position.DistanceTo(point.Position) < 1))
|
||||
{
|
||||
ChatService.Broadcast("Fahrzeug zu nah");
|
||||
}
|
||||
else
|
||||
{
|
||||
sV.PositionX = point.Position.X;
|
||||
sV.PositionY = point.Position.Y;
|
||||
sV.PositionZ = point.Position.Z;
|
||||
sV.Heading = point.Heading;
|
||||
dbContext.SaveChanges();
|
||||
break;
|
||||
}
|
||||
}
|
||||
vehicle.Delete();
|
||||
Vehicle newVeh = sV.Spawn(vehicle);
|
||||
newVeh.Repair();
|
||||
}
|
||||
|
||||
if (sV is FactionVehicle || sV is GroupVehicle)
|
||||
{
|
||||
vehicle.Delete();
|
||||
Vehicle newVeh = sV.Spawn(vehicle);
|
||||
newVeh.Repair();
|
||||
}
|
||||
}
|
||||
CheckVehicleDeath(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1328,3 +1332,6 @@ public class VehicleRespawnPoint
|
||||
public Vector3 Position { get; set; }
|
||||
public float Heading { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user