save car at position

This commit is contained in:
michael.reiswich
2021-05-13 00:33:10 +02:00
parent efc4a7e991
commit 0aa1e4d49b
3 changed files with 25 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.WeaponDeal;
using ReallifeGamemode.Database.Models;
namespace ReallifeGamemode.Server.Events
{
@@ -65,7 +66,27 @@ namespace ReallifeGamemode.Server.Events
//LastVehicle = vehicle;
//timerNoobRollerRespawn.Elapsed += async (sender, e) => {await
}
}
using (var dbContext = new DatabaseContext())
{
ServerVehicle sV = vehicle.GetServerVehicle(dbContext);
if (sV is UserVehicle)
{
Vector3 pos = vehicle.Position;
sV.PositionX = pos.X;
sV.PositionY = pos.Y;
sV.PositionZ = pos.Z;
sV.Heading = vehicle.Heading;
dbContext.SaveChanges();
}
}
}
private static void Timer600000_Elapsed(object sender, ElapsedEventArgs e)
{
//ExitVehicle c = new ExitVehicle();