CrossLab exposes a few exports so you can interact with it from other resources — useful if you want to open the menu through a different UI, sync crosshair settings with something else, or build on top of the system.
These are called from client scripts in another resource.
-- Open / close the crosshair menu
exports['s4-crosslab']:openMenu()
exports['s4-crosslab']:closeMenu()
-- Check if the menu is currently open
local open = exports['s4-crosslab']:isMenuOpen() -- returns boolean
-- Get the current crosshair settings table
local settings = exports['s4-crosslab']:getCrosshairSettings()
The settings table returned by getCrosshairSettings is the same structure as Config.DefaultCrosshair:
{
crosshairEnabled = true,
crosshairStyle = 4,
size = 3,
thickness = 1,
gap = -3,
fixedGap = -25,
csColor = 1,
colorR = 46,
colorG = 250,
colorB = 46,
alpha = 200,
useAlpha = true,
dotEnabled = false,
tStyleEnabled = false,
outlineEnabled = false,
outlineThickness = 1,
}
These are called from server scripts in another resource.
-- Get the saved crosshair settings for a player (returns nil if not loaded yet)
local settings = exports['s4-crosslab']:getCrosshairSettings(source)
-- Overwrite a player's crosshair and sync it to their client immediately
local ok = exports['s4-crosslab']:setCrosshairSettings(source, {
crosshairEnabled = true,
crosshairStyle = 2,
size = 4,
-- etc.
})
setCrosshairSettings saves the data to the player's file and triggers a client sync right away. It returns true on success, false if you passed a nil data table.
Notes#
- Settings are cached in memory on the server as soon as a player loads.
getCrosshairSettingsreads from that cache, not the file, so it's fast. - If you call
setCrosshairSettingsbefore the player has fully loaded, the data will still be saved to file and applied next time they triggers4-crosslab:playerLoaded.