Skip to content

critMenu.AddButton

CritteRo edited this page Jun 20, 2021 · 4 revisions

critMenu.AddButton

Usage:

TriggerEvent('critMenu.AddButton', _menuID, _buttonID, _buttonText, _buttonRightText, _buttonStrikeThroughText, _buttonDescription, _buttonEventHandler)

Params:

  • _menuID :: Menu ID where you want to add the button. String.
  • _buttonID :: This is the button ID that will be sent along side _menuID, when selecting the button. String.
  • _buttonText :: Left-side text of the button.
  • _buttonRightText :: Right-side text.
  • _buttonStrikeThroughText :: This text will appear on the left side of _buttonRightText, in red, with a red line crossing it.
  • _buttonDescription :: Button tooltip.
  • _buttonEventHandler :: This is a client-side event. It will be triggered once you select the button. It will send _menuID and _buttonID as params.

Screenshot:

critMenu.AddButton example screenshot

Example:

TriggerEvent('critMenu.CreateMenu', "test1", "_menuTitle", "_menuDesc", "_selectText", "_upText", "_downText", "_quitText")

TriggerEvent('critMenu.AddButton', "test1", "test1button", "_buttonText1", "_buttonRightText", "_strike", "_buttonDescription", "test.event") TriggerEvent('critMenu.AddButton', "test1", "test2button", "_buttonText2", "_buttonRightText", "_strike", "_buttonDescription", "test.event") TriggerEvent('critMenu.AddButton', "test1", "test3button", "_buttonText3", "_buttonRightText", "_strike", "_buttonDescription", "test.event") TriggerEvent('critMenu.AddButton', "test1", "test4button", "_buttonText4", "_buttonRightText", "_strike", "_buttonDescription", "test.event")

RegisterCommand('showmen', function() TriggerEvent('critMenu.ShowMenu', "test1") end)

AddEventHandler('test.event', function(_menu, _button) TriggerEvent('critMenu.HideMenu') print('button ['.._button..'] from menu ['.._menu..'] triggered this event') end)

Notes:

  • Buttons can trigger the same event, since you also get the _buttonID param when activating that event.