Skip to content

Commit

Permalink
TTT: Fix rare cl_hudpick error (#1185)
Browse files Browse the repository at this point in the history
Sometimes, for example if the player spawns on a weapon, the game will
try to show the hudpickup panel before LocalPlayer() returns a a valid
player, causing an error.
  • Loading branch information
gspetrou authored and svdm committed May 31, 2016
1 parent adf99d3 commit f43d302
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions garrysmod/gamemodes/terrortown/gamemode/cl_hudpickup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local pickupclr = {
}

function GM:HUDWeaponPickedUp( wep )
if (not IsValid(wep)) or (not LocalPlayer():Alive()) then return end
if not (IsValid(wep) and IsValid(LocalPlayer())) or (not LocalPlayer():Alive()) then return end

local name = LANG.TryTranslation(wep.GetPrintName and wep:GetPrintName() or wep:GetClass() or "Unknown Weapon Name")

Expand Down Expand Up @@ -48,7 +48,7 @@ end

function GM:HUDItemPickedUp( itemname )

if (not LocalPlayer():Alive()) then return end
if not (IsValid(LocalPlayer()) and LocalPlayer():Alive()) then return end

local pickup = {}
pickup.time = CurTime()
Expand Down Expand Up @@ -78,7 +78,7 @@ function GM:HUDItemPickedUp( itemname )
end

function GM:HUDAmmoPickedUp( itemname, amount )
if (not LocalPlayer():Alive()) then return end
if not (IsValid(LocalPlayer()) and LocalPlayer():Alive()) then return end

local itemname_trans = LANG.TryTranslation(string.lower("ammo_" .. itemname))

Expand Down

0 comments on commit f43d302

Please sign in to comment.