YSI

From SA-MP Wiki

Jump to: navigation, search

YSI (YSI Server Includes) is a set of libraries designed to provide a number of advance features via a simple API, allowing people to concentrate on the contents of their mode rather than the implementation. There is a lot of code available through a number of libraries within the package, however you can pick and choose which bits you would like to use. Listed below are the libraries available grouped by type, further down are extra tutorials and other subsidary pieces of information.

Main Libraries

The main libraries are the ones designed to be used by YSI users (any library can be used, but these provide the most interesting functionality). These are often extensively tuned to give the best possible performance and are constantly updated to new methods.

  • y_classes - Allows for huge control over the class selection screen, including adding and removing classes, setting classes to only be seen by certain players and sending a player straight to a specifc class in the selection.
  • y_commands - A command processor using the same technology as ZCMD (though actually using it first), designed for maximum flexibility providing features for per-player command permissions, adding and removing alternate spellings of commands and automatically listing all commands that a player can currently use. Also has many other minor features.
  • y_files - Extends the default file processing functions using a plugin. Note that this is not a standard part of YSI.
  • y_flooding - Prevents or restricts multiple connections from a single IP.
  • y_ini - Very fast INI file reader. Uses callbacks rather than standard functions for speed.
  • y_iterate - The same as foreach, but integrated in to YSI for better compatibility. Note that this will negotiate with foreach and always include the latest version.
  • y_player - A user account system for players, fully integrated and providing "OnPlayerLogin" and "OnPlayerLogout" callbacks.
  • y_playerset - A device used to call a function for multiple players without loops, the function can take arrays, single IDs or y_playerarray bit arrays. See YSI as a DSL for more information.
  • y_stringhash - This allows you to get the Bernstein, FNV or FNV-1 hash of a string at compile time, allowing you to use strings as switch case statements.
  • y_td - High level text-draw library providing update functions to change the apperance of text draws already displayed and define and reuse styles.
  • y_testing - Provides functionality for writing unit tests which can be run or not run as required.
  • y_timers - Allows you to define functions as timer functions, removing the need for most "SetTimer" calls, especially for eternally repeating super loop timers.
  • y_users - Provides the "uvar" declaration for automatically saved data. Is not based on y_players directly - users can provide their own backends for the system if so desired.
  • y_xml - Another callback based system, this time for loading XML files.

Core Libraries

The core libraries are libraries which are used extensively by YSI itself. YSI is very hierarchical - libraries are built on other libraries which are built on other libraries, however this is for speed and simplicity reasons. Clicking on any library will display more information about that library, including which other libraries it uses.

  • y_amx - Provides information about an AMX file, for example all public and native functions used or the values of public variables by name. Used by y_commands to find all commands in a mode and y_hooks to find all hook functions. Called y_scripting before a major API overhaul.
  • y_bintree - Provides a basic implementation of "binary trees". Used by y_commands to very quickly find commands to check permissions.
  • y_bit - Provides macros for storing 32 (true/false) values in a single variable, or arrays to store hundreds or thousands of values in a very small space. Used in most libraries for storing packed data.
  • y_debug - A collection of macros for printing information to the server console when the code is compiled with a special define. Used in EVERY YSI library to provide zero-overhead debugging information (when off).
  • y_hooks - A very fast and very simple method for using callbacks in includes as well as main gamemodes. Uses y_amx to get public function (callback) information.
  • y_scriptinit - Provides two y_hooks compatible callbacks: "OnScriptInit" and "OnScriptExit". These are called when the current script first starts or ends, whether it's a gamemode or a filterscript. Added to combat the fact that many users do not correctly use the "FILTERSCRIPT" macro.
  • y_playerarray - Very similar to (but NOT using) y_bit. Allows you to store true/false values for players very compactly, but is different to normal bit arrays in that it is compatible with y_playerset.
  • y_utils - A number of common functions which don't fit in to any major category.