- Documentation
- Client functions
- guiCreateButton
Function
guiCreateButton
Creates a button. A click fires onClientGUIClick.
Syntax
gui-button guiCreateButton(float x, float y, float width, float height, string text, bool relative [, element parent = nil])Arguments
xfloat- X position.
yfloat- Y position.
widthfloat- Width.
heightfloat- Height.
textstring- Text.
relativebool- Relative values (0-1) instead of pixels.Optional in MTA:SA: bool relative = false
parentelement, optional = nil- Parent, e.g. a window.
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
guiCreateButton(float x, float y, float width, float height, string text, bool relative = false, gui-element parent = nil)Returns
The button.
Example
local btn = guiCreateButton(20, 20, 140, 36, "Napraw auto", false)
addEventHandler("onClientGUIClick", btn, function(button)
if button == "left" then
triggerServerEvent("fixMyCar", localPlayer)
end
end, false)
Notes
Pass false. When handling one button, pass false as the fourth argument of addEventHandler so you do not catch clicks on children.