diff --git a/WeaponAction.cs b/WeaponAction.cs index 784e5ac0..78b79b3e 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -332,13 +332,27 @@ namespace WeaponPaints if (!PlayerHasKnife(player) && hasKnife) { var newKnife = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.Knife)); - newKnife.AddEntityIOEvent("Kill", newKnife, null, "", 0.01f); var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP)); player.GiveNamedItem(CsItem.Knife); player.ExecuteClientCommand("slot3"); - newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f); + + Server.NextFrame(() => + { + try + { + if (newKnife != null && newKnife.IsValid) + newKnife.AddEntityIOEvent("Kill", newKnife, null, "", 0.01f); + if (newWeapon != null && newWeapon.IsValid) + newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f); + } + catch (Exception ex) + { + Logger.LogWarning("Error AddEntityIOEvent " + ex.Message); + } + }); } + foreach (var entry in weaponsWithAmmo) { foreach (var ammo in entry.Value)