vlt fix kfz id bug??

This commit is contained in:
hydrant
2021-04-22 01:15:38 +02:00
parent 57e7455abf
commit 3546ba7f99
6 changed files with 42 additions and 27 deletions

View File

@@ -15,19 +15,32 @@ namespace ReallifeGamemode.Server.Extensions
public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh);
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null)
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh)
{
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
if (currentVeh == null)
{
currentVeh = VehicleManager.GetVehicleFromServerVehicle(veh);
}
if(currentVeh != null)
{
VehicleManager.DeleteVehicle(currentVeh);
}
Vector3 position = veh.Position;
uint model = (uint)veh.Model;
float heading = veh.Heading;
int c1 = veh.PrimaryColor;
int c2 = veh.SecondaryColor;
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false);
veh.Livery = veh.Livery;
VehicleStreaming.SetEngineState(newVeh, false);
VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
VehicleManager.AddVehicle(veh, newVeh);
newVeh.Rotation = new Vector3(0, 0, heading);
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);
@@ -71,6 +84,7 @@ namespace ReallifeGamemode.Server.Extensions
{
numberplate = "NV" + numberplate;
}
NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate);
veh.NumberPlate = numberplate;