Fix player dying when switching characters in missions

This commit is contained in:
oldnapalm
2023-08-13 19:29:48 -03:00
parent 2cb5baf5f7
commit 1f8d70a520
2 changed files with 4 additions and 3 deletions

View File

@ -278,7 +278,7 @@ namespace RageCoop.Client
ProjectilesByHandle.Remove(p.Handle); ProjectilesByHandle.Remove(p.Handle);
} }
Main.Logger.Debug($"Removing projectile {sp.ID}. Reason:{reason}"); Main.Logger.Debug($"Removing projectile {sp.ID}. Reason:{reason}");
p.Explode(); if (sp.Exploded) p.Explode();
} }
ProjectilesByID.Remove(id); ProjectilesByID.Remove(id);
} }
@ -363,7 +363,8 @@ namespace RageCoop.Client
foreach (Ped p in allPeds) foreach (Ped p in allPeds)
{ {
SyncedPed c = GetPedByHandle(p.Handle); SyncedPed c = GetPedByHandle(p.Handle);
if (c == null && (p != Game.Player.Character) && !Function.Call<bool>(Hash.IS_PLAYER_SWITCH_IN_PROGRESS)) List<PedHash> mainCharacters = new List<PedHash> { PedHash.Michael, PedHash.Franklin, PedHash.Franklin02, PedHash.Trevor };
if (c == null && p != Game.Player.Character && !mainCharacters.Contains((PedHash)p.Model.Hash))
{ {
if (allPeds.Length > Main.Settings.WorldPedSoftLimit && p.PopulationType == EntityPopulationType.RandomAmbient && !p.IsInVehicle()) if (allPeds.Length > Main.Settings.WorldPedSoftLimit && p.PopulationType == EntityPopulationType.RandomAmbient && !p.IsInVehicle())
{ {

View File

@ -126,7 +126,7 @@ namespace RageCoop.Client
} }
var p = EntityPool.GetPedByID(ownerID)?.MainPed; var p = EntityPool.GetPedByID(ownerID)?.MainPed;
if (p == null) { p = Game.Player.Character; Main.Logger.Warning("Failed to find owner for bullet"); } if (p == null) { return; /* p = Game.Player.Character; Main.Logger.Warning("Failed to find owner for bullet"); */ }
if (!CorePFXAsset.IsLoaded) { CorePFXAsset.Request(); } if (!CorePFXAsset.IsLoaded) { CorePFXAsset.Request(); }
if (_lastWeaponHash != weaponHash) if (_lastWeaponHash != weaponHash)
{ {