Normalize all the line endings
This commit is contained in:
@ -10,118 +10,118 @@
|
||||
//
|
||||
// Message Stocks
|
||||
//
|
||||
|
||||
#if defined _message_stocks_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _message_stocks_included
|
||||
|
||||
/* Creates a death message. */
|
||||
stock dod_make_deathmsg(killer, victim, weaponNUM)
|
||||
{
|
||||
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
|
||||
write_byte(killer);
|
||||
write_byte(victim);
|
||||
write_byte(weaponNUM);
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Kills a user without a message. */
|
||||
stock user_silentkill(index)
|
||||
{
|
||||
static msgid = 0;
|
||||
new msgblock;
|
||||
if (!msgid)
|
||||
{
|
||||
msgid = get_user_msgid("DeathMsg");
|
||||
}
|
||||
msgblock = get_msg_block(msgid);
|
||||
set_msg_block(msgid, BLOCK_ONCE);
|
||||
user_kill(index, 1);
|
||||
set_msg_block(msgid, msgblock);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Creates a death message. */
|
||||
stock make_deathmsg(killer, victim, headshot, const weapon[])
|
||||
{
|
||||
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
|
||||
write_byte(killer);
|
||||
write_byte(victim);
|
||||
|
||||
new mod_name[32];
|
||||
get_modname(mod_name, 31);
|
||||
if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
|
||||
write_byte(headshot);
|
||||
write_string(weapon);
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a predefined text message to player.
|
||||
* Predefined texts are default game messages which will be translated
|
||||
* to player's game language, e.g. #Game_join_ct.
|
||||
*
|
||||
* @note Set index to 0 to send text globally.
|
||||
*
|
||||
* @note There does not necessarily have to be a total of 6 arguments.
|
||||
* It will depend if message takes arguments, e.g.:
|
||||
* client_printex(id, print_chat, "#Game_join_ct", "Pimp Daddy")
|
||||
* client_printex(id, print_chat, "1", "#Game_radio", "Pimp Daddy", "Hello world!")
|
||||
*
|
||||
* @param index Index of the player, use 0 to send to all players.
|
||||
* @param type The message destination. See print_* constants.
|
||||
* @param msg_name The custom or predefined message to send.
|
||||
* @param msg_param1 Optional message argument.
|
||||
* @param msg_param2 Optional message argument.
|
||||
* @param msg_param3 Optional message argument.
|
||||
* @param msg_param4 Optional message argument.
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
stock client_printex(index, type, const msg_name[], const msg_param1[] = "", const msg_param2[] = "", const msg_param3[] = "", const msg_param4[] = "")
|
||||
{
|
||||
new ch = msg_name[0];
|
||||
|
||||
// If not a predefined message, we don't care about it and forward directly to client_print.
|
||||
// Special case for radio message. msg_name is an index, msg_param1 #Game_radio*, etc. Checking index should be enough.
|
||||
if (ch != '#' && (type != print_radio || !strtol(msg_name)))
|
||||
{
|
||||
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
|
||||
}
|
||||
|
||||
// Even if message starts with '#', we should check its length for safety.
|
||||
new length = strlen(msg_name);
|
||||
|
||||
// If string is larger than expected, we forward to client_print which will cut message properly.
|
||||
// This means also this can't be a predefined game message.
|
||||
// Max console length: 128 = \n (126) + \0 (127)
|
||||
// Max SayText length: 192 = \n (190) + \0 (191)
|
||||
if ((length > 126 && (print_notify <= type <= print_console))
|
||||
|| ( length > 190 && (print_chat <= type <= print_radio)))
|
||||
{
|
||||
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
|
||||
}
|
||||
|
||||
static msgTextMsg;
|
||||
if (!msgTextMsg)
|
||||
{
|
||||
msgTextMsg = get_user_msgid("TextMsg");
|
||||
}
|
||||
|
||||
message_begin(index > 0 ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgTextMsg, .player = index);
|
||||
write_byte(type);
|
||||
write_string(msg_name);
|
||||
if (msg_param1[0]) { write_string(msg_param1); }
|
||||
if (msg_param2[0]) { write_string(msg_param2); }
|
||||
if (msg_param3[0]) { write_string(msg_param3); }
|
||||
if (msg_param4[0]) { write_string(msg_param4); }
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined _message_stocks_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _message_stocks_included
|
||||
|
||||
/* Creates a death message. */
|
||||
stock dod_make_deathmsg(killer, victim, weaponNUM)
|
||||
{
|
||||
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
|
||||
write_byte(killer);
|
||||
write_byte(victim);
|
||||
write_byte(weaponNUM);
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Kills a user without a message. */
|
||||
stock user_silentkill(index)
|
||||
{
|
||||
static msgid = 0;
|
||||
new msgblock;
|
||||
if (!msgid)
|
||||
{
|
||||
msgid = get_user_msgid("DeathMsg");
|
||||
}
|
||||
msgblock = get_msg_block(msgid);
|
||||
set_msg_block(msgid, BLOCK_ONCE);
|
||||
user_kill(index, 1);
|
||||
set_msg_block(msgid, msgblock);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Creates a death message. */
|
||||
stock make_deathmsg(killer, victim, headshot, const weapon[])
|
||||
{
|
||||
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
|
||||
write_byte(killer);
|
||||
write_byte(victim);
|
||||
|
||||
new mod_name[32];
|
||||
get_modname(mod_name, 31);
|
||||
if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
|
||||
write_byte(headshot);
|
||||
write_string(weapon);
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a predefined text message to player.
|
||||
* Predefined texts are default game messages which will be translated
|
||||
* to player's game language, e.g. #Game_join_ct.
|
||||
*
|
||||
* @note Set index to 0 to send text globally.
|
||||
*
|
||||
* @note There does not necessarily have to be a total of 6 arguments.
|
||||
* It will depend if message takes arguments, e.g.:
|
||||
* client_printex(id, print_chat, "#Game_join_ct", "Pimp Daddy")
|
||||
* client_printex(id, print_chat, "1", "#Game_radio", "Pimp Daddy", "Hello world!")
|
||||
*
|
||||
* @param index Index of the player, use 0 to send to all players.
|
||||
* @param type The message destination. See print_* constants.
|
||||
* @param msg_name The custom or predefined message to send.
|
||||
* @param msg_param1 Optional message argument.
|
||||
* @param msg_param2 Optional message argument.
|
||||
* @param msg_param3 Optional message argument.
|
||||
* @param msg_param4 Optional message argument.
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
stock client_printex(index, type, const msg_name[], const msg_param1[] = "", const msg_param2[] = "", const msg_param3[] = "", const msg_param4[] = "")
|
||||
{
|
||||
new ch = msg_name[0];
|
||||
|
||||
// If not a predefined message, we don't care about it and forward directly to client_print.
|
||||
// Special case for radio message. msg_name is an index, msg_param1 #Game_radio*, etc. Checking index should be enough.
|
||||
if (ch != '#' && (type != print_radio || !strtol(msg_name)))
|
||||
{
|
||||
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
|
||||
}
|
||||
|
||||
// Even if message starts with '#', we should check its length for safety.
|
||||
new length = strlen(msg_name);
|
||||
|
||||
// If string is larger than expected, we forward to client_print which will cut message properly.
|
||||
// This means also this can't be a predefined game message.
|
||||
// Max console length: 128 = \n (126) + \0 (127)
|
||||
// Max SayText length: 192 = \n (190) + \0 (191)
|
||||
if ((length > 126 && (print_notify <= type <= print_console))
|
||||
|| ( length > 190 && (print_chat <= type <= print_radio)))
|
||||
{
|
||||
return client_print(index, type, msg_name, msg_param1, msg_param2, msg_param3, msg_param4);
|
||||
}
|
||||
|
||||
static msgTextMsg;
|
||||
if (!msgTextMsg)
|
||||
{
|
||||
msgTextMsg = get_user_msgid("TextMsg");
|
||||
}
|
||||
|
||||
message_begin(index > 0 ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgTextMsg, .player = index);
|
||||
write_byte(type);
|
||||
write_string(msg_name);
|
||||
if (msg_param1[0]) { write_string(msg_param1); }
|
||||
if (msg_param2[0]) { write_string(msg_param2); }
|
||||
if (msg_param3[0]) { write_string(msg_param3); }
|
||||
if (msg_param4[0]) { write_string(msg_param4); }
|
||||
message_end();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -6,311 +6,311 @@
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
|
||||
#if defined _newmenus_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _newmenus_included
|
||||
|
||||
#define MEXIT_ALL 1 /* Menu will have an exit option (default)*/
|
||||
#define MEXIT_FORCE 2 /* Menu will have an exit option, even when pagination is disabled.
|
||||
* There have to be less than 10 items in the menu or it won't appear. The exit
|
||||
* option will be appended to the last item with no extra slot padding. If you
|
||||
* want it in the 10th slot you have to pad it manually with menu_addblank2 */
|
||||
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
|
||||
|
||||
#define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */
|
||||
#define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */
|
||||
#define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */
|
||||
#define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */
|
||||
#define MPROP_TITLE 5 /* Menu title text (param1 = string) */
|
||||
#define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */
|
||||
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */
|
||||
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */
|
||||
|
||||
#define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */
|
||||
|
||||
/**
|
||||
* @brief Creates a new menu object.
|
||||
*
|
||||
* The handler function should be prototyped as:
|
||||
*
|
||||
* public <function>(id, menu, item)
|
||||
* id - Client the menu is being acted upon.
|
||||
* menu - Menu resource identifier.
|
||||
* item - Item the client selected. If less than 0, the menu was
|
||||
* cancelled and the item is a status code. menu_display
|
||||
* should never be called immediately if the item is a status
|
||||
* code, for re-entrancy reasons.
|
||||
*
|
||||
* The handler function should always return PLUGIN_HANDLED to block
|
||||
* any old menu handlers from potentially feeding on the menu, unless
|
||||
* that is the desired functionality.
|
||||
*
|
||||
* @param title Title the menu should use.
|
||||
* @param handler Name of the handler function. The function will be invoked
|
||||
* once and only once to every menu_display() call.
|
||||
* @param ml Unused (should be 0).
|
||||
* @return Menu resource identifier which must be destroyed via
|
||||
* menu_destroy(). All menus are destroyed when the plugin
|
||||
* unloads.
|
||||
* @error Function name not found.
|
||||
*/
|
||||
native menu_create(const title[], const handler[], ml=0);
|
||||
|
||||
/**
|
||||
* Creates a menu item callback handler.
|
||||
*
|
||||
* The handler function should be prototyped as:
|
||||
*
|
||||
* public <function>(id, menu, item)
|
||||
* id - Client index being displayed to.
|
||||
* menu - Menu resource identifier.
|
||||
* item - Item being drawn.
|
||||
* <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to
|
||||
* explicitly enable or ITEM_DISABLED to explicitly disable.
|
||||
*
|
||||
* @param function Function name.
|
||||
* @return Menu callback ID.
|
||||
*/
|
||||
native menu_makecallback(const function[]);
|
||||
|
||||
/**
|
||||
* Adds an menu to a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param name Item text to display.
|
||||
* @param info Item info string for internal information.
|
||||
* @param paccess Access required by the player viewing the menu.
|
||||
* @param callback If set to a valid ID from menu_makecallback(), the
|
||||
* callback will be invoked before drawing the item.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
|
||||
|
||||
/**
|
||||
* Returns the number of pages in a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @return Number of pages in the menu.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_pages(menu);
|
||||
|
||||
/**
|
||||
* Returns the number of items in a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @return Number of items in the menu.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_items(menu);
|
||||
|
||||
/**
|
||||
* Displays a menu to one client. This should never be called from a handler
|
||||
* when the item is less than 0 (i.e. calling this from a cancelled menu will
|
||||
* result in an error).
|
||||
*
|
||||
* Starting with 1.8.3 this allows to specify a menu timeout similar to the
|
||||
* show_menu native. If the menu exists on the client past the timeout *any*
|
||||
* further action will send the MENU_TIMEOUT status code to the menu handler.
|
||||
* That includes actions which would otherwise send MENU_EXIT, such as the
|
||||
* client selecting an item or disconnecting and calling menu_cancel or
|
||||
* menu_destroy on a live menu.
|
||||
*
|
||||
* @param id Client index.
|
||||
* @param menu Menu resource identifier.
|
||||
* @param page Page to start from (starting from 0).
|
||||
* @param time If >=0 menu will timeout after this many seconds
|
||||
* @noreturn
|
||||
* @error Invalid menu resource or client index.
|
||||
*/
|
||||
native menu_display(id, menu, page=0, time=-1);
|
||||
|
||||
/**
|
||||
* Given a page on a menu and a keypress on that page, returns the item id selected.
|
||||
* If the item is less than 0, a special option was chosen (such as MENU_EXIT).
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param page Page on the menu.
|
||||
* @param key Key pressed (from 1 to 10).
|
||||
* @return Item identifier, or <0 for a special selection code.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_find_id(menu, page, key);
|
||||
|
||||
/**
|
||||
* Retrieves info about a menu item.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param access Variable to store access value.
|
||||
* @param info Buffer to store item info.
|
||||
* @param infolen Item info buffer length.
|
||||
* @param name Buffer to store item display text.
|
||||
* @param namelen Item name buffer length.
|
||||
* @param callback Callback ID.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);
|
||||
|
||||
/**
|
||||
* Sets an item's display text.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param name New item display text.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setname(menu, item, const name[]);
|
||||
|
||||
/**
|
||||
* Sets an item's info string.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param info New item info string.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setcmd(menu, item, const info[]);
|
||||
|
||||
/**
|
||||
* Sets an item's callback.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param callback New callback from menu_makecallback(), or -1 to clear.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setcall(menu, item, callback=-1);
|
||||
|
||||
/**
|
||||
* Destroys a menu. Player menus will be cancelled (although may still linger
|
||||
* on the HUD), and future attempts to access the menu resource will result in
|
||||
* an error.
|
||||
*
|
||||
* This must be called if you create menus dynamically, otherwise you will
|
||||
* leak memory. For normal dynamic menus, you will destroy the menu in the
|
||||
* handler function (remembering to handle the case of a menu being cancelled,
|
||||
* it must still be destroyed).
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_destroy(menu);
|
||||
|
||||
/**
|
||||
* Returns information about a menu (if any) the client is currently viewing.
|
||||
*
|
||||
* If newmenu is valid, then the menu will refer to the menuid associated with
|
||||
* the title. If newmenu is not valid, and the menu is valid, then the player
|
||||
* is viewing a menu displayed with show_menu().
|
||||
*
|
||||
* Both may be invalid if the player is not viewing a menu.
|
||||
*
|
||||
* @param id Client index.
|
||||
* @param menu Variable to store old menu id. If none, then <1 will be
|
||||
* stored.
|
||||
* @param newmenu Variable to store new menu id. If none, then -1 will be
|
||||
* stored.
|
||||
* @param menupage Variable to store current page of the new menu, if any.
|
||||
* @return 1 if the player is viewing a menu, 0 otherwise.
|
||||
* @error Invalid client.
|
||||
*/
|
||||
native player_menu_info(id, &menu, &newmenu, &menupage=0);
|
||||
|
||||
/**
|
||||
* Adds a blank line to a menu.
|
||||
*
|
||||
* When using slot=1 this might break your menu. To achieve this functionality
|
||||
* menu_addblank2 should be used.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param slot 1 (default) if the line should shift the numbering down.
|
||||
* 0 if the line should be a visual shift only.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_addblank(menu, slot=1);
|
||||
|
||||
/**
|
||||
* Adds a text line to a menu. Only available in amxmodx 1.8.1 and above.
|
||||
*
|
||||
* When using slot=1 this might break your menu. To achieve this functionality
|
||||
* menu_addtext2 should be used.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param text Text to add.
|
||||
* @param slot 1 (default) if the line should shift the numbering down.
|
||||
* 0 if the line should be a visual shift only.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_addtext(menu, const text[], slot=1);
|
||||
|
||||
/**
|
||||
* Adds a blank line to a menu, always shifting the numbering down.
|
||||
*
|
||||
* This will add a special item to create a blank line. It will affect the menu
|
||||
* item count and pagination. These items can be modified later but will ignore
|
||||
* access and item callback results.
|
||||
*
|
||||
* Only available in 1.8.3 and above.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
*
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
* Too many items on non-paginated menu (max is 10)
|
||||
*/
|
||||
native menu_addblank2( menu );
|
||||
|
||||
/**
|
||||
* Adds a text line to a menu, always shifting the numbering down.
|
||||
*
|
||||
* This will add a special item to create a blank line. It will affect the menu
|
||||
* item count and pagination. These items can be modified later but will ignore
|
||||
* access and item callback results.
|
||||
*
|
||||
* Only available in 1.8.3 and above.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param text Text to add.
|
||||
*
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
* Too many items on non-paginated menu (max is 10)
|
||||
*/
|
||||
native menu_addtext2( menu, const text[] );
|
||||
|
||||
/**
|
||||
* Sets a menu property.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param prop MPROP_ constant.
|
||||
* @param ... Property parameters.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource or property.
|
||||
*/
|
||||
native menu_setprop(menu, prop, ...);
|
||||
|
||||
/**
|
||||
* Cancels a player's menu, effectively forcing the player to select MENU_EXIT.
|
||||
* The menu will still exist on their screen but any results are invalidated,
|
||||
* and the callback is invoked.
|
||||
*
|
||||
* @param player Client index.
|
||||
* @noreturn
|
||||
* @error Invalid client index.
|
||||
*/
|
||||
native menu_cancel(player);
|
||||
|
||||
#if defined _newmenus_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _newmenus_included
|
||||
|
||||
#define MEXIT_ALL 1 /* Menu will have an exit option (default)*/
|
||||
#define MEXIT_FORCE 2 /* Menu will have an exit option, even when pagination is disabled.
|
||||
* There have to be less than 10 items in the menu or it won't appear. The exit
|
||||
* option will be appended to the last item with no extra slot padding. If you
|
||||
* want it in the 10th slot you have to pad it manually with menu_addblank2 */
|
||||
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
|
||||
|
||||
#define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */
|
||||
#define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */
|
||||
#define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */
|
||||
#define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */
|
||||
#define MPROP_TITLE 5 /* Menu title text (param1 = string) */
|
||||
#define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */
|
||||
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */
|
||||
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */
|
||||
|
||||
#define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */
|
||||
#define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */
|
||||
|
||||
/**
|
||||
* @brief Creates a new menu object.
|
||||
*
|
||||
* The handler function should be prototyped as:
|
||||
*
|
||||
* public <function>(id, menu, item)
|
||||
* id - Client the menu is being acted upon.
|
||||
* menu - Menu resource identifier.
|
||||
* item - Item the client selected. If less than 0, the menu was
|
||||
* cancelled and the item is a status code. menu_display
|
||||
* should never be called immediately if the item is a status
|
||||
* code, for re-entrancy reasons.
|
||||
*
|
||||
* The handler function should always return PLUGIN_HANDLED to block
|
||||
* any old menu handlers from potentially feeding on the menu, unless
|
||||
* that is the desired functionality.
|
||||
*
|
||||
* @param title Title the menu should use.
|
||||
* @param handler Name of the handler function. The function will be invoked
|
||||
* once and only once to every menu_display() call.
|
||||
* @param ml Unused (should be 0).
|
||||
* @return Menu resource identifier which must be destroyed via
|
||||
* menu_destroy(). All menus are destroyed when the plugin
|
||||
* unloads.
|
||||
* @error Function name not found.
|
||||
*/
|
||||
native menu_create(const title[], const handler[], ml=0);
|
||||
|
||||
/**
|
||||
* Creates a menu item callback handler.
|
||||
*
|
||||
* The handler function should be prototyped as:
|
||||
*
|
||||
* public <function>(id, menu, item)
|
||||
* id - Client index being displayed to.
|
||||
* menu - Menu resource identifier.
|
||||
* item - Item being drawn.
|
||||
* <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to
|
||||
* explicitly enable or ITEM_DISABLED to explicitly disable.
|
||||
*
|
||||
* @param function Function name.
|
||||
* @return Menu callback ID.
|
||||
*/
|
||||
native menu_makecallback(const function[]);
|
||||
|
||||
/**
|
||||
* Adds an menu to a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param name Item text to display.
|
||||
* @param info Item info string for internal information.
|
||||
* @param paccess Access required by the player viewing the menu.
|
||||
* @param callback If set to a valid ID from menu_makecallback(), the
|
||||
* callback will be invoked before drawing the item.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
|
||||
|
||||
/**
|
||||
* Returns the number of pages in a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @return Number of pages in the menu.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_pages(menu);
|
||||
|
||||
/**
|
||||
* Returns the number of items in a menu.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @return Number of items in the menu.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_items(menu);
|
||||
|
||||
/**
|
||||
* Displays a menu to one client. This should never be called from a handler
|
||||
* when the item is less than 0 (i.e. calling this from a cancelled menu will
|
||||
* result in an error).
|
||||
*
|
||||
* Starting with 1.8.3 this allows to specify a menu timeout similar to the
|
||||
* show_menu native. If the menu exists on the client past the timeout *any*
|
||||
* further action will send the MENU_TIMEOUT status code to the menu handler.
|
||||
* That includes actions which would otherwise send MENU_EXIT, such as the
|
||||
* client selecting an item or disconnecting and calling menu_cancel or
|
||||
* menu_destroy on a live menu.
|
||||
*
|
||||
* @param id Client index.
|
||||
* @param menu Menu resource identifier.
|
||||
* @param page Page to start from (starting from 0).
|
||||
* @param time If >=0 menu will timeout after this many seconds
|
||||
* @noreturn
|
||||
* @error Invalid menu resource or client index.
|
||||
*/
|
||||
native menu_display(id, menu, page=0, time=-1);
|
||||
|
||||
/**
|
||||
* Given a page on a menu and a keypress on that page, returns the item id selected.
|
||||
* If the item is less than 0, a special option was chosen (such as MENU_EXIT).
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param page Page on the menu.
|
||||
* @param key Key pressed (from 1 to 10).
|
||||
* @return Item identifier, or <0 for a special selection code.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_find_id(menu, page, key);
|
||||
|
||||
/**
|
||||
* Retrieves info about a menu item.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param access Variable to store access value.
|
||||
* @param info Buffer to store item info.
|
||||
* @param infolen Item info buffer length.
|
||||
* @param name Buffer to store item display text.
|
||||
* @param namelen Item name buffer length.
|
||||
* @param callback Callback ID.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);
|
||||
|
||||
/**
|
||||
* Sets an item's display text.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param name New item display text.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setname(menu, item, const name[]);
|
||||
|
||||
/**
|
||||
* Sets an item's info string.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param info New item info string.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setcmd(menu, item, const info[]);
|
||||
|
||||
/**
|
||||
* Sets an item's callback.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param item Item identifier.
|
||||
* @param callback New callback from menu_makecallback(), or -1 to clear.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_item_setcall(menu, item, callback=-1);
|
||||
|
||||
/**
|
||||
* Destroys a menu. Player menus will be cancelled (although may still linger
|
||||
* on the HUD), and future attempts to access the menu resource will result in
|
||||
* an error.
|
||||
*
|
||||
* This must be called if you create menus dynamically, otherwise you will
|
||||
* leak memory. For normal dynamic menus, you will destroy the menu in the
|
||||
* handler function (remembering to handle the case of a menu being cancelled,
|
||||
* it must still be destroyed).
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_destroy(menu);
|
||||
|
||||
/**
|
||||
* Returns information about a menu (if any) the client is currently viewing.
|
||||
*
|
||||
* If newmenu is valid, then the menu will refer to the menuid associated with
|
||||
* the title. If newmenu is not valid, and the menu is valid, then the player
|
||||
* is viewing a menu displayed with show_menu().
|
||||
*
|
||||
* Both may be invalid if the player is not viewing a menu.
|
||||
*
|
||||
* @param id Client index.
|
||||
* @param menu Variable to store old menu id. If none, then <1 will be
|
||||
* stored.
|
||||
* @param newmenu Variable to store new menu id. If none, then -1 will be
|
||||
* stored.
|
||||
* @param menupage Variable to store current page of the new menu, if any.
|
||||
* @return 1 if the player is viewing a menu, 0 otherwise.
|
||||
* @error Invalid client.
|
||||
*/
|
||||
native player_menu_info(id, &menu, &newmenu, &menupage=0);
|
||||
|
||||
/**
|
||||
* Adds a blank line to a menu.
|
||||
*
|
||||
* When using slot=1 this might break your menu. To achieve this functionality
|
||||
* menu_addblank2 should be used.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param slot 1 (default) if the line should shift the numbering down.
|
||||
* 0 if the line should be a visual shift only.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_addblank(menu, slot=1);
|
||||
|
||||
/**
|
||||
* Adds a text line to a menu. Only available in amxmodx 1.8.1 and above.
|
||||
*
|
||||
* When using slot=1 this might break your menu. To achieve this functionality
|
||||
* menu_addtext2 should be used.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param text Text to add.
|
||||
* @param slot 1 (default) if the line should shift the numbering down.
|
||||
* 0 if the line should be a visual shift only.
|
||||
* @noreturn
|
||||
* @error Invalid menu resource.
|
||||
*/
|
||||
native menu_addtext(menu, const text[], slot=1);
|
||||
|
||||
/**
|
||||
* Adds a blank line to a menu, always shifting the numbering down.
|
||||
*
|
||||
* This will add a special item to create a blank line. It will affect the menu
|
||||
* item count and pagination. These items can be modified later but will ignore
|
||||
* access and item callback results.
|
||||
*
|
||||
* Only available in 1.8.3 and above.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
*
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
* Too many items on non-paginated menu (max is 10)
|
||||
*/
|
||||
native menu_addblank2( menu );
|
||||
|
||||
/**
|
||||
* Adds a text line to a menu, always shifting the numbering down.
|
||||
*
|
||||
* This will add a special item to create a blank line. It will affect the menu
|
||||
* item count and pagination. These items can be modified later but will ignore
|
||||
* access and item callback results.
|
||||
*
|
||||
* Only available in 1.8.3 and above.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param text Text to add.
|
||||
*
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource.
|
||||
* Too many items on non-paginated menu (max is 10)
|
||||
*/
|
||||
native menu_addtext2( menu, const text[] );
|
||||
|
||||
/**
|
||||
* Sets a menu property.
|
||||
*
|
||||
* @param menu Menu resource identifier.
|
||||
* @param prop MPROP_ constant.
|
||||
* @param ... Property parameters.
|
||||
* @return 1 on success, 0 on failure.
|
||||
* @error Invalid menu resource or property.
|
||||
*/
|
||||
native menu_setprop(menu, prop, ...);
|
||||
|
||||
/**
|
||||
* Cancels a player's menu, effectively forcing the player to select MENU_EXIT.
|
||||
* The menu will still exist on their screen but any results are invalidated,
|
||||
* and the callback is invoked.
|
||||
*
|
||||
* @param player Client index.
|
||||
* @noreturn
|
||||
* @error Invalid client index.
|
||||
*/
|
||||
native menu_cancel(player);
|
||||
|
@ -16,92 +16,92 @@
|
||||
// C standard library, which uses the Quick Sort algorithm.
|
||||
// For more info, see: http://linux.wku.edu/~lamonml/algor/sort/sort.html
|
||||
//
|
||||
|
||||
#if defined _sorting_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _sorting_included
|
||||
|
||||
/**
|
||||
* Contains sorting orders.
|
||||
*/
|
||||
enum SortMethod
|
||||
{
|
||||
Sort_Ascending = 0,
|
||||
Sort_Descending,
|
||||
Sort_Random,
|
||||
};
|
||||
|
||||
/**
|
||||
* Data types for ADT Array Sorts
|
||||
*/
|
||||
enum SortType
|
||||
{
|
||||
Sort_Integer = 0,
|
||||
Sort_Float,
|
||||
Sort_String,
|
||||
};
|
||||
/**
|
||||
* Basic sorting functions below.
|
||||
*/
|
||||
|
||||
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
|
||||
|
||||
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
|
||||
|
||||
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
|
||||
|
||||
/**
|
||||
* Custom sorting functions below.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sorts a custom 1D array. You must pass in a comparison function.
|
||||
* The sorting algorithm then uses your comparison function to sort the data.
|
||||
* The function is called in the following manner:
|
||||
*
|
||||
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
|
||||
*
|
||||
* elem1, elem2 - Current element pair being compared
|
||||
* array[] - Array in its current mid-sorted state.
|
||||
* data[] - Extra data array you passed to the sort func.
|
||||
* data_size - Size of extra data you passed to the sort func.
|
||||
*
|
||||
* Your function should return:
|
||||
* -1 if elem1 should go before elem2
|
||||
* 0 if elem1 and elem2 are equal
|
||||
* 1 if elem1 should go after elem2
|
||||
* Note that the parameters after elem2 are all optional and you do not need to specify them.
|
||||
*/
|
||||
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
|
||||
|
||||
|
||||
/**
|
||||
* Sorts a custom 2D array.
|
||||
* The sorting algorithm then uses your comparison function to sort the data.
|
||||
* The function is called in the following manner:
|
||||
*
|
||||
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
|
||||
*
|
||||
* elem1[], elem2[] - Current element array pairs being compared
|
||||
* array[][] - Array in its currently being sorted state.
|
||||
* data[] - Extra data array you passed to the sort func.
|
||||
* data_size - Size of extra data you passed to the sort func.
|
||||
*
|
||||
* Your function should return:
|
||||
* -1 if elem1[] should go before elem2[]
|
||||
* 0 if elem1[] and elem2 are equal[]
|
||||
* 1 if elem1[] should go after elem2[]
|
||||
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
|
||||
*/
|
||||
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);
|
||||
|
||||
/**
|
||||
* Sort an ADT Array. Specify the type as Integer, Float, or String.
|
||||
*
|
||||
* @param array Array Handle to sort
|
||||
* @param order Sort order to use, same as other sorts.
|
||||
* @param type Data type stored in the ADT Array
|
||||
* @noreturn
|
||||
*/
|
||||
native SortADTArray(Array:array, SortMethod:order, SortType:type);
|
||||
|
||||
#if defined _sorting_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _sorting_included
|
||||
|
||||
/**
|
||||
* Contains sorting orders.
|
||||
*/
|
||||
enum SortMethod
|
||||
{
|
||||
Sort_Ascending = 0,
|
||||
Sort_Descending,
|
||||
Sort_Random,
|
||||
};
|
||||
|
||||
/**
|
||||
* Data types for ADT Array Sorts
|
||||
*/
|
||||
enum SortType
|
||||
{
|
||||
Sort_Integer = 0,
|
||||
Sort_Float,
|
||||
Sort_String,
|
||||
};
|
||||
/**
|
||||
* Basic sorting functions below.
|
||||
*/
|
||||
|
||||
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
|
||||
|
||||
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
|
||||
|
||||
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
|
||||
|
||||
/**
|
||||
* Custom sorting functions below.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sorts a custom 1D array. You must pass in a comparison function.
|
||||
* The sorting algorithm then uses your comparison function to sort the data.
|
||||
* The function is called in the following manner:
|
||||
*
|
||||
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
|
||||
*
|
||||
* elem1, elem2 - Current element pair being compared
|
||||
* array[] - Array in its current mid-sorted state.
|
||||
* data[] - Extra data array you passed to the sort func.
|
||||
* data_size - Size of extra data you passed to the sort func.
|
||||
*
|
||||
* Your function should return:
|
||||
* -1 if elem1 should go before elem2
|
||||
* 0 if elem1 and elem2 are equal
|
||||
* 1 if elem1 should go after elem2
|
||||
* Note that the parameters after elem2 are all optional and you do not need to specify them.
|
||||
*/
|
||||
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
|
||||
|
||||
|
||||
/**
|
||||
* Sorts a custom 2D array.
|
||||
* The sorting algorithm then uses your comparison function to sort the data.
|
||||
* The function is called in the following manner:
|
||||
*
|
||||
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
|
||||
*
|
||||
* elem1[], elem2[] - Current element array pairs being compared
|
||||
* array[][] - Array in its currently being sorted state.
|
||||
* data[] - Extra data array you passed to the sort func.
|
||||
* data_size - Size of extra data you passed to the sort func.
|
||||
*
|
||||
* Your function should return:
|
||||
* -1 if elem1[] should go before elem2[]
|
||||
* 0 if elem1[] and elem2 are equal[]
|
||||
* 1 if elem1[] should go after elem2[]
|
||||
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
|
||||
*/
|
||||
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);
|
||||
|
||||
/**
|
||||
* Sort an ADT Array. Specify the type as Integer, Float, or String.
|
||||
*
|
||||
* @param array Array Handle to sort
|
||||
* @param order Sort order to use, same as other sorts.
|
||||
* @param type Data type stored in the ADT Array
|
||||
* @noreturn
|
||||
*/
|
||||
native SortADTArray(Array:array, SortMethod:order, SortType:type);
|
||||
|
Reference in New Issue
Block a user