From DarkRP
Jump to navigation Jump to search
This page refers to DarkRP 2.4.3. This information may be incorrect as of later versions.
Check here for a up-to-date list of hooks.


DescriptionCalled when a player tries to drop a weapon
GAMEMODE:CanDropWeapon(Player ply, Entity weapon)
ReturnsCanDrop (boolean): whether the player is allowed to drop this weapon. Return nothing to use the default.


  • ply (Player)
  • The player who wants to drop a weapon

  • weapon (Entity)
  • The weapon that the player wants to drop


    DescriptionPeople can drop weapons they bought, but they cannot drop weapons they spawned with. e.g. If a gundealer buys a glock he can drop it, but a cop who spawned with it can't.
    hook.Add("CanDropWeapon", "example", function(ply, weapon)
            if not IsValid(weapon) then return end
    	local class = weapon:GetClass()
    	class = string.lower(class)
    	-- The player spawns with this weapon
    	if RPExtraTeams[ply:Team()] and table.HasValue(RPExtraTeams[ply:Team()].weapons, class) then
    		return false
    	-- Return nothing otherwise to take the default (by default things like pocket and keys can't be dropped)
    OutputPeople can't drop the weapons they spawned with