muhammad-umerr/easyMenu
A simple upgrade to the native SA-MP menus, created with TextDraws and inspired by easyDialog for easy implementation.
Este repositório não tem arquivo de licença. Ele é público para leitura, mas isso sozinho não dá permissão para reutilizar.
README.md
easyMenu
easyMenu.inc is a lightweight SA-MP include for creating singleplayer-style
menus with player textdraws. It provides a dialog-like callback API while
rendering the menu directly on the player's screen.
Menus support keyboard navigation, selection, cancellation, pagination, and optional right-aligned information for each option.
Creating a menu
Declare a menu callback with CMenu: and open it with Menu_Show:
CMenu:InventoryMenu(playerid, response, row, option[])
{
if (!response)
{
SendClientMessage(playerid, -1, "Inventory menu cancelled.");
return 1;
}
new message[96];
format(message, sizeof(message), "You selected row %d: %s", row, option);
SendClientMessage(playerid, -1, message);
return 1;
}
CMD:normalmenu(playerid, params[])
{
Menu_Show(playerid, InventoryMenu, "Inventory", "Sprunk\nWhiskey\nMedkit\nBandage\nCigarette");
return 1;
}
The callback receives:
CMenu:MenuName(playerid, response, row, option[])
playerid- The player who interacted with the menu.response-1when the player selects an option, or0when the menu is cancelled.row- The zero-based index of the selected option.option[]- The selected option's label.
Option format
Separate options with \n. Use \t to add right-aligned information:
Menu_Show(playerid, VehicleMenu, "Vehicles", "Infernus\t$100,000\nBanshee\t$85,000\nBullet\t$75,000");
The text before \t is passed to the callback as option[]. The text after
\t is displayed in the menu's information column.
Controls
While a menu is open:
UPandDOWNmove between options.SPRINTconfirms the selected option.SECONDARY_ATTACKcancels the menu.
The player is frozen while the menu is open. The include restores the player's control state when the menu is closed and preserves the jetpack state.
Menu functions
Menu_Show
Opens a menu and resets the selection to the first option.
Menu_Show(playerid, callback, title[], options[]);
The menu displays up to 10 rows at a time and automatically changes pages for larger option lists.
EasyMenu_Open
The underlying function used by Menu_Show:
EasyMenu_Open(playerid, const function[], const title[], const options[]);
Use Menu_Show in normal code so the callback name is passed correctly.
EasyMenu_Close
Closes the player's current menu and invokes its callback with response set
to 0.
EasyMenu_Close(playerid);
EasyMenu_IsOpen
Returns 1 when a menu is open for the player, otherwise 0.
if (EasyMenu_IsOpen(playerid))
EasyMenu_Close(playerid);
EasyMenu_Pause
Pauses or resumes menu input. The menu remains visible while paused.
EasyMenu_Pause(playerid); // Pause
EasyMenu_Pause(playerid, false); // Resume
EasyMenu_IsPaused
Returns 1 when the player's menu is paused, otherwise 0.
if (!EasyMenu_IsPaused(playerid))
EasyMenu_Move(playerid, 1);
EasyMenu_Move
Moves the selection by the specified number of rows. Positive values move down; negative values move up.
EasyMenu_Move(playerid, 1);
EasyMenu_Move(playerid, -1);
The include also supports these optional input callback(s):
public OnMenuRowChanged(playerid, row)
{
return 1;
}
OnMenuRowChanged is called after the selected row changes. The key callbacks
are called when the corresponding key state changes, including when no menu is
open.
Limits
- 10 visible rows per page.
- 64 options per menu.
- 18 characters for the title.
- 28 characters per row
Credits
- Umer - Author, Design
- All easyDialog contributors - For the functionality reference and inspiration
Esta página é montada com o que o GitHub publica sobre o repositório. O samp.directory não hospeda o código. Avisar de um problema com esta página