diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 5e6d0773..b16b9b57 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -92,7 +92,7 @@ bool CloseNewMenus(CPlayer *pPlayer) Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"), m_NeverExit(false), m_AutoColors(g_coloredmenus), thisId(0), func(fid), -isDestroying(false), pageCallback(-1), items_per_page(7) +isDestroying(false), pageCallback(-1), showPageNumber(true), items_per_page(7) { CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx); menuId = g_menucmds.registerMenuId(title, amx); @@ -357,7 +357,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys) m_Text = nullptr; char buffer[255]; - if (items_per_page && (pages != 1)) + if (showPageNumber && items_per_page && (pages != 1)) { if (m_AutoColors) ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages); @@ -983,6 +983,11 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params) unregisterSPForward(pMenu->pageCallback); pMenu->pageCallback = callback; + break; + } + case MPROP_SHOWPAGE: + { + pMenu->showPageNumber = (get_amxaddr(amx, params[3]) != 0); break; } case MPROP_SET_NUMBER_COLOR: diff --git a/amxmodx/newmenus.h b/amxmodx/newmenus.h index 936188c3..df132df1 100755 --- a/amxmodx/newmenus.h +++ b/amxmodx/newmenus.h @@ -31,6 +31,7 @@ #define MPROP_PADMENU 9 #define MPROP_SET_NUMBER_COLOR 10 #define MPROP_PAGE_CALLBACK 11 +#define MPROP_SHOWPAGE 12 typedef int (*MENUITEM_CALLBACK)(int, int, int); @@ -125,6 +126,7 @@ public: int func; bool isDestroying; int pageCallback; + bool showPageNumber; public: unsigned int items_per_page; }; diff --git a/plugins/include/file.inc b/plugins/include/file.inc index 9cae711f..55ee53ac 100755 --- a/plugins/include/file.inc +++ b/plugins/include/file.inc @@ -1,666 +1,666 @@ -// vim: set ts=4 sw=4 tw=99 noet: -// -// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). -// Copyright (C) The AMX Mod X Development Team. -// -// 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 - -// -// File Functions -// - -#if defined _file_included - #endinput -#endif -#define _file_included - -/** - * @note All paths in AMX Mod X natives are relative to the mod folder - * unless otherwise noted. - * - * Most functions in AMX Mod X (at least, ones that deal with direct - * file manipulation) will support an alternate path specification. - */ - -/** - * Maximum path length. - */ -#define PLATFORM_MAX_PATH 256 - -/** - * File inode types for use with open_dir() and next_file(). - */ -enum FileType -{ - FileType_Unknown, /* Unknown file type (device/socket) */ - FileType_Directory, /* File is a directory */ - FileType_File, /* File is a file */ -}; - -/** - * File time modes for use with GetFileTime(). - */ -enum FileTimeType -{ - FileTime_LastAccess, /* Last access (not available on FAT) */ - FileTime_Created, /* Creation (not available on FAT) */ - FileTime_LastChange, /* Last modification */ -}; - -/** - * File position modes for use with fseek(). - */ -#define SEEK_SET 0 /* Seek from start */ -#define SEEK_CUR 1 /* Seek from current position */ -#define SEEK_END 2 /* Seek from end position */ - -/** - * Options for use with file_size() flag parameter. - */ -#define FSOPT_BYTES_COUNT 0 /* Returns the file size in number of bytes */ -#define FSOPT_LINES_COUNT 1 /* Returns how many lines there are in this file */ -#define FSOPT_END_WITH_LF 2 /* Returns whether the last line is '\n' */ - -/** - * Data block modes for use with fread*() and fwrite*(). - */ -#define BLOCK_INT 4 -#define BLOCK_SHORT 2 -#define BLOCK_CHAR 1 -#define BLOCK_BYTE 1 - -/** - * File permissions flags for use with mkdir() and SetFilePermissions(). - */ -#define FPERM_U_READ 0x0100 /* User can read. */ -#define FPERM_U_WRITE 0x0080 /* User can write. */ -#define FPERM_U_EXEC 0x0040 /* User can exec. */ -#define FPERM_U_RWX FPERM_U_READ | FPERM_U_WRITE | FPERM_U_EXEC - -#define FPERM_G_READ 0x0020 /* Group can read. */ -#define FPERM_G_WRITE 0x0010 /* Group can write. */ -#define FPERM_G_EXEC 0x0008 /* Group can exec. */ -#define FPERM_G_RWX FPERM_G_READ | FPERM_G_WRITE | FPERM_G_EXEC - -#define FPERM_O_READ 0x0004 /* Anyone can read. */ -#define FPERM_O_WRITE 0x0002 /* Anyone can write. */ -#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */ -#define FPERM_O_RWX FPERM_O_READ | FPERM_O_WRITE | FPERM_O_EXEC - -#define FPERM_DIR_DEFAULT FPERM_U_RWX | FPERM_G_RWX | FPERM_O_RWX /* rwx r-x r-x (0755) */ - - -/** - * Reads content from directory - * - * @note This native is expensive. Consider the use of open_dir(), next_file() and close_dir() instead. - * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux. - * - * @param dirname Path to open - * @param pos Index the element - * @param output String buffer to hold content - * @param len Maximum size of string buffer - * @param outlen Number of characters written to the buffer - * - * @return Returns index of next element, otherwiwe 0 when end of dir is reached - */ -native read_dir(const dirname[], pos, output[], len, &outlen = 0); - -/** - * Reads line from file. - * - * @note This native is expensive. Consider the use of new file natives (fopen(), fgets(), etc.) - * if purpose is to read several lines of a file. - * - * @param file Path to open - * @param line Index of the line, starting to 0 - * @param text String buffer to hold line read - * @param len Maximum size of string buffer - * @param txtlen Number of characters written to the buffer - * - * @return Returns index of next line, otherwise 0 when end of file is reached - * @error Unable to read the file - */ -native read_file(const file[], line, text[], len, &txtlen = 0); - -/** - * Writes text to file. - * - * @note This native is expensive. Consider the use of new file natives (fopen(), fputs(), etc.) - * if purpose is to write several lines of a file. - * - * @param file Path to open - * @param text String to write to - * @param line Index of the line, starting to 0 - * If < 0, content will be appended - * - * @noreturn - * @error Unable to write [temporary] file - */ -native write_file(const file[], const text[], line = -1); - -/** - * Deletes a file. - * - * @param file Path of the file to delete - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to delete files existing in the Valve - * search path, rather than solely files existing directly - * in the gamedir. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. - * - * @return 1 on success, 0 on failure or if file not immediately removed. - */ -native delete_file(const file[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); - -/** - * Checks if a file exists. - * - * @param file Path to the file - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to find files existing in any of - * the Valve search paths, rather than solely files - * existing directly in the gamedir. - * - * @return 1 if the file exists, 0 otherwise - */ -native file_exists(const file[], bool:use_valve_fs = false); - -/** - * Renames a file. - * - * @param oldname New path to the file - * @param newname Path to the existing file - * @param relative If true, native will act like other natives which - * use the moddir as a base directory. Otherwise, the - * current directory is undefined (but assumed to be hlds). - * - * @return 1 on success, 0 otherwise - */ -native rename_file(const oldname[], const newname[], relative = 0); - -/** - * Checks if a directory exists. - * - * @param dir Path to the directory - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to find files existing in any of - * the Valve search paths, rather than solely files - * existing directly in the gamedir. - * - * @return 1 if the directory exists, 0 otherwise - */ -native dir_exists(const dir[], bool:use_valve_fs = false); - -/** - * Get the file size in bytes. - * - * @param file Path to the file - * @param flag Flag options, see FSOPT_* constants - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to find files existing in any of - * the Valve search paths, rather than solely files - * existing directly in the gamedir. - * If used, flag option is ignored. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths - * - * @return If flag is FSOPT_BYTES_COUNT or use_valve_fs to true, the file size in bytes - * If flag is FSOPT_LINES_COUNT, the number of lines in the file - * If flag is FSOPT_END_WITH_LF, 1 is returned if file ends with line feed - * If file doesn't exist, -1 - */ -native file_size(const file[], flag = FSOPT_BYTES_COUNT, bool:use_valve_fs = false, const valve_path_id[] = "GAME"); - -/** - * Opens or creates a file, returning a file handle on success. File handles - * should be closed with fclose(). - * - * @note The open mode may be one of the following strings: - * "r": Open an existing file for reading. - * "w": Create a file for writing, or truncate (delete the contents of) an - * existing file and then open it for writing. - * "a": Create a file for writing, or open an existing file such that writes - * will be appended to the end. - * "r+": Open an existing file for both reading and writing. - * "w+": Create a file for reading and writing, or truncate an existing file - * and then open it for reading and writing. - * "a+": Create a file for both reading and writing, or open an existing file - * such that writes will be appended to the end. - * - * @note The open mode may also contain an additional character after "r", "w", or "a", - * but before any "+" sign. This character may be "b" (indicating binary mode) or - * "t" (indicating text mode). By default, "text" mode is implied. On Linux and - * Mac, this has no distinction from binary mode. On Windows, it causes the '\n' - * character (0xA) to be written as "\r\n" (0xD, 0xA). - * - * Example: "rb" opens a binary file for writing; "at" opens a text file for - * appending. - * - * @note Registered paths ID are (in priority order) : - * GAME All paths related to current mod, including fallback - * Depending settings, it includes: _lv/_addon/_/_hd - * and itself - * GAMECONFIG The default writable directory () - * GAMEDOWNLOAD The download directory (_download) - * GAME_FALLBACK All paths related to fallback game, same as GAME - * DEFAULTGAME All paths related to the default game which is "valve", same as GAME - * BASE The base path where server is installed - * - * Note that some paths are non-writable. It includes all _* (expect _download) - * and DEFAULTGAME. Any file inside a non-writable path will be ignored if you try to open - * it in writing mode. - * - * @param filename File to open - * @param mode Open mode - * @param use_valve_fs If true, the Valve file system will be used instead - * This can be used to finred files existing in valve - * search paths, rather than solely files existing directly - * in the gamedir. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths - * - * @return A file handle, or null if the file could not be opened. - */ -native fopen(const filename[], const mode[], bool:use_valve_fs = false, const valve_path_id[] = "GAME"); - -/** - * Closes a file handle. - * - * @param file File handle - */ -native fclose(file); - -/** - * Reads a single binary data from a file. - * - * @param file Handle to the file - * @param data Variable to store item read - * @param mode Size of each element, in bytes, to be read - * See BLOCK_* constants - * - * @return Number of elements read - */ -native fread(file, &any:data, mode); - -/** - * Reads binary data from a file. - * - * @param file Handle to the file - * @param data Array to store each item read - * @param blocks Number of items to read into the array - * @param mode Size of each element, in bytes, to be read - * Valid sizes are 1, 2, or 4. See BLOCK_* constants. - * - * @return Number of elements read - */ -native fread_blocks(file, any:data[], blocks, mode); - -/** - * Reads raw binary data from a file. - * - * @param file Handle to the file - * @param stream Array to store each item read - * @param blocksize Number of items to read into the array - * @param blocks Size of each element, in bytes. The data is read directly. - * That is, in 1 or 2-byte mode, the lower byte(s) in - * each cell are used directly, rather than performing - * any casts from a 4-byte number to a smaller number. - * - * @return Number of elements read - */ -native fread_raw(file, any:stream[], blocksize, blocks); - -/** - * Writes a single binary data to a file. - * - * @param file Handle to the file - * @param data Item to write - * @param mode Size of each item in the array in bytes - * Valid sizes are 1, 2, or 4. See BLOCK_* constants - * - * @return Number of elements written - */ -native fwrite(file, any:data, mode); - -/** - * Writes binary data to a file. - * - * @param file Handle to the file - * @param data Array of items to write - * @param blocks Number of items in the array - * @param mode Size of each item in the array in bytes - * Valid sizes are 1, 2, or 4. See BLOCK_* constants - * - * @return Number of elements written - */ -native fwrite_blocks(file, const any:data[], blocks, mode); - -/** - * Writes raw binary data to a file. - * - * @param file Handle to the file. - * @param stream Array of items to write. The data is written directly. - * That is, in 1 or 2-byte mode, the lower byte(s) in - * each cell are used directly, rather than performing - * any casts from a 4-byte number to a smaller number. - * @param blocks Size of each item in the array in bytes. - * @param mode Number of items in the array. - * - * @return Number of elements written - */ -native fwrite_raw(file, const any:stream[], blocks, mode); - -/** - * Tests if the end of file has been reached. - * - * @param file Handle to the file - * - * @return 1 if end of file has been reached, 0 otherwise. - */ -native feof(file); - -/** - * Reads a line from a text file. - * - * @param file Handle to the file. - * @param buffer String buffer to hold the line - * @param maxlength Maximum size of string buffer - * - * @return Total number of characters written on success, 0 otherwise - */ -native fgets(file, buffer[], maxlength); - -/** - * Writes a line of text to a text file. - * - * @param file Handle to the file - * @param text String to write - * @param null_term True to append NULL terminator, false otherwise - * - * @return 0 on success, -1 otherwise - */ -native fputs(file, const text[], bool:null_term = false); - -/** - * Writes a line of formatted text to a text file. - * - * @param file Handle to the file - * @param format Formatting rules - * @param ... Variable number of format parameters - * - * @return Total number of characters written on success, 0 otherwise - */ -native fprintf(file, const fmt[], any:...); - -/** - * Sets the file position indicator. - * - * @param file Handle to the file - * @param position Position relative to what is specified in whence - * @param start SEEK_ constant value of where to see from - * - * @return 0 on success, a non-zero value otherwise - */ -native fseek(file, position, start); - -/** - * Gets current position in the file. - * - * @param file Handle to the file - * - * @return Value for the file position indicator - */ -native ftell(file); - -/** - * Gets character from file. - * - * @param file Handle to the file - * - * @return Character read on success, -1 otherwise - */ -native fgetc(file); - -/** - * Writes character to file - * - * @param file Handle to the file - * @param data Character to put - * - * @return Character written on success, -1 otherwise - */ -native fputc(file, data); - -/** - * Ungets character from file. - * - * @param file Handle to the file - * @param data Character to unget - * - * @return On success, the character put back is returned, -1 otherwise - */ -native fungetc(file, data); - -/** - * Flushes a buffered output stream. - * - * @param file File handle, or 0 for all open streams - * - * @return 0 on success, -1 on failure - */ -native fflush(file); - -/** - * Gets the formatted file size in bytes. - * - * @param filename Path to the file - * @param ... Variable number of format parameters - * - * @return File size in bytes, otherwise -1 if file not found - */ -native filesize(const filename[], any:...); - -/** - * Removes a directory. - * - * @note On most Operating Systems you cannot remove a directory which has files inside it. - * - * @param path Path to the directory - * - * @return 1 on success, 0 otherwise - */ -native rmdir(const path[]); - -/** - * Creates a directory. - * - * @param path Path to create - * @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have - * the execute bit set on Linux. On Windows, the mode is ignored. - * @param use_valve_fs If true, the Valve file system will be used instead - * This can be used to create folders in the game's - * Valve search paths, rather than directly in the gamedir. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default - * In this case, mode is ignored - * - * @return 0 on success, -1 otherwise - */ -native mkdir(const dirname[], mode = FPERM_DIR_DEFAULT, bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); - -/** - * Deletes a file (delete_file macro) - * - * @param filename Path of the file to delete - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to delete files existing in the Valve - * search path, rather than solely files existing directly - * in the gamedir. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths - * - * @return 1 on success, 0 on failure or if file not immediately removed - */ -native unlink(const filename[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); - -/** - * Opens a directory/folder for contents enumeration. - * - * @note Directories are closed with close_dir(). - * - * @param dir Path to open. - * @param firstfile String buffer to hold first file name - * @param length Maximum size of the string buffer - * @param type Optional variable to store the file type - * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to find files existing in any of - * the Valve search paths, rather than solely files - * existing directly in the gamedir. - * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. - * - * @return Handle to the directory, 0 otherwise - */ -native open_dir(dir[], firstfile[], length, &FileType:type = FileType_Unknown, bool:use_valve_fs = false, const valve_path_id[] = "GAME"); - -/** - * Reads the next directory entry as a local filename. - * - * @note Contents of buffers are undefined when returning false. - * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux. - * - * @param dirh Handle to a directory - * @param buffer String buffer to hold directory name - * @param length Maximum size of string buffer - * @param type Optional variable to store the file type. FileType_* constants - * - * @return 1 on success, 0 if there are no more files to read. - */ -native next_file(dirh, buffer[], length, &FileType:type = FileType_Unknown); - -/** - * Closes the directory. - * - * @param dirh Handle to a directory - */ -native close_dir(dirh); - -/** - * Loads a file using the LoadFileForMe engine function. - * - * The data is truncated if there is not enough space. No null-terminator - * is applied; the data is the raw contents of the file. - * - * @param file File to load (may be a file from the GCF) - * @param buffer Buffer to store file contents - * @param maxlength Maximum size of the file buffer - * @param length Variable to store the file length. This may return - * a number larger than the buffer size - * @return -1 if the file could not be loaded. Otherwise, - * the number of cells actually written to the buffer - * are returned. - */ -native LoadFileForMe(const file[], buffer[], maxlength, &length = 0); - -/** - * Returns a file timestamp as a unix timestamp. - * - * @param file File name - * @param tmode Time mode, see FileTime_* constants - * - * @return Returns a file timestamp as a unix timestamp - */ -native GetFileTime(const file[], FileTimeType:tmode); - -/** - * Changes a file or directories permissions. - * - * @param path Path to the file - * @param mode Permissions to set, see FPERM_* constants - * - * @return True on success, false otherwise - */ -native bool:SetFilePermissions(const path[], mode); - -/** - * Reads a single int8 (byte) from a file. The returned value is sign- - * extended to an int32. - * - * @param file Handle to the file - * @param data Variable to store the data read - * - * @return True on success, false on failure - */ -native bool:FileReadInt8(file, &any:data); - -/** - * Reads a single uint8 (unsigned byte) from a file. The returned value is - * zero-extended to an int32. - * - * @param file Handle to the file - * @param data Variable to store the data read - * - * @return True on success, false on failure - */ -native bool:FileReadUint8(file, &any:data); - -/** - * Reads a single int16 (short) from a file. The value is sign-extended to - * an int32. - * - * @param file Handle to the file - * @param data Variable to store the data read - * - * @return True on success, false on failure - */ -native bool:FileReadInt16(file, &any:data); - -/** - * Reads a single unt16 (unsigned short) from a file. The value is zero- - * extended to an int32. - * - * @param file Handle to the file - * @param data Variable to store the data read - * - * @return True on success, false on failure - */ -native bool:FileReadUint16(file, &any:data); - -/** - * Reads a single int32 (int/cell) from a file. - * - * @param file Handle to the file - * @param data Variable to store the data read - * - * @return True on success, false on failure - */ -native bool:FileReadInt32(file, &any:data); - -/** - * Writes a single int8 (byte) to a file. - * - * @param file Handle to the file - * @param data Data to write (truncated to an int8) - * - * @return True on success, false on failure - */ -native bool:FileWriteInt8(file, any:data); - -/** - * Writes a single int16 (short) to a file. - * - * @param file Handle to the file - * @param data Data to write (truncated to an int16) - * - * @return True on success, false on failure - */ -native bool:FileWriteInt16(file, any:data); - -/** - * Writes a single int32 (int/cell) to a file. - * - * @param file Handle to the file - * @param data Data to write - * - * @return True on success, false on failure - */ -native bool:FileWriteInt32(file, any:data); - +// vim: set ts=4 sw=4 tw=99 noet: +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// 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 + +// +// File Functions +// + +#if defined _file_included + #endinput +#endif +#define _file_included + +/** + * @note All paths in AMX Mod X natives are relative to the mod folder + * unless otherwise noted. + * + * Most functions in AMX Mod X (at least, ones that deal with direct + * file manipulation) will support an alternate path specification. + */ + +/** + * Maximum path length. + */ +#define PLATFORM_MAX_PATH 256 + +/** + * File inode types for use with open_dir() and next_file(). + */ +enum FileType +{ + FileType_Unknown, /* Unknown file type (device/socket) */ + FileType_Directory, /* File is a directory */ + FileType_File, /* File is a file */ +}; + +/** + * File time modes for use with GetFileTime(). + */ +enum FileTimeType +{ + FileTime_LastAccess, /* Last access (not available on FAT) */ + FileTime_Created, /* Creation (not available on FAT) */ + FileTime_LastChange, /* Last modification */ +}; + +/** + * File position modes for use with fseek(). + */ +#define SEEK_SET 0 /* Seek from start */ +#define SEEK_CUR 1 /* Seek from current position */ +#define SEEK_END 2 /* Seek from end position */ + +/** + * Options for use with file_size() flag parameter. + */ +#define FSOPT_BYTES_COUNT 0 /* Returns the file size in number of bytes */ +#define FSOPT_LINES_COUNT 1 /* Returns how many lines there are in this file */ +#define FSOPT_END_WITH_LF 2 /* Returns whether the last line is '\n' */ + +/** + * Data block modes for use with fread*() and fwrite*(). + */ +#define BLOCK_INT 4 +#define BLOCK_SHORT 2 +#define BLOCK_CHAR 1 +#define BLOCK_BYTE 1 + +/** + * File permissions flags for use with mkdir() and SetFilePermissions(). + */ +#define FPERM_U_READ 0x0100 /* User can read. */ +#define FPERM_U_WRITE 0x0080 /* User can write. */ +#define FPERM_U_EXEC 0x0040 /* User can exec. */ +#define FPERM_U_RWX FPERM_U_READ | FPERM_U_WRITE | FPERM_U_EXEC + +#define FPERM_G_READ 0x0020 /* Group can read. */ +#define FPERM_G_WRITE 0x0010 /* Group can write. */ +#define FPERM_G_EXEC 0x0008 /* Group can exec. */ +#define FPERM_G_RWX FPERM_G_READ | FPERM_G_WRITE | FPERM_G_EXEC + +#define FPERM_O_READ 0x0004 /* Anyone can read. */ +#define FPERM_O_WRITE 0x0002 /* Anyone can write. */ +#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */ +#define FPERM_O_RWX FPERM_O_READ | FPERM_O_WRITE | FPERM_O_EXEC + +#define FPERM_DIR_DEFAULT FPERM_U_RWX | FPERM_G_RWX | FPERM_O_RWX /* rwx r-x r-x (0755) */ + + +/** + * Reads content from directory + * + * @note This native is expensive. Consider the use of open_dir(), next_file() and close_dir() instead. + * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux. + * + * @param dirname Path to open + * @param pos Index the element + * @param output String buffer to hold content + * @param len Maximum size of string buffer + * @param outlen Number of characters written to the buffer + * + * @return Returns index of next element, otherwiwe 0 when end of dir is reached + */ +native read_dir(const dirname[], pos, output[], len, &outlen = 0); + +/** + * Reads line from file. + * + * @note This native is expensive. Consider the use of new file natives (fopen(), fgets(), etc.) + * if purpose is to read several lines of a file. + * + * @param file Path to open + * @param line Index of the line, starting to 0 + * @param text String buffer to hold line read + * @param len Maximum size of string buffer + * @param txtlen Number of characters written to the buffer + * + * @return Returns index of next line, otherwise 0 when end of file is reached + * @error Unable to read the file + */ +native read_file(const file[], line, text[], len, &txtlen = 0); + +/** + * Writes text to file. + * + * @note This native is expensive. Consider the use of new file natives (fopen(), fputs(), etc.) + * if purpose is to write several lines of a file. + * + * @param file Path to open + * @param text String to write to + * @param line Index of the line, starting to 0 + * If < 0, content will be appended + * + * @noreturn + * @error Unable to write [temporary] file + */ +native write_file(const file[], const text[], line = -1); + +/** + * Deletes a file. + * + * @param file Path of the file to delete + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to delete files existing in the Valve + * search path, rather than solely files existing directly + * in the gamedir. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. + * + * @return 1 on success, 0 on failure or if file not immediately removed. + */ +native delete_file(const file[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); + +/** + * Checks if a file exists. + * + * @param file Path to the file + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to find files existing in any of + * the Valve search paths, rather than solely files + * existing directly in the gamedir. + * + * @return 1 if the file exists, 0 otherwise + */ +native file_exists(const file[], bool:use_valve_fs = false); + +/** + * Renames a file. + * + * @param oldname New path to the file + * @param newname Path to the existing file + * @param relative If true, native will act like other natives which + * use the moddir as a base directory. Otherwise, the + * current directory is undefined (but assumed to be hlds). + * + * @return 1 on success, 0 otherwise + */ +native rename_file(const oldname[], const newname[], relative = 0); + +/** + * Checks if a directory exists. + * + * @param dir Path to the directory + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to find files existing in any of + * the Valve search paths, rather than solely files + * existing directly in the gamedir. + * + * @return 1 if the directory exists, 0 otherwise + */ +native dir_exists(const dir[], bool:use_valve_fs = false); + +/** + * Get the file size in bytes. + * + * @param file Path to the file + * @param flag Flag options, see FSOPT_* constants + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to find files existing in any of + * the Valve search paths, rather than solely files + * existing directly in the gamedir. + * If used, flag option is ignored. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths + * + * @return If flag is FSOPT_BYTES_COUNT or use_valve_fs to true, the file size in bytes + * If flag is FSOPT_LINES_COUNT, the number of lines in the file + * If flag is FSOPT_END_WITH_LF, 1 is returned if file ends with line feed + * If file doesn't exist, -1 + */ +native file_size(const file[], flag = FSOPT_BYTES_COUNT, bool:use_valve_fs = false, const valve_path_id[] = "GAME"); + +/** + * Opens or creates a file, returning a file handle on success. File handles + * should be closed with fclose(). + * + * @note The open mode may be one of the following strings: + * "r": Open an existing file for reading. + * "w": Create a file for writing, or truncate (delete the contents of) an + * existing file and then open it for writing. + * "a": Create a file for writing, or open an existing file such that writes + * will be appended to the end. + * "r+": Open an existing file for both reading and writing. + * "w+": Create a file for reading and writing, or truncate an existing file + * and then open it for reading and writing. + * "a+": Create a file for both reading and writing, or open an existing file + * such that writes will be appended to the end. + * + * @note The open mode may also contain an additional character after "r", "w", or "a", + * but before any "+" sign. This character may be "b" (indicating binary mode) or + * "t" (indicating text mode). By default, "text" mode is implied. On Linux and + * Mac, this has no distinction from binary mode. On Windows, it causes the '\n' + * character (0xA) to be written as "\r\n" (0xD, 0xA). + * + * Example: "rb" opens a binary file for writing; "at" opens a text file for + * appending. + * + * @note Registered paths ID are (in priority order) : + * GAME All paths related to current mod, including fallback + * Depending settings, it includes: _lv/_addon/_/_hd + * and itself + * GAMECONFIG The default writable directory () + * GAMEDOWNLOAD The download directory (_download) + * GAME_FALLBACK All paths related to fallback game, same as GAME + * DEFAULTGAME All paths related to the default game which is "valve", same as GAME + * BASE The base path where server is installed + * + * Note that some paths are non-writable. It includes all _* (expect _download) + * and DEFAULTGAME. Any file inside a non-writable path will be ignored if you try to open + * it in writing mode. + * + * @param filename File to open + * @param mode Open mode + * @param use_valve_fs If true, the Valve file system will be used instead + * This can be used to finred files existing in valve + * search paths, rather than solely files existing directly + * in the gamedir. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths + * + * @return A file handle, or null if the file could not be opened. + */ +native fopen(const filename[], const mode[], bool:use_valve_fs = false, const valve_path_id[] = "GAME"); + +/** + * Closes a file handle. + * + * @param file File handle + */ +native fclose(file); + +/** + * Reads a single binary data from a file. + * + * @param file Handle to the file + * @param data Variable to store item read + * @param mode Size of each element, in bytes, to be read + * See BLOCK_* constants + * + * @return Number of elements read + */ +native fread(file, &any:data, mode); + +/** + * Reads binary data from a file. + * + * @param file Handle to the file + * @param data Array to store each item read + * @param blocks Number of items to read into the array + * @param mode Size of each element, in bytes, to be read + * Valid sizes are 1, 2, or 4. See BLOCK_* constants. + * + * @return Number of elements read + */ +native fread_blocks(file, any:data[], blocks, mode); + +/** + * Reads raw binary data from a file. + * + * @param file Handle to the file + * @param stream Array to store each item read + * @param blocksize Number of items to read into the array + * @param blocks Size of each element, in bytes. The data is read directly. + * That is, in 1 or 2-byte mode, the lower byte(s) in + * each cell are used directly, rather than performing + * any casts from a 4-byte number to a smaller number. + * + * @return Number of elements read + */ +native fread_raw(file, any:stream[], blocksize, blocks); + +/** + * Writes a single binary data to a file. + * + * @param file Handle to the file + * @param data Item to write + * @param mode Size of each item in the array in bytes + * Valid sizes are 1, 2, or 4. See BLOCK_* constants + * + * @return Number of elements written + */ +native fwrite(file, any:data, mode); + +/** + * Writes binary data to a file. + * + * @param file Handle to the file + * @param data Array of items to write + * @param blocks Number of items in the array + * @param mode Size of each item in the array in bytes + * Valid sizes are 1, 2, or 4. See BLOCK_* constants + * + * @return Number of elements written + */ +native fwrite_blocks(file, const any:data[], blocks, mode); + +/** + * Writes raw binary data to a file. + * + * @param file Handle to the file. + * @param stream Array of items to write. The data is written directly. + * That is, in 1 or 2-byte mode, the lower byte(s) in + * each cell are used directly, rather than performing + * any casts from a 4-byte number to a smaller number. + * @param blocks Size of each item in the array in bytes. + * @param mode Number of items in the array. + * + * @return Number of elements written + */ +native fwrite_raw(file, const any:stream[], blocks, mode); + +/** + * Tests if the end of file has been reached. + * + * @param file Handle to the file + * + * @return 1 if end of file has been reached, 0 otherwise. + */ +native feof(file); + +/** + * Reads a line from a text file. + * + * @param file Handle to the file. + * @param buffer String buffer to hold the line + * @param maxlength Maximum size of string buffer + * + * @return Total number of characters written on success, 0 otherwise + */ +native fgets(file, buffer[], maxlength); + +/** + * Writes a line of text to a text file. + * + * @param file Handle to the file + * @param text String to write + * @param null_term True to append NULL terminator, false otherwise + * + * @return 0 on success, -1 otherwise + */ +native fputs(file, const text[], bool:null_term = false); + +/** + * Writes a line of formatted text to a text file. + * + * @param file Handle to the file + * @param format Formatting rules + * @param ... Variable number of format parameters + * + * @return Total number of characters written on success, 0 otherwise + */ +native fprintf(file, const fmt[], any:...); + +/** + * Sets the file position indicator. + * + * @param file Handle to the file + * @param position Position relative to what is specified in whence + * @param start SEEK_ constant value of where to see from + * + * @return 0 on success, a non-zero value otherwise + */ +native fseek(file, position, start); + +/** + * Gets current position in the file. + * + * @param file Handle to the file + * + * @return Value for the file position indicator + */ +native ftell(file); + +/** + * Gets character from file. + * + * @param file Handle to the file + * + * @return Character read on success, -1 otherwise + */ +native fgetc(file); + +/** + * Writes character to file + * + * @param file Handle to the file + * @param data Character to put + * + * @return Character written on success, -1 otherwise + */ +native fputc(file, data); + +/** + * Ungets character from file. + * + * @param file Handle to the file + * @param data Character to unget + * + * @return On success, the character put back is returned, -1 otherwise + */ +native fungetc(file, data); + +/** + * Flushes a buffered output stream. + * + * @param file File handle, or 0 for all open streams + * + * @return 0 on success, -1 on failure + */ +native fflush(file); + +/** + * Gets the formatted file size in bytes. + * + * @param filename Path to the file + * @param ... Variable number of format parameters + * + * @return File size in bytes, otherwise -1 if file not found + */ +native filesize(const filename[], any:...); + +/** + * Removes a directory. + * + * @note On most Operating Systems you cannot remove a directory which has files inside it. + * + * @param path Path to the directory + * + * @return 1 on success, 0 otherwise + */ +native rmdir(const path[]); + +/** + * Creates a directory. + * + * @param path Path to create + * @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have + * the execute bit set on Linux. On Windows, the mode is ignored. + * @param use_valve_fs If true, the Valve file system will be used instead + * This can be used to create folders in the game's + * Valve search paths, rather than directly in the gamedir. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default + * In this case, mode is ignored + * + * @return 0 on success, -1 otherwise + */ +native mkdir(const dirname[], mode = FPERM_DIR_DEFAULT, bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); + +/** + * Deletes a file (delete_file macro) + * + * @param filename Path of the file to delete + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to delete files existing in the Valve + * search path, rather than solely files existing directly + * in the gamedir. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths + * + * @return 1 on success, 0 on failure or if file not immediately removed + */ +native unlink(const filename[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG"); + +/** + * Opens a directory/folder for contents enumeration. + * + * @note Directories are closed with close_dir(). + * + * @param dir Path to open. + * @param firstfile String buffer to hold first file name + * @param length Maximum size of the string buffer + * @param type Optional variable to store the file type + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to find files existing in any of + * the Valve search paths, rather than solely files + * existing directly in the gamedir. + * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. + * + * @return Handle to the directory, 0 otherwise + */ +native open_dir(dir[], firstfile[], length, &FileType:type = FileType_Unknown, bool:use_valve_fs = false, const valve_path_id[] = "GAME"); + +/** + * Reads the next directory entry as a local filename. + * + * @note Contents of buffers are undefined when returning false. + * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux. + * + * @param dirh Handle to a directory + * @param buffer String buffer to hold directory name + * @param length Maximum size of string buffer + * @param type Optional variable to store the file type. FileType_* constants + * + * @return 1 on success, 0 if there are no more files to read. + */ +native next_file(dirh, buffer[], length, &FileType:type = FileType_Unknown); + +/** + * Closes the directory. + * + * @param dirh Handle to a directory + */ +native close_dir(dirh); + +/** + * Loads a file using the LoadFileForMe engine function. + * + * The data is truncated if there is not enough space. No null-terminator + * is applied; the data is the raw contents of the file. + * + * @param file File to load (may be a file from the GCF) + * @param buffer Buffer to store file contents + * @param maxlength Maximum size of the file buffer + * @param length Variable to store the file length. This may return + * a number larger than the buffer size + * @return -1 if the file could not be loaded. Otherwise, + * the number of cells actually written to the buffer + * are returned. + */ +native LoadFileForMe(const file[], buffer[], maxlength, &length = 0); + +/** + * Returns a file timestamp as a unix timestamp. + * + * @param file File name + * @param tmode Time mode, see FileTime_* constants + * + * @return Returns a file timestamp as a unix timestamp + */ +native GetFileTime(const file[], FileTimeType:tmode); + +/** + * Changes a file or directories permissions. + * + * @param path Path to the file + * @param mode Permissions to set, see FPERM_* constants + * + * @return True on success, false otherwise + */ +native bool:SetFilePermissions(const path[], mode); + +/** + * Reads a single int8 (byte) from a file. The returned value is sign- + * extended to an int32. + * + * @param file Handle to the file + * @param data Variable to store the data read + * + * @return True on success, false on failure + */ +native bool:FileReadInt8(file, &any:data); + +/** + * Reads a single uint8 (unsigned byte) from a file. The returned value is + * zero-extended to an int32. + * + * @param file Handle to the file + * @param data Variable to store the data read + * + * @return True on success, false on failure + */ +native bool:FileReadUint8(file, &any:data); + +/** + * Reads a single int16 (short) from a file. The value is sign-extended to + * an int32. + * + * @param file Handle to the file + * @param data Variable to store the data read + * + * @return True on success, false on failure + */ +native bool:FileReadInt16(file, &any:data); + +/** + * Reads a single unt16 (unsigned short) from a file. The value is zero- + * extended to an int32. + * + * @param file Handle to the file + * @param data Variable to store the data read + * + * @return True on success, false on failure + */ +native bool:FileReadUint16(file, &any:data); + +/** + * Reads a single int32 (int/cell) from a file. + * + * @param file Handle to the file + * @param data Variable to store the data read + * + * @return True on success, false on failure + */ +native bool:FileReadInt32(file, &any:data); + +/** + * Writes a single int8 (byte) to a file. + * + * @param file Handle to the file + * @param data Data to write (truncated to an int8) + * + * @return True on success, false on failure + */ +native bool:FileWriteInt8(file, any:data); + +/** + * Writes a single int16 (short) to a file. + * + * @param file Handle to the file + * @param data Data to write (truncated to an int16) + * + * @return True on success, false on failure + */ +native bool:FileWriteInt16(file, any:data); + +/** + * Writes a single int32 (int/cell) to a file. + * + * @param file Handle to the file + * @param data Data to write + * + * @return True on success, false on failure + */ +native bool:FileWriteInt32(file, any:data); + diff --git a/plugins/include/float.inc b/plugins/include/float.inc index 72c8f1a3..a731ffb6 100755 --- a/plugins/include/float.inc +++ b/plugins/include/float.inc @@ -1,422 +1,422 @@ -/* Float arithmetic -* -* (c) Copyright 1999, Artran, Inc. -* Written by Greg Garner (gmg@artran.com) -* Modified in March 2001 to include user defined -* operators for the floating point functions. -* -* This file is provided as is (no warranties). -*/ - -#if defined _float_included - #endinput -#endif -#define _float_included - -#pragma rational Float - -/** - * Different methods of rounding - */ -enum floatround_method { - floatround_round = 0, - floatround_floor, - floatround_ceil, - floatround_tozero -}; - -/** - * Different units of measurement for angles - */ -enum anglemode { - radian = 0, - degrees, - grades -}; - -/** - * Converts an integer into a floating point value. - * - * @param value Value to be converted - * - * @return Converted value - */ -native Float:float(value); - -/** - * Converts a string into a floating point value. - * - * @param string Input string to be converted - * - * @return Converted value - */ -native Float:floatstr(const string[]); - -/** - * Returns the fractional part of a floating point value - * - * @param string Floating point value to get the fractional part from - * - * @return The fractional part - */ -native Float:floatfract(Float:value); - -/** - * Rounds a floating point value to an integer value - * - * @note For the list of available rounding methods look at - * floatround_method enumeration. - * - * @param value Floating point value to be rounded - * @param method Rounding method - * - * @return Converted value - */ -native floatround(Float:value, floatround_method:method=floatround_round); - -/** - * Compares two floating point values. - * - * @param fOne First value to be compared - * @param fTwo Second value to be compared - * - * @return If arguments are equal, returns 0. - * If the first one is greater, returns 1. - * If the second one is greater, returns -1. - */ -native floatcmp(Float:fOne, Float:fTwo); - -/** - * Returns the square root of a floating point value - * - * @note Same as floatpower(value, 0.5) - * - * @param value Floating point value to get square root from - * - * @return Square root of the input value - */ -native Float:floatsqroot(Float:value); - -/** - * Returns the value raised to the power of the exponent - * - * @param value Floating point value to be raised - * @param exponent The exponent - * - * @return Value raised to the power of the exponent - */ -native Float:floatpower(Float:value, Float:exponent); - -/** - * Returns the logarithm of value - * - * @param value Floating point value to calculate the logarithm for - * @param base The optional logarithmic base to use. - * Defaults to 10, or the natural logarithm - * - * @return Square root of the input value - */ -native Float:floatlog(Float:value, Float:base=10.0); - -/** - * Returns the sine of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the sine from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The sine of a given angle - */ -native Float:floatsin(Float:value, anglemode:mode=radian); - -/** - * Returns the cosine of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the cosine from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The cosine of a given angle - */ -native Float:floatcos(Float:value, anglemode:mode=radian); - -/** - * Returns the tangent of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the tangent from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The tangent of a given angle - */ -native Float:floattan(Float:value, anglemode:mode=radian); - -/** - * Returns the hyperbolic sine of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the hyperbolic sine from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The hyperbolic sine of a given angle - */ -native Float:floatsinh(Float:angle, anglemode:mode=radian); - -/** - * Returns the hyperbolic cosine of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the hyperbolic cosine from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The hyperbolic cosine of a given angle - */ -native Float:floatcosh(Float:angle, anglemode:mode=radian); - -/** - * Returns the hyperbolic tangent of a given angle - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The angle to calculate the hyperbolic tangent from - * @param mode What unit of measurement is the angle specified in - * Defaults to radians - * - * @return The hyperbolic tangent of a given angle - */ -native Float:floattanh(Float:angle, anglemode:mode=radian); - -/** - * Returns the absolute value of a floating point value - * - * @param value The floating point value to get the absolute value from - * - * @return The absolute value - */ -native Float:floatabs(Float:value); - -/* Return the angle of a sine, cosine or tangent. - * The output angle may be in radians, degrees, or grades. */ - -/** - * Returns the angle of the given tangent - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The tangent to calculate the angle from - * @param mode What unit of measurement should the output angle be in - * - * @return The angle of a tangent - */ -native Float:floatatan(Float:angle, {anglemode,_}:radix); - -/** - * Returns the angle of the given cosine - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The cosine to calculate the angle from - * @param mode What unit of measurement should the output angle be in - * - * @return The angle of a cosine - */ -native Float:floatacos(Float:angle, {anglemode,_}:radix); - -/** - * Returns the angle of the given sine - * - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param value The sine to calculate the angle from - * @param mode What unit of measurement should the output angle be in - * - * @return The angle of a sine - */ -native Float:floatasin(Float:angle, {anglemode,_}:radix); - -/** - * Computes the principal value of arctangent of y/x - * - * @note Someone should verify this native, not sure what it actually does. - * @note For available units of measurements(modes) look at the anglemode enum - * - * @param x Value representing the proportion of the x-coordinate. - * @param y Value representing the proportion of the x-coordinate. - * @param mode What unit of measurement should the output angle be in - * - * @return Arctangent of y/x - */ -native Float:floatatan2(Float:x, Float:y, {anglemode,_}:radix); - - - -/* Multiply two floats together */ -native Float:floatmul(Float:oper1, Float:oper2); - -/* Divide the dividend float by the divisor float */ -native Float:floatdiv(Float:dividend, Float:divisor); - -/* Add two floats together */ -native Float:floatadd(Float:dividend, Float:divisor); - -/* Subtract oper2 float from oper1 float */ -native Float:floatsub(Float:oper1, Float:oper2); - -/* user defined operators */ -native Float:operator*(Float:oper1, Float:oper2) = floatmul; -native Float:operator/(Float:oper1, Float:oper2) = floatdiv; -native Float:operator+(Float:oper1, Float:oper2) = floatadd; -native Float:operator-(Float:oper1, Float:oper2) = floatsub; - -stock Float:operator++(Float:oper) - return oper+1.0; - -stock Float:operator--(Float:oper) - return oper-1.0; - -stock Float:operator-(Float:oper) - return oper^Float:cellmin; /* IEEE values are sign/magnitude */ - -stock Float:operator*(Float:oper1, oper2) - return floatmul(oper1, float(oper2)); /* "*" is commutative */ - -stock Float:operator/(Float:oper1, oper2) - return floatdiv(oper1, float(oper2)); - -stock Float:operator/(oper1, Float:oper2) - return floatdiv(float(oper1), oper2); - -stock Float:operator+(Float:oper1, oper2) - return floatadd(oper1, float(oper2)); /* "+" is commutative */ - -stock Float:operator-(Float:oper1, oper2) - return floatsub(oper1, float(oper2)); - -stock Float:operator-(oper1, Float:oper2) - return floatsub(float(oper1), oper2); - -stock bool:operator==(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) == 0; - -stock bool:operator==(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */ - -stock bool:operator!=(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) != 0; - -stock bool:operator!=(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) != 0; /* "==" is commutative */ - -stock bool:operator>(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) > 0; - -stock bool:operator>(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) > 0; - -stock bool:operator>(oper1, Float:oper2) - return floatcmp(float(oper1), oper2) > 0; - -stock bool:operator>=(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) >= 0; - -stock bool:operator>=(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) >= 0; - -stock bool:operator>=(oper1, Float:oper2) - return floatcmp(float(oper1), oper2) >= 0; - -stock bool:operator<(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) < 0; - -stock bool:operator<(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) < 0; - -stock bool:operator<(oper1, Float:oper2) - return floatcmp(float(oper1), oper2) < 0; - -stock bool:operator<=(Float:oper1, Float:oper2) - return floatcmp(oper1, oper2) <= 0; - -stock bool:operator<=(Float:oper1, oper2) - return floatcmp(oper1, float(oper2)) <= 0; - -stock bool:operator<=(oper1, Float:oper2) - return floatcmp(float(oper1), oper2) <= 0; - -stock bool:operator!(Float:oper) - return (_:oper & ((-1)/2)) == 0; /* -1 = all bits to 1; /2 = remove most significant bit (sign) - works on both 32bit and 64bit systems; no constant required */ -/* forbidden operations */ -forward operator%(Float:oper1, Float:oper2); -forward operator%(Float:oper1, oper2); -forward operator%(oper1, Float:oper2); - - -/** - * Returns whichever value is the smaller one - * - * @param ValueA The first value - * @param ValueB The second value - * - * @return ValueA if it is smaller than ValueB, and vice versa - */ -stock Float:floatmin(Float:ValueA, Float:ValueB) -{ - if (ValueA<=ValueB) - { - return ValueA; - } - - return ValueB; -} - -/** - * Returns whichever value is the greater one - * - * @param ValueA The first value - * @param ValueB The second value - * - * @return ValueA if it is greater than ValueB, and vice versa - */ -stock Float:floatmax(Float:ValueA, Float:ValueB) -{ - if (ValueA>=ValueB) - { - return ValueA; - } - - return ValueB; -} - -/** - * Clamps a value between a minimum and a maximum floating point value - * - * @param Value The value to be clamped - * @param MinValue Minimum value - * @param MaxValue Maximum value - * - * @return The Value clamped between MinValue and MaxValue - */ -stock Float:floatclamp(Float:Value, Float:MinValue, Float:MaxValue) -{ - if (Value<=MinValue) - { - return MinValue; - } - if (Value>=MaxValue) - { - return MaxValue; - } - - return Value; +/* Float arithmetic +* +* (c) Copyright 1999, Artran, Inc. +* Written by Greg Garner (gmg@artran.com) +* Modified in March 2001 to include user defined +* operators for the floating point functions. +* +* This file is provided as is (no warranties). +*/ + +#if defined _float_included + #endinput +#endif +#define _float_included + +#pragma rational Float + +/** + * Different methods of rounding + */ +enum floatround_method { + floatround_round = 0, + floatround_floor, + floatround_ceil, + floatround_tozero +}; + +/** + * Different units of measurement for angles + */ +enum anglemode { + radian = 0, + degrees, + grades +}; + +/** + * Converts an integer into a floating point value. + * + * @param value Value to be converted + * + * @return Converted value + */ +native Float:float(value); + +/** + * Converts a string into a floating point value. + * + * @param string Input string to be converted + * + * @return Converted value + */ +native Float:floatstr(const string[]); + +/** + * Returns the fractional part of a floating point value + * + * @param string Floating point value to get the fractional part from + * + * @return The fractional part + */ +native Float:floatfract(Float:value); + +/** + * Rounds a floating point value to an integer value + * + * @note For the list of available rounding methods look at + * floatround_method enumeration. + * + * @param value Floating point value to be rounded + * @param method Rounding method + * + * @return Converted value + */ +native floatround(Float:value, floatround_method:method=floatround_round); + +/** + * Compares two floating point values. + * + * @param fOne First value to be compared + * @param fTwo Second value to be compared + * + * @return If arguments are equal, returns 0. + * If the first one is greater, returns 1. + * If the second one is greater, returns -1. + */ +native floatcmp(Float:fOne, Float:fTwo); + +/** + * Returns the square root of a floating point value + * + * @note Same as floatpower(value, 0.5) + * + * @param value Floating point value to get square root from + * + * @return Square root of the input value + */ +native Float:floatsqroot(Float:value); + +/** + * Returns the value raised to the power of the exponent + * + * @param value Floating point value to be raised + * @param exponent The exponent + * + * @return Value raised to the power of the exponent + */ +native Float:floatpower(Float:value, Float:exponent); + +/** + * Returns the logarithm of value + * + * @param value Floating point value to calculate the logarithm for + * @param base The optional logarithmic base to use. + * Defaults to 10, or the natural logarithm + * + * @return Square root of the input value + */ +native Float:floatlog(Float:value, Float:base=10.0); + +/** + * Returns the sine of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the sine from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The sine of a given angle + */ +native Float:floatsin(Float:value, anglemode:mode=radian); + +/** + * Returns the cosine of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the cosine from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The cosine of a given angle + */ +native Float:floatcos(Float:value, anglemode:mode=radian); + +/** + * Returns the tangent of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the tangent from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The tangent of a given angle + */ +native Float:floattan(Float:value, anglemode:mode=radian); + +/** + * Returns the hyperbolic sine of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the hyperbolic sine from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The hyperbolic sine of a given angle + */ +native Float:floatsinh(Float:angle, anglemode:mode=radian); + +/** + * Returns the hyperbolic cosine of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the hyperbolic cosine from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The hyperbolic cosine of a given angle + */ +native Float:floatcosh(Float:angle, anglemode:mode=radian); + +/** + * Returns the hyperbolic tangent of a given angle + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The angle to calculate the hyperbolic tangent from + * @param mode What unit of measurement is the angle specified in + * Defaults to radians + * + * @return The hyperbolic tangent of a given angle + */ +native Float:floattanh(Float:angle, anglemode:mode=radian); + +/** + * Returns the absolute value of a floating point value + * + * @param value The floating point value to get the absolute value from + * + * @return The absolute value + */ +native Float:floatabs(Float:value); + +/* Return the angle of a sine, cosine or tangent. + * The output angle may be in radians, degrees, or grades. */ + +/** + * Returns the angle of the given tangent + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The tangent to calculate the angle from + * @param mode What unit of measurement should the output angle be in + * + * @return The angle of a tangent + */ +native Float:floatatan(Float:angle, {anglemode,_}:radix); + +/** + * Returns the angle of the given cosine + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The cosine to calculate the angle from + * @param mode What unit of measurement should the output angle be in + * + * @return The angle of a cosine + */ +native Float:floatacos(Float:angle, {anglemode,_}:radix); + +/** + * Returns the angle of the given sine + * + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param value The sine to calculate the angle from + * @param mode What unit of measurement should the output angle be in + * + * @return The angle of a sine + */ +native Float:floatasin(Float:angle, {anglemode,_}:radix); + +/** + * Computes the principal value of arctangent of y/x + * + * @note Someone should verify this native, not sure what it actually does. + * @note For available units of measurements(modes) look at the anglemode enum + * + * @param x Value representing the proportion of the x-coordinate. + * @param y Value representing the proportion of the x-coordinate. + * @param mode What unit of measurement should the output angle be in + * + * @return Arctangent of y/x + */ +native Float:floatatan2(Float:x, Float:y, {anglemode,_}:radix); + + + +/* Multiply two floats together */ +native Float:floatmul(Float:oper1, Float:oper2); + +/* Divide the dividend float by the divisor float */ +native Float:floatdiv(Float:dividend, Float:divisor); + +/* Add two floats together */ +native Float:floatadd(Float:dividend, Float:divisor); + +/* Subtract oper2 float from oper1 float */ +native Float:floatsub(Float:oper1, Float:oper2); + +/* user defined operators */ +native Float:operator*(Float:oper1, Float:oper2) = floatmul; +native Float:operator/(Float:oper1, Float:oper2) = floatdiv; +native Float:operator+(Float:oper1, Float:oper2) = floatadd; +native Float:operator-(Float:oper1, Float:oper2) = floatsub; + +stock Float:operator++(Float:oper) + return oper+1.0; + +stock Float:operator--(Float:oper) + return oper-1.0; + +stock Float:operator-(Float:oper) + return oper^Float:cellmin; /* IEEE values are sign/magnitude */ + +stock Float:operator*(Float:oper1, oper2) + return floatmul(oper1, float(oper2)); /* "*" is commutative */ + +stock Float:operator/(Float:oper1, oper2) + return floatdiv(oper1, float(oper2)); + +stock Float:operator/(oper1, Float:oper2) + return floatdiv(float(oper1), oper2); + +stock Float:operator+(Float:oper1, oper2) + return floatadd(oper1, float(oper2)); /* "+" is commutative */ + +stock Float:operator-(Float:oper1, oper2) + return floatsub(oper1, float(oper2)); + +stock Float:operator-(oper1, Float:oper2) + return floatsub(float(oper1), oper2); + +stock bool:operator==(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) == 0; + +stock bool:operator==(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */ + +stock bool:operator!=(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) != 0; + +stock bool:operator!=(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) != 0; /* "==" is commutative */ + +stock bool:operator>(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) > 0; + +stock bool:operator>(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) > 0; + +stock bool:operator>(oper1, Float:oper2) + return floatcmp(float(oper1), oper2) > 0; + +stock bool:operator>=(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) >= 0; + +stock bool:operator>=(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) >= 0; + +stock bool:operator>=(oper1, Float:oper2) + return floatcmp(float(oper1), oper2) >= 0; + +stock bool:operator<(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) < 0; + +stock bool:operator<(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) < 0; + +stock bool:operator<(oper1, Float:oper2) + return floatcmp(float(oper1), oper2) < 0; + +stock bool:operator<=(Float:oper1, Float:oper2) + return floatcmp(oper1, oper2) <= 0; + +stock bool:operator<=(Float:oper1, oper2) + return floatcmp(oper1, float(oper2)) <= 0; + +stock bool:operator<=(oper1, Float:oper2) + return floatcmp(float(oper1), oper2) <= 0; + +stock bool:operator!(Float:oper) + return (_:oper & ((-1)/2)) == 0; /* -1 = all bits to 1; /2 = remove most significant bit (sign) + works on both 32bit and 64bit systems; no constant required */ +/* forbidden operations */ +forward operator%(Float:oper1, Float:oper2); +forward operator%(Float:oper1, oper2); +forward operator%(oper1, Float:oper2); + + +/** + * Returns whichever value is the smaller one + * + * @param ValueA The first value + * @param ValueB The second value + * + * @return ValueA if it is smaller than ValueB, and vice versa + */ +stock Float:floatmin(Float:ValueA, Float:ValueB) +{ + if (ValueA<=ValueB) + { + return ValueA; + } + + return ValueB; +} + +/** + * Returns whichever value is the greater one + * + * @param ValueA The first value + * @param ValueB The second value + * + * @return ValueA if it is greater than ValueB, and vice versa + */ +stock Float:floatmax(Float:ValueA, Float:ValueB) +{ + if (ValueA>=ValueB) + { + return ValueA; + } + + return ValueB; +} + +/** + * Clamps a value between a minimum and a maximum floating point value + * + * @param Value The value to be clamped + * @param MinValue Minimum value + * @param MaxValue Maximum value + * + * @return The Value clamped between MinValue and MaxValue + */ +stock Float:floatclamp(Float:Value, Float:MinValue, Float:MaxValue) +{ + if (Value<=MinValue) + { + return MinValue; + } + if (Value>=MaxValue) + { + return MaxValue; + } + + return Value; } \ No newline at end of file diff --git a/plugins/include/fun.inc b/plugins/include/fun.inc index 1096e767..d284af1e 100755 --- a/plugins/include/fun.inc +++ b/plugins/include/fun.inc @@ -1,306 +1,306 @@ -// vim: set ts=4 sw=4 tw=99 noet: -// -// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). -// Copyright (C) The AMX Mod X Development Team. -// -// 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 - -// -// Fun Functions -// - -#if defined _fun_included - #endinput -#endif -#define _fun_included - -#pragma reqlib fun -#if !defined AMXMODX_NOAUTOLOAD - #pragma loadlib fun -#endif - -/** - * Tells whether receiver hears sender via voice communication. - * - * @param receiver Receiver - * @param sender Sender - * - * @return 1 if receiver hears the sender, 0 otherwise. - * @error If receiver or sender are not connected or not - * within the range of 1 to MaxClients - */ -native get_client_listen(receiver, sender); - -/** - * Sets who can listen who. - * - * @param receiver Receiver - * @param sender Sender - * @param listen 1 if receiver should be able to hear sender, 0 if not - * - * @return 0 if the setting can't be done for some reason - * @error If receiver or sender are not connected or not - * within the range of 1 to MaxClients. - */ -native set_client_listen(receiver, sender, listen); - -/** - * Sets player's godmode. - * - * @param index Client index - * @param godmode 1 to enable godmode, 0 to disable - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_godmode(index, godmode = 0); - -/** - * Tells whether a player has godmode on. - * - * @param index Client index - * - * @return 1 if player has godmode on, 0 if not - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native get_user_godmode(index); - -/** - * Sets player's armor amount. - * - * @param index Client index - * @param armor The armor amount to set - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_armor(index, armor); - -/** - * Sets player's health amount. - * - * @param index Client index - * @param health The health amount to set - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_health(index, health); - -/** - * Moves a player to the given origin. - * - * @param index Client index - * @param origin Origin to move a player to - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_origin(index, const origin[3]); - -/** - * Sets player's rendering mode. - * - * @note A really useful render modes reference: - * https://sites.google.com/site/svenmanor/rendermodes - * - * @param index Client index - * @param fx Rendering effects. One of kRenderFx* constants - * @param r The amount of red color (0 to 255) - * @param g The amount of green color (0 to 255) - * @param b The amount of blue color (0 to 255) - * @param render Render mode. One of kRender* constants - * @param amount Render amount (0 to 255) - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_rendering(index, fx = kRenderFxNone, r = 0, g = 0, b = 0, render = kRenderNormal, amount = 0); - -/** - * Gives an item to a player. - * - * @param index Client index - * @param item Classname of the item to give. Should start with either - * "weapon_", "ammo_", "item_" or "tf_weapon_" - * - * @return Item entity index. If an invalid item name is - * given or the item failed to create, it will return 0. - * If the item was removed, it will return -1 - * @error If player is not connected or not within the range - * of 1 to MaxClients or item creation fails. - */ -native give_item(index, const item[]); - -/** - * Sets (adds, removes) hit zones for a player. - * - * @note This actually sets rules of how any player can hit any other. - * Example: set_user_hitzones(id, target, 2) - makes @id able to - * hit @target only in the head. - * - * @param index Client index - * @param target The target player - * @param body A bitsum of the body parts that can/can't be shot: - * 1 - generic - * 2 - head - * 4 - chest - * 8 - stomach - * 16 - left arm - * 32 - right arm - * 64 - left leg - * 128 - right leg - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_hitzones(index = 0, target = 0, body = 255); - -/** - * Gets the set of hit zone "rules" between @index and @target players. - * - * @note For the body part bitsum take a look at the set_user_hitzones() native. - * - * @param index Client index - * @param target The target player - * - * @return The bitsum of @target's body parts @index is able to hit - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native get_user_hitzones(index, target); - -/** - * Sets player's maximum movement speed. - * - * @param index Client index - * @param speed The maximum speed player will be able to run at - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_maxspeed(index, Float:speed = -1.0); - -/** - * Gets player's maximum movement speed. - * - * @param index Client index - * - * @return Player's maximum movement speed - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native Float:get_user_maxspeed(index); - -/** - * Sets player's gravity. - * - * @param index Client index - * @param gravity Gravity value to set, 1.0 being normal gravity (800) - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_gravity(index, Float:gravity = 1.0); - -/** - * Gets player's gravity. - * - * @param index Client index - * - * @return Player's gravity value, 1.0 being normal gravity (800) - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native Float:get_user_gravity(index); - -/** - * Spawns an entity. - * - * @param index Entity index - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native spawn(index); - -/** - * Enables or disables player's noclip. - * - * @param index Client index - * @param noclip 1 to enable noclip, 0 to disable - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_noclip(index, noclip = 0); - -/** - * Gets whether a player has noclip enabled or not. - * - * @param index Client index - * - * @return 1 if noclip is enabled, 0 if disabled - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native get_user_noclip(index); - -/** - * Tells whether a player has silent footsteps enabled. - * - * @param index Client index - * - * @return 1 if silent footsteps are enabled, 0 if not - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native get_user_footsteps(index); - -/** - * Enables or disables player's silent footsteps. - * - * @param index Client index - * @param set 1 if player should have silent footsteps, 0 otherwise - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_footsteps(id, set = 1); - -/** - * Strips all weapons from a player, including their knife. - * - * @param index Client index - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native strip_user_weapons(index); - -/** - * Sets player's frags amount. - * - * @param index Client index - * @param frags The amount of frags to set - * - * @noreturn - * @error If player is not connected or not within the range - * of 1 to MaxClients. - */ -native set_user_frags(index, frags); +// vim: set ts=4 sw=4 tw=99 noet: +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// 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 + +// +// Fun Functions +// + +#if defined _fun_included + #endinput +#endif +#define _fun_included + +#pragma reqlib fun +#if !defined AMXMODX_NOAUTOLOAD + #pragma loadlib fun +#endif + +/** + * Tells whether receiver hears sender via voice communication. + * + * @param receiver Receiver + * @param sender Sender + * + * @return 1 if receiver hears the sender, 0 otherwise. + * @error If receiver or sender are not connected or not + * within the range of 1 to MaxClients + */ +native get_client_listen(receiver, sender); + +/** + * Sets who can listen who. + * + * @param receiver Receiver + * @param sender Sender + * @param listen 1 if receiver should be able to hear sender, 0 if not + * + * @return 0 if the setting can't be done for some reason + * @error If receiver or sender are not connected or not + * within the range of 1 to MaxClients. + */ +native set_client_listen(receiver, sender, listen); + +/** + * Sets player's godmode. + * + * @param index Client index + * @param godmode 1 to enable godmode, 0 to disable + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_godmode(index, godmode = 0); + +/** + * Tells whether a player has godmode on. + * + * @param index Client index + * + * @return 1 if player has godmode on, 0 if not + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native get_user_godmode(index); + +/** + * Sets player's armor amount. + * + * @param index Client index + * @param armor The armor amount to set + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_armor(index, armor); + +/** + * Sets player's health amount. + * + * @param index Client index + * @param health The health amount to set + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_health(index, health); + +/** + * Moves a player to the given origin. + * + * @param index Client index + * @param origin Origin to move a player to + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_origin(index, const origin[3]); + +/** + * Sets player's rendering mode. + * + * @note A really useful render modes reference: + * https://sites.google.com/site/svenmanor/rendermodes + * + * @param index Client index + * @param fx Rendering effects. One of kRenderFx* constants + * @param r The amount of red color (0 to 255) + * @param g The amount of green color (0 to 255) + * @param b The amount of blue color (0 to 255) + * @param render Render mode. One of kRender* constants + * @param amount Render amount (0 to 255) + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_rendering(index, fx = kRenderFxNone, r = 0, g = 0, b = 0, render = kRenderNormal, amount = 0); + +/** + * Gives an item to a player. + * + * @param index Client index + * @param item Classname of the item to give. Should start with either + * "weapon_", "ammo_", "item_" or "tf_weapon_" + * + * @return Item entity index. If an invalid item name is + * given or the item failed to create, it will return 0. + * If the item was removed, it will return -1 + * @error If player is not connected or not within the range + * of 1 to MaxClients or item creation fails. + */ +native give_item(index, const item[]); + +/** + * Sets (adds, removes) hit zones for a player. + * + * @note This actually sets rules of how any player can hit any other. + * Example: set_user_hitzones(id, target, 2) - makes @id able to + * hit @target only in the head. + * + * @param index Client index + * @param target The target player + * @param body A bitsum of the body parts that can/can't be shot: + * 1 - generic + * 2 - head + * 4 - chest + * 8 - stomach + * 16 - left arm + * 32 - right arm + * 64 - left leg + * 128 - right leg + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_hitzones(index = 0, target = 0, body = 255); + +/** + * Gets the set of hit zone "rules" between @index and @target players. + * + * @note For the body part bitsum take a look at the set_user_hitzones() native. + * + * @param index Client index + * @param target The target player + * + * @return The bitsum of @target's body parts @index is able to hit + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native get_user_hitzones(index, target); + +/** + * Sets player's maximum movement speed. + * + * @param index Client index + * @param speed The maximum speed player will be able to run at + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_maxspeed(index, Float:speed = -1.0); + +/** + * Gets player's maximum movement speed. + * + * @param index Client index + * + * @return Player's maximum movement speed + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native Float:get_user_maxspeed(index); + +/** + * Sets player's gravity. + * + * @param index Client index + * @param gravity Gravity value to set, 1.0 being normal gravity (800) + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_gravity(index, Float:gravity = 1.0); + +/** + * Gets player's gravity. + * + * @param index Client index + * + * @return Player's gravity value, 1.0 being normal gravity (800) + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native Float:get_user_gravity(index); + +/** + * Spawns an entity. + * + * @param index Entity index + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native spawn(index); + +/** + * Enables or disables player's noclip. + * + * @param index Client index + * @param noclip 1 to enable noclip, 0 to disable + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_noclip(index, noclip = 0); + +/** + * Gets whether a player has noclip enabled or not. + * + * @param index Client index + * + * @return 1 if noclip is enabled, 0 if disabled + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native get_user_noclip(index); + +/** + * Tells whether a player has silent footsteps enabled. + * + * @param index Client index + * + * @return 1 if silent footsteps are enabled, 0 if not + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native get_user_footsteps(index); + +/** + * Enables or disables player's silent footsteps. + * + * @param index Client index + * @param set 1 if player should have silent footsteps, 0 otherwise + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_footsteps(id, set = 1); + +/** + * Strips all weapons from a player, including their knife. + * + * @param index Client index + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native strip_user_weapons(index); + +/** + * Sets player's frags amount. + * + * @param index Client index + * @param frags The amount of frags to set + * + * @noreturn + * @error If player is not connected or not within the range + * of 1 to MaxClients. + */ +native set_user_frags(index, frags); diff --git a/plugins/include/newmenus.inc b/plugins/include/newmenus.inc index 4ded31d9..98faad81 100644 --- a/plugins/include/newmenus.inc +++ b/plugins/include/newmenus.inc @@ -81,6 +81,11 @@ */ #define MPROP_PAGE_CALLBACK 11 +/** + * Whether to show the page number in menu title (param1 = bool, true = default) + */ +#define MPROP_SHOWPAGE 12 + /** * @deprecated */