DarkRP.CanDropWeapon
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. |
---|
Syntax[edit]
Description | Called when a player tries to drop a weapon |
---|---|
Syntax |
GAMEMODE:CanDropWeapon(Player ply, Entity weapon)
|
Returns | CanDrop (boolean): whether the player is allowed to drop this weapon. Return nothing to use the default. |
Arguments
The player who wants to drop a weapon
The weapon that the player wants to drop
Examples[edit]
Description | People 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. |
---|---|
Code | 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
end
-- Return nothing otherwise to take the default (by default things like pocket and keys can't be dropped)
end)
|
Output | People can't drop the weapons they spawned with |