guiGetSize | Multi Theft Auto: Wiki Skip to content

guiGetSize

Client-side
Server-side
Shared

Pair: guiSetSize

This function gets the size of a GUI element.

OOP Syntax Help! I don't understand this!

Syntax

float|false, ​float guiGetSize ( ​gui-element theElement, [ ​bool relative = false ] )
Required arguments
  • theElement: The GUI element to get size of.
Optional arguments

Note: when using optional arguments, you might need to supply all arguments before the one you wish to use.

  • relative (default: false): A boolean representing whether the size should be relative to the element's parent width, or an absolute size in pixels.

Returns

Returns the GUI element size width and height if the function has been successful, false otherwise.

  • float|false: width
  • float: height

Code Examples

client

This example creates a random sized gui window and outputs its size to the chatbox.

local window = guiCreateWindow(0, 0, (math.random(0, 100) / 100), (math.random(0, 100) / 100), "test", true)
-- Create the window
local x, y = guiGetSize(window, false) -- Get the gui window size
outputChatBox("Window size: " .. x .. " " .. y) -- output the gui window size

See Also

GUI Functions