guiGridListGetItemText | Multi Theft Auto: Wiki Skip to content

guiGridListGetItemText

Client-side
Server-side
Shared

Pair: guiGridListSetItemText

This function retrieves the text from a specific grid list item.

OOP Syntax Help! I don't understand this!

Syntax

string|false guiGridListGetItemText ( ​gui-gridlist gridList, ​int rowIndex, ​int columnIndex )
Required arguments
  • gridList: The gridlist containing the item you're interested in.
  • rowIndex: Row ID of the item. Indexes start at 0.
  • columnIndex: Column ID of the item. Indexes start at 1.

Returns

Returns the text of the item if the arguments are right, false otherwise.

  • string|false: item text

Code Examples

client

This example creates a player list on resource start, clicking on it will output the selected player name to the chatbox.

local playerList
function createPlayerList()
-- Create the grid list
playerList = guiCreateGridList(0.80, 0.10, 0.15, 0.60, true)
-- Create a players column in the list
local column = guiGridListAddColumn(playerList, "Player", 0.85)
if (column) then -- If the column has been created, fill it with players
for id, playeritem in ipairs(getElementsByType("player")) do
local row = guiGridListAddRow(playerList)
guiGridListSetItemText(playerList, row, column, getPlayerName(playeritem), false, false)
end
addEventHandler("onClientGUIClick", playerList, click)
end
end
addEventHandler("onClientResourceStart", getRootElement(), createPlayerList)
function click()
local playerName = guiGridListGetItemText(playerList, guiGridListGetSelectedItem(playerList), 1)
outputChatBox(playerName)
end

See Also

GUI Functions