guiRadioButtonSetSelected | Multi Theft Auto: Wiki Skip to content

guiRadioButtonSetSelected

Client-side
Server-side
Shared

Pair: guiRadioButtonGetSelected

This function selects or unselects a radio button.

OOP Syntax Help! I don't understand this!

Syntax

bool guiRadioButtonSetSelected ( ​gui-radiobutton guiRadioButton, ​bool state )
Required arguments
  • guiRadioButton: The GUI radio button in which you wish to change the selection state of.
  • state: The state of the radio button, where true indicates selected, and false indicates unselected.

Returns

Returns true if the radio button's selection state was successfully set, false otherwise.

  • bool: result

Code Examples

client
local label = guiCreateLabel(0.3, 0.35, 0.1, 0.025, "What's your favorite color?", true)
local blue = guiCreateRadioButton(0.3, 0.4, 0.03, 0.015, 'Blue', true)
local green = guiCreateRadioButton(0.3, 0.45, 0.03, 0.015, 'Green', true)
local red = guiCreateRadioButton(0.3, 0.5, 0.03, 0.015, 'Red', true)
addCommandHandler('favcolor', function(cmd, color)
if (not tostring(color)) then
outputChatBox('Use /favcolor <color>')
return
end
color = color:lower()
if (color == 'blue') then
guiRadioButtonSetSelected(blue, true)
elseif (color == 'green') then
guiRadioButtonSetSelected(green, true)
elseif (color == 'red') then
guiRadioButtonSetSelected(red, true)
else
outputChatBox('Wrong color!')
end
end)

See Also

GUI Functions