guiCreateButton | Multi Theft Auto: Wiki Skip to content

guiCreateButton

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

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


This function allows creation of a GUI Button, which is a clickable item as part of GUI.

Syntax

guiCreateButton ( )

Code Examples

client

This example creates an edit box alongside an "Output!" button. When the button is clicked, it will output the message in the edit box into the Chat Box.

--create our button
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
--Create an edit box and define it as "editBox".
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
-- and attach our button to the outputEditBox function
addEventHandler ( "onClientGUIClick", editBox, outputEditBox )
guiEditSetMaxLength ( editBox, 128 ) --the max chatbox length is 128, so force this
--setup our function to output the message to the chatbox
function outputEditBox ()
local text = guiGetText ( editBox )--get the text from the edit box
outputChatBox ( text ) --output that text
end
addEventHandler ( "onClientGUIClick", button, outputEditBox )

See Also

GUI Functions