Update WeaponPaints.cs

Fixed crashing
This commit is contained in:
Dawid Bepierszcz
2023-11-16 20:38:35 +01:00
committed by GitHub
parent 5262739c3d
commit 42bd45c3f0

View File

@@ -195,6 +195,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
}
Server.NextFrame(() =>
{
try {
if (!weapon.IsValid) return;
if (weapon.OwnerEntity.Value == null) return;
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
@@ -226,6 +227,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
skeleton.ModelState.MeshGroupMask = 2;
}
});
} catch(Exception) {}
}
public void GiveKnifeToPlayer(CCSPlayerController player)
{
@@ -267,6 +269,7 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
}
public void RefreshPlayerKnife(CCSPlayerController player)
{
if (!player.IsValid || !player.PawnIsAlive) return;
if (!PlayerHasKnife(player))
GiveKnifeToPlayer(player);
}
@@ -320,11 +323,11 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
public bool PlayerHasKnife(CCSPlayerController player)
{
if (!Config.Additional.KnifeEnabled) return true;
if (!Config.Additional.KnifeEnabled) return false;
if (!player.IsValid || !player.PlayerPawn.IsValid)
if (!player.IsValid || !player.PawnIsAlive)
{
return true;
return false;
}
var weapons = player.PlayerPawn.Value.WeaponServices!.MyWeapons;