guiCheckBoxGetSelected | Multi Theft Auto: Wiki Skip to content

guiCheckBoxGetSelected

Client-side
Server-side
Shared

Pair: guiCheckBoxSetSelected

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function gets a checkbox's selection state.

OOP Syntax Help! I don't understand this!

  • Method: guicheckbox:getSelected(...)
  • Variable: .selected

Syntax

bool guiCheckBoxGetSelected ( element theCheckbox )
Required Arguments
  • theCheckbox: MISSING_PARAM_DESC

Returns

  • bool: value

Returns true if the checkbox is selected, false if it is not.

Code Examples

shared

This example makes a different beep based on the state when any checkbox has been clicked.

function checkboxBleepWhenClicked()
if ( getElementType(source) == "gui-checkbox" ) then -- Is the element clicked a checkbox?
if ( guiCheckBoxGetSelected(source) ) then
playSoundFrontEnd(1) -- If the checkbox is selected play sound 1.
else
playSoundFrontEnd(2) -- If the checkbox isn't selected play sound 2.
end
end
end
addEventHandler("onClientGUIClick", root, checkboxBleepWhenClicked, false)

See Also

GUI Functions