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

Fixed error when trying to drop ammo for weapons without AmmoEnt #1671

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Fixed weapon pickup through walls (by @MrXonte)
- Fixed spectating player still being visible through thermalvision after killing that player (by @MrXonte)
- Fixed Magneto-stick not using C_Hands (by @SvveetMavis)
- Fixed console error when dropping ammo for weapons with no AmmoEnt (by @MrXonte)

### Changed

Expand Down
5 changes: 4 additions & 1 deletion gamemodes/terrortown/gamemode/server/sv_player_ext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,10 @@ end
-- @return boolean Returns if this weapon's ammo can be dropped
-- @realm server
function plymeta:CanSafeDropAmmo(wep)
if not IsValid(self) or not (IsValid(wep) and wep.AmmoEnt) then
-- We explicitly check for the two common non-existent ammo ents (`nil` and `empty string`) here
-- to prevent these from leading to a console error later once they are fed into `ents.Create`.
-- There is currently no way to check if the AmmoEnt exists, so this is the best we can do.
if not IsValid(self) or not IsValid(wep) or not wep.AmmoEnt or wep.AmmoEnt == "" then
return false
end

Expand Down