Dropping Weapons On Death

I found SWEP:ShouldDropOnDie() but how do i use it … (Yes i’m a lua noob :stuck_out_tongue: ) Do i put it into the weapon code? or serverside code?

Goal:

  1. On death, user will drop his weapon for anyone to pick up ( Just like PERP, You die, you drop your weapon )
  2. Select which weapon to drop… Don’t Want cops dropping the weapons they spawn with.

Btw, i’m making a modified DarkRP, which will hopefully turn into a mix of DarkRP/Perp… Either way… Help?

Thanks,
Crusher

you put it into the weapon code

As far as I know, SWEP:ShouldDropOnDie does nothing on it’s own.

You can put the code in a PlayerDeath hook on the server. This way, you can detect whether or not you want a specific weapon to drop when the player dies.



function GM:PlayerDeath(ply, inflictor, attacker)
    for k, v in pairs(ply:GetWeapons()) do
        if v:GetClass() == "weapon_crowbar" then return
    else ply:DropWeapon(v)
    end
end


The above code takes a table of all of the dead player’s weapons and checks to see if it’s a crowbar. If it is a crowbar, it does not drop it, but everything else will be dropped. I didn’t test it, but it should work (and if it doesn’t, well, you get the idea.)