Skip to content

Commit

Permalink
Move IsBeingDarkRPDropped to meta:dropDRPWeapon
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Aug 8, 2024
1 parent ce52ff7 commit 1d3dcd4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions entities/weapons/weapon_cs_base2/sv_commands.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local meta = FindMetaTable("Player")
function meta:dropDRPWeapon(weapon)
if not weapon:IsValid() or weapon:GetOwner() ~= self then return end
if not weapon:IsValid() or weapon:GetOwner() ~= self or weapon.IsBeingDarkRPDropped then return end

if GAMEMODE.Config.restrictdrop then
local found = false
Expand All @@ -14,6 +14,10 @@ function meta:dropDRPWeapon(weapon)
if not found then return end
end

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

local primAmmo = self:GetAmmoCount(weapon:GetPrimaryAmmoType())
self:DropWeapon(weapon) -- Drop it so the model isn't the viewmodel
weapon:SetOwner(self)
Expand Down Expand Up @@ -53,7 +57,7 @@ end

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

Please sign in to comment.