DgsMenuGetItemText

From Multi Theft Auto: Wiki
Revision as of 04:49, 10 July 2025 by Mohab (talk | contribs) (Created page with "{{Client function}} __NOTOC__ This function retrieves the displayed text of a menu item. ==Syntax== <syntaxhighlight lang="lua"> string dgsMenuGetItemText ( element menu, int uniqueID ) </syntaxhighlight> ===Required Arguments=== *'''menu:''' The DGS menu element containing the item *'''uniqueID:''' The unique ID of the menu item (returned by dgsMenuAddItem) ===Returns=== Returns the text string if successful, ''false'' if the item doesn't exist. ==Examples== <sy...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function retrieves the displayed text of a menu item.

Syntax

string dgsMenuGetItemText ( element menu, int uniqueID )

Required Arguments

  • menu: The DGS menu element containing the item
  • uniqueID: The unique ID of the menu item (returned by dgsMenuAddItem)

Returns

Returns the text string if successful, false if the item doesn't exist.

Examples

loadstring(exports.dgs:dgsImportFunction())()-- load functions

-- Create a menu with some items
local menu = dgsCreateMenu(200, 200, 150, 100, false)
local item1 = dgsMenuAddItem(menu, "New Game", "new")
local item2 = dgsMenuAddItem(menu, "Load Game", "load")
local item3 = dgsMenuAddItem(menu, "Exit", "exit")

-- Show the menu
dgsMenuShow(menu)

-- Get and display the text of menu items
local text1 = dgsMenuGetItemText(menu, item1)
local text2 = dgsMenuGetItemText(menu, item2)
local text3 = dgsMenuGetItemText(menu, item3)

outputChatBox("Menu items: " .. text1 .. ", " .. text2 .. ", " .. text3)
-- Output: "Menu items: New Game, Load Game, Exit"

See Also

Author

Mohab.