Skip to content

Commit

Permalink
Fix hud hook not called when exiting vehicle. Fixes: #1500
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 committed Aug 26, 2023
1 parent 69d9466 commit a0d377f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lua/entities/starfall_processor/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ net.Receive("starfall_hud_set_enabled" , function()
end
end)

local function runHudHooks(ply, chip, activator, enabled)
local instance = chip.instance
if instance then
instance:runScriptHook(enabled and "hudconnected" or "huddisconnected", instance.WrapObject(activator), instance.WrapObject(ply))
instance:RunHook(enabled and "starfall_hud_connected" or "starfall_hud_disconnected", activator)
end
end

if SERVER then
function SF.EnableHud(ply, chip, activator, enabled, dontsync)
local huds = chip.ActiveHuds
Expand All @@ -263,7 +271,10 @@ if SERVER then
net.WriteBool(false)
net.Send(ply)
end
if sync then syncHud(ply, chip, activator, false) end
if sync then
runHudHooks(ply, chip, activator, false)
syncHud(ply, chip, activator, false)
end
end
if enabled then
huds[ply] = true
Expand All @@ -284,11 +295,7 @@ if SERVER then
if not enabled then ply:SetViewEntity() end
huds[ply] = enabled or nil
end
local instance = chip.instance
if instance then
instance:runScriptHook(enabled and "hudconnected" or "huddisconnected", instance.WrapObject(activator), instance.WrapObject(ply))
instance:RunHook(enabled and "starfall_hud_connected" or "starfall_hud_disconnected", activator)
end
runHudHooks(ply, chip, activator, enabled)
if not dontsync then syncHud(ply, chip, activator, enabled) end
end
else
Expand All @@ -310,12 +317,7 @@ else
else
LocalPlayer():ChatPrint("Starfall HUD disconnected"..enabledBy..".")
end

local instance = chip.instance
if instance then
instance:runScriptHook(enabled and "hudconnected" or "huddisconnected", instance.WrapObject(activator), instance.WrapObject(ply))
instance:RunHook(enabled and "starfall_hud_connected" or "starfall_hud_disconnected", activator)
end
runHudHooks(ply, chip, activator, enabled)
if not dontsync then syncHud(ply, chip, activator, enabled) end
end
end
Expand Down

0 comments on commit a0d377f

Please sign in to comment.