From da518fdc0f32839730ccdee8098b59c6f842d93f Mon Sep 17 00:00:00 2001 From: navewindre Date: Mon, 13 Nov 2023 14:28:08 +0100 Subject: ya --- .../scripting/include/smlib/menus.inc | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sourcemod-1.5-dev/scripting/include/smlib/menus.inc (limited to 'sourcemod-1.5-dev/scripting/include/smlib/menus.inc') diff --git a/sourcemod-1.5-dev/scripting/include/smlib/menus.inc b/sourcemod-1.5-dev/scripting/include/smlib/menus.inc new file mode 100644 index 0000000..c0c825d --- /dev/null +++ b/sourcemod-1.5-dev/scripting/include/smlib/menus.inc @@ -0,0 +1,38 @@ +#if defined _smlib_menus_included + #endinput +#endif +#define _smlib_menus_included + +#include +#include + +/** + * Adds an option to a menu with a String display but an integer + * identifying the option. + * + * @param menu Handle to the menu + * @param value Integer value for the option + * @param display Display text for the menu + * @noreturn + */ +stock Menu_AddIntItem(Handle:menu, any:value, String:display[]) +{ + decl String:buffer[INT_MAX_DIGITS + 1]; + IntToString(value, buffer, sizeof(buffer)); + AddMenuItem(menu, buffer, display); +} + +/** + * Retrieves an integer-value choice from a menu, where the + * menu's information strings were created as integers. + * + * @param menu Handle to the menu + * @param param2 The item position selected from the menu. + * @return Integer choice from the menu, or 0 if the integer could not be parsed. + */ +stock any:Menu_GetIntItem(Handle:menu, any:param2) +{ + decl String:buffer[INT_MAX_DIGITS + 1]; + GetMenuItem(menu, param2, buffer, sizeof(buffer)); + return StringToInt(buffer); +} -- cgit v1.2.3