SomeoneHasSkill - Accessed None 'Pawn' fix

This commit is contained in:
Shtoyan 2022-01-20 21:19:11 +04:00
parent 7af1e7bc4e
commit 65371a7a53

View File

@ -50,24 +50,35 @@ static function bool HasSkill(NicePlayerController nicePlayer, class<NiceSkill>
return true; return true;
return false; return false;
} }
static function bool SomeoneHasSkill(NicePlayerController player, class<NiceSkill> skill){
static function bool SomeoneHasSkill(NicePlayerController player, class<NiceSkill> skill)
{
local int i; local int i;
local Controller P; local Controller P;
local NicePlayerController nicePlayer; local NicePlayerController nicePlayer;
if (player == none) if (player == none)
return false; return false;
if(player.Pawn.Role == ROLE_Authority) // added pawn check coz of log spam
for(P = player.Level.ControllerList; P != none; P = P.nextController){ if (player.Pawn != none && player.Pawn.Role == ROLE_Authority)
{
for(P = player.Level.ControllerList; P != none; P = P.nextController)
{
nicePlayer = NicePlayerController(P); nicePlayer = NicePlayerController(P);
if (nicePlayer != none && HasSkill(nicePlayer, skill) && nicePlayer.Pawn.Health > 0 && !nicePlayer.Pawn.bPendingDelete if (nicePlayer != none && HasSkill(nicePlayer, skill) && nicePlayer.Pawn.Health > 0 && !nicePlayer.Pawn.bPendingDelete
&& nicePlayer.PlayerReplicationInfo.Team == player.PlayerReplicationInfo.Team) && nicePlayer.PlayerReplicationInfo.Team == player.PlayerReplicationInfo.Team)
return true; return true;
} }
else for(i = 0;i < player.broadcastedSkills.Length;i ++) }
else
{
for (i = 0;i < player.broadcastedSkills.Length;i ++)
if (player.broadcastedSkills[i] == skill) if (player.broadcastedSkills[i] == skill)
return true; return true;
}
return false; return false;
} }
// Checks if player will automatically chose given skill at the next opportunity // Checks if player will automatically chose given skill at the next opportunity
static function bool IsSkillPending(NicePlayerController nicePlayer, class<NiceSkill> skill){ static function bool IsSkillPending(NicePlayerController nicePlayer, class<NiceSkill> skill){
local int i; local int i;