From 1f03e1c4f0d12100cb388810ff7b5f63fd4f2626 Mon Sep 17 00:00:00 2001 From: StefanX <60297289+stefanx111@users.noreply.github.com> Date: Sat, 24 Jan 2026 04:02:16 +0200 Subject: [PATCH] fix: safe weapon kill (hope no more crash) --- WeaponAction.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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)