Skip to content

Commit

Permalink
Add a check to prevent double dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Aug 8, 2024
1 parent cc65f8c commit a411514
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion entities/weapons/weapon_cs_base2/sv_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end

local function DropWeapon(ply)
local ent = ply:GetActiveWeapon()
if not ent:IsValid() or ent:GetModel() == "" then
if not ent:IsValid() or ent:GetModel() == "" or ent.IsBeingDarkRPDropped then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("cannot_drop_weapon"))
return ""
end
Expand All @@ -64,6 +64,10 @@ local function DropWeapon(ply)
return ""
end

-- Mark the weapon as being dropped. This, along with the check above will
-- prevent the same weapon from being dropped twice.
ent.IsBeingDarkRPDropped = true

ply:DoAnimationEvent(ACT_GMOD_GESTURE_ITEM_DROP)

timer.Simple(1, function()
Expand Down

0 comments on commit a411514

Please sign in to comment.