guiGetPosition | Multi Theft Auto: Wiki Skip to content

guiGetPosition

Client-side
Server-side
Shared

Pair: guiSetPosition

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 retrieval of a GUI element's current position, relative to its parent.

Syntax

guiGetPosition ( )

Code Examples

client

This example checks which corner a gui element exists in

function positionCheck ( guiElement )
local x,y = guiGetPosition ( guiElement, true ) --get the position
local position --define the position
if ( x == 0.5 ) and ( y == 0.5 ) then --if its bang in the middle
position = "middle" --set position to middle
elseif ( x > 0.5 ) and ( y > 0.5 ) then --if its in the right bottom
position = "right-bottom"
elseif ( x < 0.5 ) and ( y < 0.5 ) then --if its in the left top
position = "left-top"
elseif ( x < 0.5 ) and ( y > 0.5 ) then --if its in the left bottom
position = "left-bottom"
elseif ( x > 0.5 ) and ( y < 0.5 ) then --if its in the right top
position = "right-top"
else --if it couldnt be retrieved
position = "unknown"
end
--announce this into the chatbox
outputChatBox ( "The gui element's position is "..position.."!" )
end

See Also

GUI Functions