Removing weapon crashes the server

function SWEP:Holster()
    if SERVER and self.Primary.Clips < 1 then
        self.Owner:StripWeapon( self.Weapon:GetClass() ) 
    return true

So essentially I have these disposable grenades, and once the player has used up their ammo, the game strips the weapon when they select a new weapon.

This used to work, now it hardcrashes the server with no errors.

I’d prefer to keep the weapon stripping behaviour (since it makes sense to remove disposables) so I’d like to know if anyone has a working way of doing this.

This is also kind of a bug report since I think a crash to desktop is hardly ideal for something like this.

Have you tried just doing


instead of stripping it? Might not be any difference, but it can’t hurt to try.

From memory removing weapon entities that a player is holding causes weird behaviour, I’ll give it a shot but I doubt it’ll be an ideal solution.

[editline]8th October 2015[/editline]

Looks like using saferemove has fixed it, I’m still doing some testing but yeah looks like it’s working as expected.

I don’t think that function existed back when I made these sweps so I guess that’s that.