From 041c6beda007a5cfe164bfa20b28d1a768b03555 Mon Sep 17 00:00:00 2001 From: Name Date: Thu, 11 Jan 2024 17:16:00 +0100 Subject: [PATCH] Expose SF.IsHUDActive on the serverside as Player.isHUDActive (#1595) --- lua/starfall/libs_cl/render.lua | 4 ++-- lua/starfall/libs_sh/players.lua | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/starfall/libs_cl/render.lua b/lua/starfall/libs_cl/render.lua index 213ef6159..9d9819773 100644 --- a/lua/starfall/libs_cl/render.lua +++ b/lua/starfall/libs_cl/render.lua @@ -2056,8 +2056,8 @@ function render_library.traceSurfaceColor(vec1, vec2) return cwrap(render.GetSurfaceColor(vunwrap(vec1), vunwrap(vec2)):ToColor()) end ---- Checks if a hud component is connected to the Starfall Chip --- @return boolean Whether a hud component is connected to the SF Chip and active +--- Checks if the client is connected to a HUD component that's linked to this chip +-- @return boolean True if a HUD component is connected and active, nil otherwise function render_library.isHUDActive() return SF.IsHUDActive(instance.entity) end diff --git a/lua/starfall/libs_sh/players.lua b/lua/starfall/libs_sh/players.lua index 8db0c6e71..61781f0c3 100644 --- a/lua/starfall/libs_sh/players.lua +++ b/lua/starfall/libs_sh/players.lua @@ -510,6 +510,13 @@ if SERVER then ply:SetModelScale(math.Clamp(math.Truncate(scale, 2), 0.01, playerMaxScale:GetFloat())) end + --- Checks if the player is connected to a HUD component that's linked to this chip + -- @server + -- @return boolean True if a HUD component is connected and active for the player, nil otherwise + function player_methods:isHUDActive() + return SF.IsHUDActive(instance.entity, getply(self)) + end + --- Sets the view entity of the player. Only works if they are linked to a hud. -- @server -- @param Entity ent Entity to set the player's view entity to, or nothing to reset it