y_utils.inc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * <library name="y_utils">
  3. * <section>
  4. * Description
  5. * </section>
  6. * Misc functions used throughout.
  7. * <section>
  8. * Version
  9. * </section>
  10. * 0.1.3
  11. * <section>
  12. * Functions
  13. * </section>
  14. * <subsection>Stock</subsection>
  15. * <ul>
  16. * <symbol name="StrToLower">Convert a whole string to lower-case.</symbol>
  17. * <symbol name="StrToUpper">Convert a whole string to upper-case.</symbol>
  18. * <symbol name="Random">Generate a random number, optionally takes lower and upper bounds.</symbol>
  19. * <symbol name="RandomFloat">Same as <symbolref name="Random" />, but for floats.</symbol>
  20. * <symbol name="StripNL">Strips the newline characters from the end of a string.</symbol>
  21. * <symbol name="StripL">Remove whitespace from the start of a string.</symbol>
  22. * <symbol name="Strip">Remove whitespace from both ends of a string.</symbol>
  23. * <symbol name="endofline">Check if the given position is the end of a string (ignoring whitespace).</symbol>
  24. * <symbol name="chrfind">Return the first position (after <symbolref name="start" />) of the given character.</symbol>
  25. * <symbol name="chrfindp">Like <symbolref name="chrfind" />, but without the upper-bounds check.</symbol>
  26. * <symbol name="bernstein">Generate the Bernstein hash of the given string.</symbol>
  27. * <symbol name="ishex">Is the given string hexadecimal?</symbol>
  28. * <symbol name="unpack">Version of <symbolref name="strunpack" /> that returns the result.</symbol>
  29. * <symbol name="returnstringarg">Get the string passed as a variable argument from the given index.</symbol>
  30. * <symbol name="va_return">Like <symbolref name="sprintf" />, formats a string and returns the result.</symbol>
  31. * <symbol name="isnumeric">Is the given string a number?</symbol>
  32. * <symbol name="hexstr">Return the value of the given hexadecimal string.</symbol>
  33. * <symbol name="boolstr">Return the value of the given boolean string.</symbol>
  34. * <symbol name="binstr">Return the value of the given binary string.</symbol>
  35. * <symbol name="rawMemcpy">Copy memory between two address, instead of two arrays.</symbol>
  36. * <symbol name="memset">Set all of an array to a value.</symbol>
  37. * <symbol name="rawMemset">Set all of a given memory region to a value.</symbol>
  38. * <symbol name="ReturnPlayerName">Return a player's name.</symbol>
  39. * <symbol name="ftouch">Ensures that a file exists, but nothing more.</symbol>
  40. * <symbol name="InterpolateColour">Get the colour (in 3D RGB space) between two other colours.</symbol>
  41. * <symbol name="SkipWhitespace">Return the first position in a string of a non-whitespace character.</symbol>
  42. * <symbol name="Trim">Get the first and last positions of non-whitespace characters in the string. Like <symbolref name="Strip" />, but doesn't modify the string.</symbol>
  43. * <symbol name="Sum">Get the total (sum) of an array.</symbol>
  44. * <symbol name="Mean">Get the mathematical mean of an array.</symbol>
  45. * <symbol name="Mode">Get the mathematical mode of an array.</symbol>
  46. * <symbol name="Median">Get the mathematical median of an array.</symbol>
  47. * <symbol name="Range">Get the mathematical range of an array.</symbol>
  48. * </ul>
  49. * <subsection>Inline</subsection>
  50. * <ul>
  51. * <symbol name="UCMP">Unsigned compare.</symbol>
  52. * <symbol name="VALID_PLAYERID">Check if a player ID is valid (in range).</symbol>
  53. * <symbol name="IS_IN_RANGE">Check if a number is in range.</symbol>
  54. * <symbol name="NOT_IN_RANGE">Check if a number is outside a range.</symbol>
  55. * <symbol name="ceildiv">Divide two numbers and round up.</symbol>
  56. * <symbol name="floordiv">Divide two numbers and round down.</symbol>
  57. * <symbol name="isnull">Checks if a string is NULL (<c>\1\0</c> or <c>\0</c>).</symbol>
  58. * <symbol name="isodd">Checks if a number is odd.</symbol>
  59. * <symbol name="iseven">Checks if a number is even.</symbol>
  60. * <symbol name="strcpy">Copy one string to another.</symbol>
  61. * <symbol name="GetIP">Return the encoded (32-bit) version of a player's IP.</symbol>
  62. * <synonym name="getstring" for="returnstringarg"> (there are a lot)</synonym>
  63. * <synonym name="GetString" for="returnstringarg"> (there are a lot)</synonym>
  64. * <synonym name="getstringarg" for="returnstringarg"> (there are a lot)</synonym>
  65. * <synonym name="GetStringArg" for="returnstringarg"> (there are a lot)</synonym>
  66. * <synonym name="ReturnStringArg" for="returnstringarg"> (there are a lot)</synonym>
  67. * <synonym name="InterpolateColor" for="InterpolateColour" />
  68. * <synonym name="StripR" for="StripNL" />
  69. * </ul>
  70. * <section>
  71. * Variables
  72. * </section>
  73. * <subsection>Global</subsection>
  74. * <ul>
  75. * <symbol name="TRUE">True hack for infinate loops.</symbol>
  76. * <symbol name="FALSE">False hack for one-time loops.</symbol>
  77. * <symbol name="NULL">1 long string for passing via Call(Remote|Local)Function.</symbol>
  78. * </ul>
  79. * </library>
  80. *//** *//*
  81. Legal:
  82. Version: MPL 1.1
  83. The contents of this file are subject to the Mozilla Public License Version
  84. 1.1 the "License"; you may not use this file except in compliance with
  85. the License. You may obtain a copy of the License at
  86. http://www.mozilla.org/MPL/
  87. Software distributed under the License is distributed on an "AS IS" basis,
  88. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  89. for the specific language governing rights and limitations under the
  90. License.
  91. The Original Code is the YSI framework.
  92. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  93. Portions created by the Initial Developer are Copyright C 2011
  94. the Initial Developer. All Rights Reserved.
  95. Contributors:
  96. Y_Less
  97. koolk
  98. JoeBullet/Google63
  99. g_aSlice/Slice
  100. Misiur
  101. samphunter
  102. tianmeta
  103. maddinat0r
  104. spacemud
  105. Crayder
  106. Dayvison
  107. Ahmad45123
  108. Zeex
  109. irinel1996
  110. Yiin-
  111. Chaprnks
  112. Konstantinos
  113. Masterchen09
  114. Southclaws
  115. PatchwerkQWER
  116. m0k1
  117. paulommu
  118. udan111
  119. Thanks:
  120. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  121. ZeeX - Very productive conversations.
  122. koolk - IsPlayerinAreaEx code.
  123. TheAlpha - Danish translation.
  124. breadfish - German translation.
  125. Fireburn - Dutch translation.
  126. yom - French translation.
  127. 50p - Polish translation.
  128. Zamaroht - Spanish translation.
  129. Los - Portuguese translation.
  130. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  131. me to strive to better.
  132. Pixels^ - Running XScripters where the idea was born.
  133. Matite - Pestering me to release it and using it.
  134. Very special thanks to:
  135. Thiadmer - PAWN, whose limits continue to amaze me!
  136. Kye/Kalcor - SA:MP.
  137. SA:MP Team past, present and future - SA:MP.
  138. Optional plugins:
  139. Gamer_Z - GPS.
  140. Incognito - Streamer.
  141. Me - sscanf2, fixes2, Whirlpool.
  142. */
  143. #if !defined _INC_y_core
  144. #tryinclude "y_core\y_core_entry"
  145. #endif
  146. #if !defined _INC_y_core
  147. #tryinclude "YSI_Core\y_core\y_core_entry"
  148. #endif
  149. #if !defined _INC_y_core
  150. #tryinclude "YSI\YSI_Core\y_core\y_core_entry"
  151. #endif
  152. #if !defined _INC_y_core
  153. #tryinclude <YSI_Core\y_core\y_core_entry>
  154. #endif
  155. #if !defined _INC_y_core
  156. #tryinclude <YSI\YSI_Core\y_core\y_core_entry>
  157. #endif
  158. #if !defined _INC_y_core
  159. #error Could not find y_utils
  160. #endif