note Help Needed
This wiki is the result of an ongoing community effort — thank you all for helping!
If you want to provide changes to this page then please click here.
OnPlayerSelectedMenuRow
Description
This callback is called when a player selects an item from a menu (ShowMenuForPlayer).
Name | Description |
---|---|
playerid | The ID of the player that selected a menu item. |
row | The ID of the row that was selected. The first row is ID 0. |
Returns
It is always called first in gamemode.
Examples
new Menu:MyMenu;
public OnGameModeInit()
{
MyMenu = CreateMenu("Example Menu", 1, 50.0, 180.0, 200.0, 200.0);
AddMenuItem(MyMenu, 0, "Item 1");
AddMenuItem(MyMenu, 0, "Item 2");
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
if (GetPlayerMenu(playerid) == MyMenu)
{
switch (row)
{
case 0:
{
print("Item 1 Selected");
}
case 1:
{
print("Item 2 Selected");
}
}
}
return 1;
}
Notes
tip
The menu ID is not passed to this callback. GetPlayerMenu must be used to determine which menu the player selected an item on.
Related Callbacks
The following callbacks might be useful, as they're related to this callback in one way or another.
- OnPlayerExitedMenu: This callback is called when a player exits a menu.
- OnDialogResponse: This callback is called when a player responds to a dialog.
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- CreateMenu: Create a menu.
- DestroyMenu: Destroy a menu.
- AddMenuItem: Adds an item to a specified menu.
- ShowMenuForPlayer: Show a menu for a player.
- HideMenuForPlayer: Hide a menu for a player.