guiGridListGetSelectedItem | Multi Theft Auto: Wiki Skip to content

guiGridListGetSelectedItem

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 returns the row and column indexes of the selected item in a grid list. First selected row and column is (0, 0).

Syntax

guiGridListGetSelectedItem ( )

Code Examples

client

This code creates a grid list and fills it with the names of the connected players. When the user selects an item, its text (the player name) will be output in the chat box.

addEventHandler('onClientResourceStart', resourceRoot, function()
local playerList = guiCreateGridList(0.8, 0.1, 0.15, 0.6, true)
-- Create a players column in the list
local column = guiGridListAddColumn(playerList, 'Player', 0.85)
-- If the column has been created, fill it with players
if not column then return end
for id, playeritem in ipairs(getElementsByType('player')) do
local row = guiGridListAddRow ( playerList )
guiGridListSetItemText(playerList, row, column, getPlayerName(playeritem), false, false)
end
addEventHandler('onClientGUIClick', playerList, function()
local row, column = guiGridListGetSelectedItem(playerList)
outputChatBox(guiGridListGetItemText(playerList, row, column))
end)
end

See Also

GUI Functions