Skip to content

Commit

Permalink
Merge pull request #359 from GMLambda/weapon-respawn
Browse files Browse the repository at this point in the history
Fix player weapons respawning
  • Loading branch information
ZehMatt authored Feb 23, 2025
2 parents 241d5b4 + 706afa9 commit 2bf4402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Fixed: Level transition can carry some unwanted entities to the next map.
- Fixed: d2_coast_08: Incorrect player spawn when directly starting from this map.
- Fixed: Compatibility with addons that use GM:AddDeathNotice, this caused errors to appear.
- Fixed: Weapons from players respawning when picked up.

0.9.27
- Fixed: Entity inputs/outputs are parsed incorrect.
Expand Down
8 changes: 4 additions & 4 deletions gamemode/sv_player_pickup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function GM:PlayerCanPickupItem(ply, item)
DbgPrintPickup("PlayerCanPickupItem", ply, item)

if item.CreatedForPlayer ~= nil then
if item.CreatedForPlayer == ply then
if item.CreatedForPlayer == ply or item.CreatedForPlayer == NULL then
DbgPrintPickup("Simple pickup, created for player: " .. tostring(ply))

return true
Expand Down Expand Up @@ -252,7 +252,7 @@ function GM:PlayerCanPickupWeapon(ply, wep)
end

if wep.CreatedForPlayer ~= nil then
if wep.CreatedForPlayer == ply then
if wep.CreatedForPlayer == ply or wep.CreatedForPlayer == NULL then
DbgPrintPickup(ply, "Simple pickup, created for player")

return true
Expand Down Expand Up @@ -311,7 +311,7 @@ function GM:WeaponEquip(wep, owner)
end
end

if wep.CreatedForPlayer ~= owner and wep.DroppedByPlayer == nil then
if wep.CreatedForPlayer == nil and wep.DroppedByPlayer == nil then
if AMMO_LIKE_WEAPONS[wep:GetClass()] ~= true and self:CallGameTypeFunc("ShouldRespawnWeapon", wep) == true then
local respawnTime = self:CallGameTypeFunc("GetWeaponRespawnTime") or 0.5

Expand All @@ -321,5 +321,5 @@ function GM:WeaponEquip(wep, owner)
end
end

wep.CreatedForPlayer = nil
wep.CreatedForPlayer = NULL
end

0 comments on commit 2bf4402

Please sign in to comment.