3 bug fixes

This commit is contained in:
EntenKoeniq
2021-12-13 20:25:31 +01:00
parent 9e1d0c30b4
commit b55ba2ac33
2 changed files with 34 additions and 106 deletions

View File

@ -696,44 +696,16 @@ namespace CoopClient
{ {
messageType = NetDeliveryMethod.UnreliableSequenced; messageType = NetDeliveryMethod.UnreliableSequenced;
Vehicle vehicleIsTryingToEnter = null; if (player.IsInVehicle())
if (player.IsInVehicle() || (vehicleIsTryingToEnter = player.VehicleTryingToEnter) != null)
{ {
Vehicle veh = player.CurrentVehicle ?? vehicleIsTryingToEnter; Vehicle veh = player.CurrentVehicle;
LVector3 vehPosition = new LVector3();
LQuaternion vehRotation = new LQuaternion();
float vehEngineHealth = 0f;
float vehRPM = 0f;
LVector3 vehVelocity = new LVector3();
float vehSpeed = 0f;
float vehSteeringAngle = 0f;
Dictionary<int, int> vehMods = null;
VehicleDoors[] vehDoors = null;
int vehTires = 0;
int primaryColor = 0; int primaryColor = 0;
int secondaryColor = 0; int secondaryColor = 0;
if (veh.GetResponsiblePedHandle() == player.Handle) unsafe
{ {
vehPosition = veh.Position.ToLVector(); Function.Call<int>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
vehRotation = veh.Quaternion.ToLQuaternion();
vehEngineHealth = veh.EngineHealth;
vehRPM = veh.CurrentRPM;
vehVelocity = veh.Velocity.ToLVector();
vehSpeed = veh.Speed;
vehSteeringAngle = veh.SteeringAngle;
vehMods = veh.Mods.GetVehicleMods();
vehDoors = veh.Doors.GetVehicleDoors();
vehTires = veh.Wheels.GetBrokenTires();
unsafe
{
Function.Call<int>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
}
} }
new FullSyncPlayerVehPacket() new FullSyncPlayerVehPacket()
@ -748,18 +720,18 @@ namespace CoopClient
Props = player.GetPedProps(), Props = player.GetPedProps(),
VehModelHash = veh.Model.Hash, VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)player.SeatIndex, VehSeatIndex = (int)player.SeatIndex,
VehPosition = vehPosition, VehPosition = veh.Position.ToLVector(),
VehRotation = vehRotation, VehRotation = veh.Quaternion.ToLQuaternion(),
VehEngineHealth = vehEngineHealth, VehEngineHealth = veh.EngineHealth,
VehRPM = vehRPM, VehRPM = veh.CurrentRPM,
VehVelocity = vehVelocity, VehVelocity = veh.Velocity.ToLVector(),
VehSpeed = vehSpeed, VehSpeed = veh.Speed,
VehSteeringAngle = vehSteeringAngle, VehSteeringAngle = veh.SteeringAngle,
VehAimCoords = veh.IsTurretSeat((int)player.SeatIndex) ? Util.GetVehicleAimCoords().ToLVector() : new LVector3(), VehAimCoords = veh.IsTurretSeat((int)player.SeatIndex) ? Util.GetVehicleAimCoords().ToLVector() : new LVector3(),
VehColors = new int[] { primaryColor, secondaryColor }, VehColors = new int[] { primaryColor, secondaryColor },
VehMods = vehMods, VehMods = veh.Mods.GetVehicleMods(),
VehDoors = vehDoors, VehDoors = veh.Doors.GetVehicleDoors(),
VehTires = vehTires, VehTires = veh.Wheels.GetBrokenTires(),
Flag = veh.GetVehicleFlags(true) Flag = veh.GetVehicleFlags(true)
}.PacketToNetOutGoingMessage(outgoingMessage); }.PacketToNetOutGoingMessage(outgoingMessage);
} }
@ -794,21 +766,6 @@ namespace CoopClient
{ {
Vehicle veh = player.CurrentVehicle; Vehicle veh = player.CurrentVehicle;
LVector3 vehPosition = new LVector3();
LQuaternion vehRotation = new LQuaternion();
LVector3 vehVelocity = new LVector3();
float vehSpeed = 0f;
float vehSteeringAngle = 0f;
if (veh.GetResponsiblePedHandle() == player.Handle)
{
vehPosition = veh.Position.ToLVector();
vehRotation = veh.Quaternion.ToLQuaternion();
vehVelocity = veh.Velocity.ToLVector();
vehSpeed = veh.Speed;
vehSteeringAngle = veh.SteeringAngle;
}
new LightSyncPlayerVehPacket() new LightSyncPlayerVehPacket()
{ {
Extra = new PlayerPacket() Extra = new PlayerPacket()
@ -819,11 +776,11 @@ namespace CoopClient
}, },
VehModelHash = veh.Model.Hash, VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)player.SeatIndex, VehSeatIndex = (int)player.SeatIndex,
VehPosition = vehPosition, VehPosition = veh.Position.ToLVector(),
VehRotation = vehRotation, VehRotation = veh.Quaternion.ToLQuaternion(),
VehVelocity = vehVelocity, VehVelocity = veh.Velocity.ToLVector(),
VehSpeed = vehSpeed, VehSpeed = veh.Speed,
VehSteeringAngle = vehSteeringAngle, VehSteeringAngle = veh.SteeringAngle,
Flag = veh.GetVehicleFlags(false) Flag = veh.GetVehicleFlags(false)
}.PacketToNetOutGoingMessage(outgoingMessage); }.PacketToNetOutGoingMessage(outgoingMessage);
} }
@ -862,45 +819,16 @@ namespace CoopClient
{ {
NetOutgoingMessage outgoingMessage = Client.CreateMessage(); NetOutgoingMessage outgoingMessage = Client.CreateMessage();
Vehicle vehicleTryingToEnter = null; if (npc.IsInVehicle())
if (npc.IsInVehicle() || (vehicleTryingToEnter = npc.VehicleTryingToEnter) != null)
{ {
Vehicle veh = npc.CurrentVehicle ?? vehicleTryingToEnter; Vehicle veh = npc.CurrentVehicle;
LVector3 vehPosition = new LVector3();
LQuaternion vehRotation = new LQuaternion();
float vehEngineHealth = 0f;
float vehRPM = 0f;
LVector3 vehVelocity = new LVector3();
float vehSpeed = 0f;
float vehSteeringAngle = 0f;
Dictionary<int, int> vehMods = null;
VehicleDoors[] vehDoors = null;
int vehTires = 0;
int primaryColor = 0; int primaryColor = 0;
int secondaryColor = 0; int secondaryColor = 0;
if (veh.GetResponsiblePedHandle() == npc.Handle) unsafe
{ {
vehPosition = veh.Position.ToLVector(); Function.Call<int>(Hash.GET_VEHICLE_COLOURS, npc.CurrentVehicle, &primaryColor, &secondaryColor);
vehRotation = veh.Quaternion.ToLQuaternion();
vehEngineHealth = veh.EngineHealth;
vehRPM = veh.CurrentRPM;
vehVelocity = veh.Velocity.ToLVector();
vehSpeed = veh.Speed;
vehSteeringAngle = veh.SteeringAngle;
vehMods = veh.Mods.GetVehicleMods();
vehDoors = veh.Doors.GetVehicleDoors();
vehTires = veh.Wheels.GetBrokenTires();
unsafe
{
Function.Call<int>(Hash.GET_VEHICLE_COLOURS, npc.CurrentVehicle, &primaryColor, &secondaryColor);
}
} }
new FullSyncNpcVehPacket() new FullSyncNpcVehPacket()
@ -912,17 +840,17 @@ namespace CoopClient
Position = npc.Position.ToLVector(), Position = npc.Position.ToLVector(),
VehModelHash = veh.Model.Hash, VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)npc.SeatIndex, VehSeatIndex = (int)npc.SeatIndex,
VehPosition = vehPosition, VehPosition = veh.Position.ToLVector(),
VehRotation = vehRotation, VehRotation = veh.Quaternion.ToLQuaternion(),
VehEngineHealth = vehEngineHealth, VehEngineHealth = veh.EngineHealth,
VehRPM = vehRPM, VehRPM = veh.CurrentRPM,
VehVelocity = vehVelocity, VehVelocity = veh.Velocity.ToLVector(),
VehSpeed = vehSpeed, VehSpeed = veh.Speed,
VehSteeringAngle = vehSteeringAngle, VehSteeringAngle = veh.SteeringAngle,
VehColors = new int[] { primaryColor, secondaryColor }, VehColors = new int[] { primaryColor, secondaryColor },
VehMods = vehMods, VehMods = veh.Mods.GetVehicleMods(),
VehDoors = vehDoors, VehDoors = veh.Doors.GetVehicleDoors(),
VehTires = vehTires, VehTires = veh.Wheels.GetBrokenTires(),
Flag = veh.GetVehicleFlags(true) Flag = veh.GetVehicleFlags(true)
}.PacketToNetOutGoingMessage(outgoingMessage); }.PacketToNetOutGoingMessage(outgoingMessage);
} }

View File

@ -96,7 +96,7 @@ namespace CoopClient
Function.Call((Hash)0xF796359A959DF65D, false); //Display distant vehicles Function.Call((Hash)0xF796359A959DF65D, false); //Display distant vehicles
Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true); Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true);
foreach (Ped ped in World.GetAllPeds().Where(p => p.RelationshipGroup != "SYNCPED" && !p.IsPlayer)) foreach (Ped ped in World.GetAllPeds().Where(p => p.RelationshipGroup != "SYNCPED" && p.Handle != Game.Player.Character?.Handle))
{ {
ped.CurrentVehicle?.Delete(); ped.CurrentVehicle?.Delete();
ped.Kill(); ped.Kill();