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.
HideMenuForPlayer
Description
Hides a menu for a player.
Name | Description |
---|---|
Menu:menuid | The ID of the menu to hide. Returned by CreateMenu and passed to OnPlayerSelectedMenuRow. |
playerid | The ID of the player that the menu will be hidden for. |
Returns
true - The function was executed successfully.
false - The function failed to execute.
Examples
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/menuhide", true) == 0)
{
new Menu:myMenu = GetPlayerMenu(playerid);
HideMenuForPlayer(myMenu, playerid);
return 1;
}
return 0;
}
Notes
warning
Crashes the both server and player if an invalid menu ID given. (Fixed in open.mp)
tip
This function has always taken a menu ID parameter, but in SA:MP this ID was not used. So whatever value was given the player's current menu would be closed, even if they weren't looking at the one you said to close.
Old code may have looked like:
gShopMenu = CreateMenu("text", 2, 100.0, 30.0, 7.0);
HideMenuForPlayer(gShopMenu, playerid);
That would always close the player's current menu, regardless of which one they were actually looking at. Now you will need to remember which one they are looking at, or just get it:
gShopMenu = CreateMenu("text", 2, 100.0, 30.0, 7.0);
HideMenuForPlayer(GetPlayerMenu(playerid), playerid);
Related Functions
- CreateMenu: Create a menu.
- AddMenuItem: Adds an item to a specified menu.
- SetMenuColumnHeader: Set the header for one of the columns in a menu.
- ShowMenuForPlayer: Show a menu for a player.