OnPlayerSelectedMenuRow

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 21:38, 26 April 2015
MP2 (Talk | contribs)

← Previous diff
Current revision
OstGot (Talk | contribs)

Line 7: Line 7:
{{Param|row|The ID of the row that was selected. The first row is ID 0.}} {{Param|row|The ID of the row that was selected. The first row is ID 0.}}
-{{NoReturnCallback}}+{{Returns|This callback does not handle returns.
 +* It is always called first in gamemode.}}
{{note|The menu ID is not passed to this callback. [[GetPlayerMenu]] must be used to determine which menu the player selected an item on.}} {{note|The menu ID is not passed to this callback. [[GetPlayerMenu]] must be used to determine which menu the player selected an item on.}}
Line 17: Line 18:
public OnGameModeInit() public OnGameModeInit()
{ {
- MyMenu= CreateMenu("Example Menu", 1, 50.0, 180.0, 200.0, 200.0);+ MyMenu = CreateMenu("Example Menu", 1, 50.0, 180.0, 200.0, 200.0);
AddMenuItem(MyMenu, 0, "Item 1"); AddMenuItem(MyMenu, 0, "Item 1");
AddMenuItem(MyMenu, 0, "Item 2"); AddMenuItem(MyMenu, 0, "Item 2");

Current revision



Description:

This callback is called when a player selects an item from a menu (ShowMenuForPlayer).


Parameters:
(playerid, row)
playeridThe ID of the player that selected a menu item.
rowThe ID of the row that was selected. The first row is ID 0.


Return Values:

This callback does not handle returns.
  • It is always called first in gamemode.


Image:32px-Ambox_warning_orange.png

Note

The menu ID is not passed to this callback. GetPlayerMenu must be used to determine which menu the player selected an item on.


Example Usage:

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;
}

Related Callbacks

The following callbacks might be useful as well, as they are related to this callback in one way or another.


Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

Personal tools