UI

User interface elements (DIVs, images, etc.).

Availability: Client-only

Methods


UI.addDIV

client

Add a DIV element to the UI. Returns the element ID.

Signature: str action(str, str, str, str)

Parameters:

NameTypeDescription
elementIdstrThe elementId parameter
visstrThe vis parameter
stylstrThe styl parameter
parentIdstrThe parentId parameter

Returns: str

str result = GAME.UI.addDIV("value", "value", "value", "value");

UI.addImage

client

Add an image element to the UI using an asset ID

Signature: str action(str, str, bool, str, str)

Parameters:

NameTypeDescription
assetIdstrThe asset ID for the image
elementIdstrUnique ID for the element
visboolWhether the element is visible
stylstrCSS style string
parentIdstrParent element ID (default: 'game')

Returns: str - The element ID if created successfully

str result = GAME.UI.addImage("value", "value", true, "value", "value");

UI.getDIVText

client

Get the text content of an element

Signature: str action(str)

Parameters:

NameTypeDescription
idstrElement ID

Returns: str - The text content

str dIVText = GAME.UI.getDIVText(0);

UI.getProp

client

Get a CSS property value from an element

Signature: str action(str, str)

Parameters:

NameTypeDescription
idstrElement ID
propstrCSS property name

Returns: str - The property value

str prop = GAME.UI.getProp(0, "color");

UI.getSize

client

Get the current window/viewport size

Signature: obj action()

Returns: obj - Object with width and height properties

obj size = GAME.UI.getSize();

UI.hideCrosshair

client

Hide the default game crosshair

Signature: action()

GAME.UI.hideCrosshair();

UI.hideDefault

client

Hide all default game UI elements (health, ammo, etc.)

Signature: action()

GAME.UI.hideDefault();

UI.moveDIV

client

Move a DIV element to a different parent, optionally renaming it

Signature: str action(str, str, str)

Parameters:

NameTypeDescription
oldIdstrCurrent element ID
parentIdstrNew parent element ID
newIdstrOptional new ID for the element

Returns: str - The element ID after moving

str result = GAME.UI.moveDIV("value", "value", "value");

UI.removeDIV

client

Remove a DIV element from the UI

Signature: action(str)

Parameters:

NameTypeDescription
idstrElement ID to remove
GAME.UI.removeDIV(0);

UI.updateDIV

client

Update a CSS property on an element

Signature: action(str, str, str)

Parameters:

NameTypeDescription
idstrElement ID
propstrCSS property name
valstrNew property value
GAME.UI.updateDIV(0, "color", 100);

UI.updateDIVText

client

Update the text content of an element

Signature: action(str, str)

Parameters:

NameTypeDescription
idstrElement ID
textstrNew text content
GAME.UI.updateDIVText(0, "Hello");