Fix vehicle projectile

This commit is contained in:
Sardelka
2022-06-17 11:33:53 +08:00
parent 45f487c9f4
commit 1ae913f0d2

View File

@ -16,28 +16,29 @@ namespace RageCoop.Client
MainProjectile = p;
Origin=p.Position;
var shooter = EntityPool.GetPedByHandle((p.Owner?.Handle).GetValueOrDefault());
if(shooter != null)
{
if (shooter.MainPed!=null && (p.AttachedEntity==shooter.MainPed.Weapons.CurrentWeaponObject || p.AttachedEntity== shooter.MainPed))
{
IsValid=false;
}
ShooterID=shooter.ID;
IsMine=shooter.IsMine;
}
else
if (shooter==null)
{
// Owner will be the vehicle if projectile is shot with a vehicle
var shooterVeh = EntityPool.GetVehicleByHandle((p.Owner?.Handle).GetValueOrDefault());
if (shooterVeh!=null && shooterVeh.MainVehicle.Driver!=null)
{
ShooterID=shooterVeh.MainVehicle.Driver.GetSyncEntity().ID;
shooter=shooterVeh.MainVehicle.Driver?.GetSyncEntity();
}
else
{
Main.Logger.Warning($"Could not find owner for projectile:{Hash}");
}
}
if(shooter != null)
{
if (shooter.MainPed!=null && (p.AttachedEntity==shooter.MainPed.Weapons.CurrentWeaponObject || p.AttachedEntity== shooter.MainPed))
{
// Reloading
IsValid=false;
}
ShooterID=shooter.ID;
IsMine=shooter.IsMine;
}
}
public SyncedProjectile(int id)