Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validity checks to dropDRPWeapon #3265

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions entities/weapons/weapon_cs_base2/sv_commands.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local meta = FindMetaTable("Player")
function meta:dropDRPWeapon(weapon)
if not weapon:IsValid() or weapon:GetOwner() ~= self or weapon.IsBeingDarkRPDropped then return end

if GAMEMODE.Config.restrictdrop then
local found = false
for k,v in pairs(CustomShipments) do
Expand All @@ -12,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