mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-17 10:31:00 +00:00
Merge pull request #475 from stefanx111/fix-weapon-kill
fix: safe weapon kill (hope no more crash)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user