vehicle respawn if vehicleIsDead
This commit is contained in:
@@ -1116,10 +1116,52 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
}
|
}
|
||||||
InventoryManager.RemoveAllItemsfromVehicleInventory(vehicle);
|
InventoryManager.RemoveAllItemsfromVehicleInventory(vehicle);
|
||||||
|
|
||||||
serverVehicle.Spawn(vehicle);
|
CheckVehicleDeath(vehicle.Id);
|
||||||
vehicle.Repair();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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")]
|
[RemoteEvent("CLIENT:setMarkerBehindVehicle")]
|
||||||
public void setVectorBehindVehicle(Player player, int id, string jsonX, string jsonY, string jsonZ)
|
public void setVectorBehindVehicle(Player player, int id, string jsonX, string jsonY, string jsonZ)
|
||||||
{
|
{
|
||||||
@@ -1231,95 +1273,57 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
Position = new Vector3(-343.31, -974.59, 31.08),
|
Position = new Vector3(-343.31, -974.59, 31.08),
|
||||||
Heading = -20.22f
|
Heading = -20.22f
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
||||||
{
|
{
|
||||||
|
|
||||||
new Vector3(-343.31, -974.59, 31.08), //Heading -20.22
|
new Vector3(-343.31, -974.59, 31.08), //Heading -20.22
|
||||||
new Vector3(-339.67, -975.69, 31.08), //Heading -16.76
|
new Vector3(-339.67, -975.69, 31.08), //Heading -16.76
|
||||||
new Vector3(-336.38, -976.95, 31.08), //Heading -19.30
|
new Vector3(-336.38, -976.95, 31.08), //Heading -19.30
|
||||||
new Vector3(-332.50, -978.28, 31.08), //Heading -18.82
|
new Vector3(-332.50, -978.28, 31.08), //Heading -18.82
|
||||||
new Vector3(-329.48, -979.39, 31.08), //Heading -26.22
|
new Vector3(-329.48, -979.39, 31.08), //Heading -26.22
|
||||||
new Vector3(-325.96, -980.70, 31.08), //Heading -19.74
|
new Vector3(-325.96, -980.70, 31.08), //Heading -19.74
|
||||||
new Vector3(-360.85, -900.53, 31.07), //Heading -88.64
|
new Vector3(-360.85, -900.53, 31.07), //Heading -88.64
|
||||||
new Vector3(-360.71, -904.02, 31.07), //Heading -88.04
|
new Vector3(-360.71, -904.02, 31.07), //Heading -88.04
|
||||||
new Vector3(-360.56, -907.78, 31.07), //Heading -88.41
|
new Vector3(-360.56, -907.78, 31.07), //Heading -88.41
|
||||||
new Vector3(-360.41, -911.79, 31.08), //Heading -86.13
|
new Vector3(-360.41, -911.79, 31.08), //Heading -86.13
|
||||||
new Vector3(-360.30, -915.26, 31.08), //Heading -134.60
|
new Vector3(-360.30, -915.26, 31.08), //Heading -134.60
|
||||||
new Vector3(-360.12, -919.21, 31.08), //Heading -82.35
|
new Vector3(-360.12, -919.21, 31.08), //Heading -82.35
|
||||||
new Vector3(-360.03, -922.63, 31.08), //Heading -89.27
|
new Vector3(-360.03, -922.63, 31.08), //Heading -89.27
|
||||||
new Vector3(-359.78, -926.58, 31.08), //Heading -84.04
|
new Vector3(-359.78, -926.58, 31.08), //Heading -84.04
|
||||||
new Vector3(-359.73, -929.89, 31.08), //Heading -88.67
|
new Vector3(-359.73, -929.89, 31.08), //Heading -88.67
|
||||||
new Vector3(-359.66, -933.50, 31.08), //Heading -88.67
|
new Vector3(-359.66, -933.50, 31.08), //Heading -88.67
|
||||||
new Vector3(-359.54, -937.61, 31.08), //Heading -86.68
|
new Vector3(-359.54, -937.61, 31.08), //Heading -86.68
|
||||||
new Vector3(-359.48, -941.17, 31.08), //Heading -90.07
|
new Vector3(-359.48, -941.17, 31.08), //Heading -90.07
|
||||||
new Vector3(-336.84, -952.54, 31.08), //Heading 68.74
|
new Vector3(-336.84, -952.54, 31.08), //Heading 68.74
|
||||||
new Vector3(-355.55, -949.08, 31.08), //Heading 71.85
|
new Vector3(-355.55, -949.08, 31.08), //Heading 71.85
|
||||||
new Vector3(-334.47, -945.95, 31.08), //Heading 70.89
|
new Vector3(-334.47, -945.95, 31.08), //Heading 70.89
|
||||||
new Vector3(-333.11, -942.11, 31.08), //Heading 70.18
|
new Vector3(-333.11, -942.11, 31.08), //Heading 70.18
|
||||||
new Vector3(-331.90, -938.98, 31.08), //Heading 68.07
|
new Vector3(-331.90, -938.98, 31.08), //Heading 68.07
|
||||||
new Vector3(-330.65, -935.58, 31.08), //Heading 70.98
|
new Vector3(-330.65, -935.58, 31.08), //Heading 70.98
|
||||||
new Vector3(-329.24, -931.58, 31.08), //Heading 73.91
|
new Vector3(-329.24, -931.58, 31.08), //Heading 73.91
|
||||||
new Vector3(-328.12, -928.44, 31.08), //Heading 69.17
|
new Vector3(-328.12, -928.44, 31.08), //Heading 69.17
|
||||||
new Vector3(-326.67, -924.60, 31.08), //Heading 46.89
|
new Vector3(-326.67, -924.60, 31.08), //Heading 46.89
|
||||||
new Vector3(-322.36, -982.02, 31.08), //Heading -21.25059
|
new Vector3(-322.36, -982.02, 31.08), //Heading -21.25059
|
||||||
new Vector3(-318.92, -983.19, 31.08), //Heading -20.580233
|
new Vector3(-318.92, -983.19, 31.08), //Heading -20.580233
|
||||||
new Vector3(-315.42, -984.40, 31.08), //Heading -21.508415
|
new Vector3(-315.42, -984.40, 31.08), //Heading -21.508415
|
||||||
new Vector3(-311.97, 985.60, 31.080), //Heading -20.866705
|
new Vector3(-311.97, 985.60, 31.080), //Heading -20.866705
|
||||||
new Vector3(-308.43, -986.83, 31.08), //Heading -21.050055
|
new Vector3(-308.43, -986.83, 31.08), //Heading -21.050055
|
||||||
new Vector3(-305.03, -988.07, 31.08), //Heading -21.021408
|
new Vector3(-305.03, -988.07, 31.08), //Heading -21.021408
|
||||||
new Vector3(-301.48, -989.31, 31.08), //Heading -22.333475
|
new Vector3(-301.48, -989.31, 31.08), //Heading -22.333475
|
||||||
new Vector3(-298.04, -990.48, 31.08), //Heading -26.02332
|
new Vector3(-298.04, -990.48, 31.08), //Heading -26.02332
|
||||||
new Vector3(-342.30, -921.35, 31.0), //Heading-109.20534
|
new Vector3(-342.30, -921.35, 31.0), //Heading-109.20534
|
||||||
new Vector3(-343.37, -925.01, 31.08), //Heading -111.86385
|
new Vector3(-343.37, -925.01, 31.08), //Heading -111.86385
|
||||||
new Vector3(-344.68, -928.18, 31.08), //Heading -109.97883
|
new Vector3(-344.68, -928.18, 31.08), //Heading -109.97883
|
||||||
new Vector3(-345.78, -931.86, 31.08), //Heading -110.89556
|
new Vector3(-345.78, -931.86, 31.08), //Heading -110.89556
|
||||||
}.AsReadOnly();
|
}.AsReadOnly();
|
||||||
*/
|
*/
|
||||||
#endregion spawnpositions-vehicleInWater
|
#endregion spawnpositions-vehicleInWater
|
||||||
|
|
||||||
[RemoteEvent("CheckWater")]
|
[RemoteEvent("CheckWater")]
|
||||||
public void CheckWater(Player player, int id)
|
public static void CheckWater(Player player, int id)
|
||||||
{
|
{
|
||||||
|
CheckVehicleDeath(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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1328,3 +1332,6 @@ public class VehicleRespawnPoint
|
|||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
public float Heading { get; set; }
|
public float Heading { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user