@amxts/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/README.ru.md +162 -0
  4. package/amxmodx/base/include/amxconst.inc +594 -0
  5. package/amxmodx/base/include/amxmisc.inc +902 -0
  6. package/amxmodx/base/include/amxmodx.inc +3447 -0
  7. package/amxmodx/base/include/amxmodx_version.inc +20 -0
  8. package/amxmodx/base/include/cellarray.inc +525 -0
  9. package/amxmodx/base/include/cellstack.inc +166 -0
  10. package/amxmodx/base/include/celltrie.inc +412 -0
  11. package/amxmodx/base/include/core.inc +202 -0
  12. package/amxmodx/base/include/csstats.inc +298 -0
  13. package/amxmodx/base/include/csstats_const.inc +29 -0
  14. package/amxmodx/base/include/cstrike.inc +1287 -0
  15. package/amxmodx/base/include/cstrike_const.inc +521 -0
  16. package/amxmodx/base/include/csx.inc +259 -0
  17. package/amxmodx/base/include/cvars.inc +547 -0
  18. package/amxmodx/base/include/datapack.inc +161 -0
  19. package/amxmodx/base/include/dbi.inc +154 -0
  20. package/amxmodx/base/include/dodconst.inc +152 -0
  21. package/amxmodx/base/include/dodfun.inc +152 -0
  22. package/amxmodx/base/include/dodstats.inc +69 -0
  23. package/amxmodx/base/include/dodx.inc +161 -0
  24. package/amxmodx/base/include/engine.inc +1343 -0
  25. package/amxmodx/base/include/engine_const.inc +310 -0
  26. package/amxmodx/base/include/engine_stocks.inc +248 -0
  27. package/amxmodx/base/include/esf.inc +70 -0
  28. package/amxmodx/base/include/esf_const.inc +74 -0
  29. package/amxmodx/base/include/fakemeta.inc +1127 -0
  30. package/amxmodx/base/include/fakemeta_const.inc +793 -0
  31. package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
  32. package/amxmodx/base/include/fakemeta_util.inc +882 -0
  33. package/amxmodx/base/include/file.inc +666 -0
  34. package/amxmodx/base/include/float.inc +422 -0
  35. package/amxmodx/base/include/fun.inc +333 -0
  36. package/amxmodx/base/include/gameconfig.inc +93 -0
  37. package/amxmodx/base/include/geoip.inc +264 -0
  38. package/amxmodx/base/include/ham_const.inc +4352 -0
  39. package/amxmodx/base/include/hamsandwich.inc +439 -0
  40. package/amxmodx/base/include/hlsdk_const.inc +808 -0
  41. package/amxmodx/base/include/json.inc +777 -0
  42. package/amxmodx/base/include/lang.inc +119 -0
  43. package/amxmodx/base/include/message_const.inc +1130 -0
  44. package/amxmodx/base/include/message_stocks.inc +161 -0
  45. package/amxmodx/base/include/messages.inc +604 -0
  46. package/amxmodx/base/include/newmenus.inc +387 -0
  47. package/amxmodx/base/include/ns.inc +754 -0
  48. package/amxmodx/base/include/ns_const.inc +196 -0
  49. package/amxmodx/base/include/nvault.inc +154 -0
  50. package/amxmodx/base/include/regex.inc +348 -0
  51. package/amxmodx/base/include/sockets.inc +183 -0
  52. package/amxmodx/base/include/sorting.inc +107 -0
  53. package/amxmodx/base/include/sqlx.inc +582 -0
  54. package/amxmodx/base/include/string.inc +786 -0
  55. package/amxmodx/base/include/string_const.inc +156 -0
  56. package/amxmodx/base/include/string_stocks.inc +325 -0
  57. package/amxmodx/base/include/textparse_ini.inc +214 -0
  58. package/amxmodx/base/include/textparse_smc.inc +261 -0
  59. package/amxmodx/base/include/tfcconst.inc +84 -0
  60. package/amxmodx/base/include/tfcstats.inc +62 -0
  61. package/amxmodx/base/include/tfcx.inc +148 -0
  62. package/amxmodx/base/include/time.inc +118 -0
  63. package/amxmodx/base/include/tsconst.inc +154 -0
  64. package/amxmodx/base/include/tsfun.inc +198 -0
  65. package/amxmodx/base/include/tsstats.inc +65 -0
  66. package/amxmodx/base/include/tsx.inc +88 -0
  67. package/amxmodx/base/include/vault.inc +60 -0
  68. package/amxmodx/base/include/vector.inc +131 -0
  69. package/amxmodx/base/include/xs.inc +1570 -0
  70. package/as/amxts.d.ts +153 -0
  71. package/as/constants.ts +4730 -0
  72. package/as/effects.ts +1449 -0
  73. package/as/entities.ts +5482 -0
  74. package/as/events.ts +3054 -0
  75. package/as/facade.ts +4639 -0
  76. package/as/flags.ts +299 -0
  77. package/as/fs.ts +287 -0
  78. package/as/hooks.ts +18536 -0
  79. package/as/kit.ts +25 -0
  80. package/as/lib/check.ts +86 -0
  81. package/as/modules/http.ts +184 -0
  82. package/as/natives.ts +11845 -0
  83. package/as/os.ts +30 -0
  84. package/as/promise.ts +1392 -0
  85. package/as/promise.types.d.ts +82 -0
  86. package/as/remote.ts +288 -0
  87. package/as/tsconfig.json +22 -0
  88. package/as/vector.ts +65 -0
  89. package/bin/amxts.mjs +10 -0
  90. package/includes/menu_core.inc +355 -0
  91. package/includes/order.txt +54 -0
  92. package/includes/sources.json +27 -0
  93. package/includes/universal_config.inc +355 -0
  94. package/lint/oxlint-plugin.mjs +77 -0
  95. package/node_modules/assemblyscript/LICENSE +201 -0
  96. package/node_modules/assemblyscript/NOTICE +93 -0
  97. package/node_modules/assemblyscript/package.json +63 -0
  98. package/node_modules/assemblyscript/std/README.md +6 -0
  99. package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
  100. package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
  101. package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
  102. package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
  103. package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
  104. package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
  105. package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
  106. package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
  107. package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
  108. package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
  109. package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
  110. package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
  111. package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
  112. package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
  113. package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
  114. package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
  115. package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
  116. package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
  117. package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
  118. package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
  119. package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
  120. package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
  121. package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
  122. package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
  123. package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
  124. package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
  125. package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
  126. package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
  127. package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
  128. package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
  129. package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
  130. package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
  131. package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
  132. package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
  133. package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
  134. package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
  135. package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
  136. package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
  137. package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
  138. package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
  139. package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
  140. package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
  141. package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
  142. package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
  143. package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
  144. package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
  145. package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
  146. package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
  147. package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
  148. package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
  149. package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
  150. package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
  151. package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
  152. package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
  153. package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
  154. package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
  155. package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
  156. package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
  157. package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
  158. package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
  159. package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
  160. package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
  161. package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
  162. package/node_modules/assemblyscript/std/assembly.json +16 -0
  163. package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
  164. package/node_modules/assemblyscript/std/portable/index.js +416 -0
  165. package/node_modules/assemblyscript/std/portable.json +11 -0
  166. package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
  167. package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
  168. package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
  169. package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
  170. package/node_modules/assemblyscript/tsconfig-base.json +13 -0
  171. package/package.json +112 -0
  172. package/runtime/deps/assemblyscript/LICENSE +201 -0
  173. package/runtime/deps/assemblyscript/NOTICE +93 -0
  174. package/runtime/deps/assemblyscript/bin/asc.js +35 -0
  175. package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
  176. package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
  177. package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
  178. package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
  179. package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
  180. package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
  181. package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
  182. package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
  183. package/runtime/deps/assemblyscript/package.json +114 -0
  184. package/runtime/host/amxts.inc +85 -0
  185. package/runtime/licenses/AMXX-LICENSE.txt +34 -0
  186. package/runtime/licenses/AssemblyScript-LICENSE +201 -0
  187. package/runtime/licenses/AssemblyScript-NOTICE +93 -0
  188. package/runtime/licenses/Binaryen-LICENSE +201 -0
  189. package/runtime/licenses/Bun-LICENSE.md +84 -0
  190. package/runtime/licenses/GPL-3.0.txt +674 -0
  191. package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
  192. package/runtime/licenses/README.md +25 -0
  193. package/runtime/licenses/WAMR-LICENSE +219 -0
  194. package/runtime/natives.txt +1095 -0
  195. package/runtime/patches/README.md +59 -0
  196. package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
  197. package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
  198. package/scripts/apply-docs.ts +508 -0
  199. package/scripts/asc.ts +27 -0
  200. package/scripts/auto-imports.ts +258 -0
  201. package/scripts/build-wasm.ts +595 -0
  202. package/scripts/check.ts +93 -0
  203. package/scripts/compile-cache.ts +179 -0
  204. package/scripts/compile.ts +401 -0
  205. package/scripts/docker-server.ts +73 -0
  206. package/scripts/docs/as/amxts.ts +210 -0
  207. package/scripts/docs/as/effects.ts +1684 -0
  208. package/scripts/docs/as/facade.ts +3302 -0
  209. package/scripts/docs/as/fs.ts +173 -0
  210. package/scripts/docs/as/lib/check.ts +68 -0
  211. package/scripts/docs/as/modules/http.ts +66 -0
  212. package/scripts/docs/as/os.ts +16 -0
  213. package/scripts/docs/as/promise.ts +132 -0
  214. package/scripts/docs/as/promise.types.ts +63 -0
  215. package/scripts/docs/as/vector.ts +48 -0
  216. package/scripts/docs/entities.ts +2338 -0
  217. package/scripts/docs/events.ts +245 -0
  218. package/scripts/docs/game.ts +497 -0
  219. package/scripts/docs/messages.ts +148 -0
  220. package/scripts/file-contents.ts +74 -0
  221. package/scripts/includes.ts +134 -0
  222. package/scripts/player-fields.ts +866 -0
  223. package/scripts/plugin-cache.ts +92 -0
  224. package/scripts/plugin-natives.ts +1157 -0
  225. package/scripts/prebuilt.ts +268 -0
  226. package/scripts/prepare.ts +134 -0
  227. package/scripts/project.ts +973 -0
  228. package/scripts/run.ts +28 -0
  229. package/scripts/shared-modules.ts +906 -0
  230. package/scripts/system.ts +33 -0
  231. package/scripts/tracked-fs.ts +115 -0
  232. package/scripts/typed-configs.ts +788 -0
  233. package/scripts/ui.ts +77 -0
  234. package/src/cli-api.mjs +175 -0
  235. package/src/parser/include-parser.ts +506 -0
  236. package/src/system.mjs +155 -0
  237. package/src/testing/compile-cache.ts +31 -0
  238. package/src/testing/compile.ts +222 -0
  239. package/src/testing/coroutines.ts +191 -0
  240. package/src/testing/index.ts +39 -0
  241. package/src/testing/kits.ts +55 -0
  242. package/src/testing/memory.ts +125 -0
  243. package/src/testing/natives.ts +925 -0
  244. package/src/testing/server.ts +1874 -0
  245. package/src/testing/setup.ts +63 -0
  246. package/src/testing/tables.ts +139 -0
  247. package/src/types.ts +51 -0
@@ -0,0 +1,786 @@
1
+ // vim: set ts=4 sw=4 tw=99 noet:
2
+ //
3
+ // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
4
+ // Copyright (C) The AMX Mod X Development Team.
5
+ //
6
+ // This software is licensed under the GNU General Public License, version 3 or higher.
7
+ // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
8
+ // https://alliedmods.net/amxmodx-license
9
+
10
+ //
11
+ // String Manipulation
12
+ //
13
+
14
+ #if defined _string_included
15
+ #endinput
16
+ #endif
17
+ #define _string_included
18
+
19
+ #include <string_const>
20
+
21
+ /**
22
+ * @global Unless otherwise noted, all string functions which take in a
23
+ * writable buffer and maximum length should NOT have the null terminator INCLUDED
24
+ * in the length. This means that this is valid:
25
+ * copy(string, charsmax(string), ...)
26
+ */
27
+
28
+ /**
29
+ * Calculates the length of a string.
30
+ *
31
+ * @param string String to check.
32
+ * @return Number of valid character bytes in the string.
33
+ */
34
+ native strlen(const string[]);
35
+
36
+ /**
37
+ * Tests whether a string is found inside another string.
38
+ *
39
+ * @param source String to search in.
40
+ * @param string Substring to find inside the original string.
41
+ *
42
+ * @return -1 on failure (no match found). Any other value
43
+ * indicates a position in the string where the match starts.
44
+ */
45
+ native contain(const source[], const string[]);
46
+
47
+ /**
48
+ * Tests whether a string is found inside another string with case ignoring.
49
+ *
50
+ * @note This supports multi-byte characters (UTF-8) on comparison.
51
+ *
52
+ * @param source String to search in.
53
+ * @param string Substring to find inside the original string.
54
+ *
55
+ * @return -1 on failure (no match found). Any other value
56
+ * indicates a position in the string where the match starts.
57
+ */
58
+ native containi(const source[], const string[]);
59
+
60
+ /**
61
+ * Given a string, replaces the first occurrence of a search string with a
62
+ * replacement string.
63
+ *
64
+ * @param text String to perform search and replacements on.
65
+ * @param len Maximum length of the string buffer.
66
+ * @param what String to search for.
67
+ * @param with String to replace the search string with.
68
+ *
69
+ * @return The new string length after replacement, or 0 if no replacements were made.
70
+ */
71
+ native replace(text[], len, const what[], const with[]);
72
+
73
+ /**
74
+ * Given a string, replaces all occurrences of a search string with a
75
+ * replacement string.
76
+ *
77
+ * @note Similar to replace_all() stock, but implemented as native and
78
+ * with different algorithm. This native doesn't error on bad
79
+ * buffer size and will smartly cut off the string in a way
80
+ * that pushes old data out.
81
+ *
82
+ * @note Only available in 1.8.3 and above.
83
+ * @note This supports multi-byte characters (UTF-8) on case insensitive comparison.
84
+ *
85
+ * @param text String to perform search and replacements on.
86
+ * @param maxlength Maximum length of the string buffer.
87
+ * @param search String to search for.
88
+ * @param replace String to replace the search string with.
89
+ * @param caseSensitive If true (default), search is case sensitive.
90
+ *
91
+ * @return Number of replacements that were performed.
92
+ */
93
+ native replace_string(text[], maxlength, const search[], const replace[], bool:caseSensitive = true);
94
+
95
+ /**
96
+ * Given a string, replaces the first occurrence of a search string with a
97
+ * replacement string.
98
+ *
99
+ * @note Similar to replace() native, but implemented with more options and
100
+ * with different algorithm. This native doesn't error on bad
101
+ * buffer size and will smartly cut off the string in a way
102
+ * that pushes old data out.
103
+ *
104
+ * @note Only available in 1.8.3 and above.
105
+ * @note This supports multi-byte characters (UTF-8) on case insensitive comparison.
106
+ *
107
+ * @param text String to perform search and replacements on.
108
+ * @param maxlength Maximum length of the string buffer.
109
+ * @param search String to search for.
110
+ * @param replace String to replace the search string with.
111
+ * @param searchLen If higher than -1, its value will be used instead of
112
+ * a strlen() call on the search parameter.
113
+ * @param replaceLen If higher than -1, its value will be used instead of
114
+ * a strlen() call on the replace parameter.
115
+ * @param caseSensitive If true (default), search is case sensitive.
116
+ *
117
+ * @return Index into the buffer (relative to the start) from where
118
+ * the last replacement ended, or -1 if no replacements were
119
+ * made.
120
+ */
121
+ native replace_stringex(text[], maxlength, const search[], const replace[], searchLen = -1, replaceLen = -1, bool:caseSensitive = true);
122
+
123
+ /**
124
+ * Concatenates one string onto another.
125
+ *
126
+ * @param dest String to append to.
127
+ * @param len Maximum length of entire buffer.
128
+ * @param src Source string to concatenate.
129
+ * @param max Number of characters to add.
130
+ *
131
+ * @return Number of of all merged characters.
132
+ */
133
+ native add(dest[],len,const src[],max=0);
134
+
135
+ /**
136
+ * Formats a string according to the AMX Mod X format rules (see documentation).
137
+ *
138
+ * @note Example: format(dest, "Hello %s. You are %d years old", "Tom", 17).
139
+ * If any of your input buffers overlap with the destination buffer,
140
+ * format() falls back to a "copy-back" version as of 1.65. This is
141
+ * slower, so you should using a source string that is the same as
142
+ * the destination.
143
+ *
144
+ * @param output Destination string buffer.
145
+ * @param len Maximum length of output string buffer.
146
+ * @param format Formatting rules.
147
+ * @param ... Variable number of format parameters.
148
+ *
149
+ * @return Number of cells written.
150
+ */
151
+ native format(output[], len, const format[], any:...);
152
+
153
+ /**
154
+ * Formats a string according to the AMX Mod X format rules (see documentation).
155
+ *
156
+ * @note Same as format(), except does not perform a "copy back" check.
157
+ * This means formatex() is faster, but DOES NOT ALLOW this type
158
+ * of call:
159
+ * formatex(buffer, len, "%s", buffer)
160
+ * formatex(buffer, len, buffer, buffer)
161
+ * formatex(buffer, len, "%s", buffer[5])
162
+ * This is because the output is directly stored into "buffer",
163
+ * rather than copied back at the end.
164
+ *
165
+ * @param output Destination string buffer.
166
+ * @param len Maximum length of output string buffer.
167
+ * @param format Formatting rules.
168
+ * @param ... Variable number of format parameters.
169
+ *
170
+ * @return Number of cells written.
171
+ */
172
+ native formatex(output[], len, const format[], any:...);
173
+
174
+ /**
175
+ * Formats and returns a string according to the AMX Mod X format rules
176
+ * (see documentation).
177
+ *
178
+ * @note Example: menu_additem(menu, fmt("My first %s", "item")).
179
+ * @note This should only be used for simple inline formatting like in the above example.
180
+ * Avoid using this function to store strings into variables as an additional
181
+ * copying step is required.
182
+ * @note The buffer size is defined by MAX_FMT_LENGTH.
183
+ *
184
+ * @param format Formatting rules.
185
+ * @param ... Variable number of format parameters.
186
+ *
187
+ * @return Formatted string
188
+ */
189
+ native [MAX_FMT_LENGTH]fmt(const format[], any:...);
190
+
191
+ /**
192
+ * Formats a string according to the AMX Mod X format rules (see documentation).
193
+ *
194
+ * @note This is the same as format(), except it grabs parameters from a
195
+ * parent parameter stack, rather than a local. This is useful for
196
+ * implementing your own variable argument functions.
197
+ *
198
+ * @note Replacement for format_args. Much faster and %L compatible.
199
+ * This works exactly like vsnprintf() from C.
200
+ * You must pass in the output buffer and its size,
201
+ * the string to format, and the number of the FIRST variable
202
+ * argument parameter. For example, for:
203
+ * function (a, b, c, ...)
204
+ * You would pass 4 (a is 1, b is 2, c is 3, et cetera).
205
+ * There is no vformatex().
206
+ *
207
+ * @param buffer Destination string buffer.
208
+ * @param len Maximum length of output string buffer.
209
+ * @param fmt Formatting rules.
210
+ * @param vararg Argument number which contains the '...' symbol.
211
+ * Note: Arguments start at 1.
212
+ * @return Number of bytes written.
213
+ */
214
+ native vformat(buffer[], len, const fmt[], vararg);
215
+
216
+ /**
217
+ * Formats a string according to the AMX Mod X format rules (see documentation).
218
+ *
219
+ * @note Same as vformat(), except works in normal style dynamic natives.
220
+ * Instead of passing the format arg string, you can only pass the
221
+ * actual format argument number itself.
222
+ * If you pass 0, it will read the format string from an optional
223
+ * fifth parameter.
224
+ *
225
+ * @param buffer Destination string buffer.
226
+ * @param len Maximum length of output string buffer.
227
+ * @param fmt_arg Argument number which contains the format.
228
+ * @param vararg Argument number which contains the '...' symbol.
229
+ * Note: Arguments start at 1.
230
+ * @return Number of bytes written.
231
+ */
232
+ native vdformat(buffer[], len, fmt_arg, vararg, ...);
233
+
234
+ /**
235
+ * Gets parameters from function as formated string.
236
+ *
237
+ * @param output Destination string buffer.
238
+ * @param len Maximum length of output string buffer.
239
+ * @param pos Argument number which contains the '...' symbol.
240
+ *
241
+ * @return Number of bytes written.
242
+ */
243
+ native format_args(output[], len, pos = 0);
244
+
245
+ /**
246
+ * Converts an integer to a string.
247
+ *
248
+ * @param num Integer to convert.
249
+ * @param string Buffer to store string in.
250
+ * @param len Maximum length of string buffer.
251
+ *
252
+ * @return Number of cells written to buffer.
253
+ */
254
+ native num_to_str(num,string[],len);
255
+
256
+ /**
257
+ * Converts a string to an integer.
258
+ *
259
+ * @param string String to convert.
260
+ * @return Integer conversion of string, or 0 on failure.
261
+ */
262
+ native str_to_num(const string[]);
263
+
264
+ /**
265
+ * Parses the 'string' interpreting its content as an integral number of the specified 'base',
266
+ * which is returned as integer value. The function also sets the value of 'endPos' to point
267
+ * to the position of the first character after the number.
268
+ *
269
+ * This is the same as C++ strtol function with a difference on second param.
270
+ *
271
+ * The function first discards as many whitespace characters as necessary until the first
272
+ * non-whitespace character is found. Then, starting from this character, takes as many
273
+ * characters as possible that are valid following a syntax that depends on the 'base' parameter,
274
+ * and interprets them as a numerical value. Finally, a position of the first character following
275
+ * the integer representation in 'string' is stored in 'endPos'.
276
+ *
277
+ * If the value of 'base' is zero, the syntax expected is similar to that of integer constants,
278
+ * which is formed by a succession of :
279
+ * An optional sign character (+ or -)
280
+ * An optional prefix indicating octal or hexadecimal base ("0" or "0x"/"0X" respectively)
281
+ * A sequence of decimal digits (if no base prefix was specified) or either octal or hexadecimal digits if a specific prefix is present
282
+ *
283
+ * If the 'base' value is between 2 and 36, the format expected for the integral number is a succession
284
+ * of any of the valid digits and/or letters needed to represent integers of the specified radix
285
+ * (starting from '0' and up to 'z'/'Z' for radix 36). The sequence may optionally be preceded by
286
+ * a sign (either + or -) and, if base is 16, an optional "0x" or "0X" prefix.
287
+ *
288
+ * If the first sequence of non-whitespace characters in 'string' is not a valid integral number
289
+ * as defined above, or if no such sequence exists because either 'string' is empty or it contains
290
+ * only whitespace characters, no conversion is performed.
291
+ *
292
+ * @param string The string to parse.
293
+ * @param endPos The position of the first character following the number.
294
+ * On success and when containing only numbers, position is at the end of string, meaning equal to 'string' length.
295
+ * On failure, position is sets always to 0.
296
+ * @param base The numerical base (radix) that determines the valid characters and their interpretation.
297
+ * If this is 0, the base used is determined by the format in the sequence.
298
+ * @return On success, the function returns the converted integral number as integer value.
299
+ * If no valid conversion could be performed, a zero value is returned.
300
+ * If the value read is out of the range of representable values by a cell,
301
+ * the function returns 'cellmin' or 'cellmax'.
302
+ */
303
+ native strtol(const string[], &endPos = 0, base = 0);
304
+
305
+ /**
306
+ * Parses the 'string' interpreting its content as an floating point number and returns its value as a float.
307
+ * The function also sets the value of 'endPos' to point to the position of the first character after the number.
308
+ *
309
+ * This is the same as C++ strtod function with a difference on second param.
310
+ *
311
+ * The function first discards as many whitespace characters as necessary until the first
312
+ * non-whitespace character is found. Then, starting from this character, takes as many
313
+ * characters as possible that are valid and interprets them as a numerical value.
314
+ * Finally, a position of the first character following the float representation in 'string'
315
+ * is stored in 'endPos'.
316
+ *
317
+ * If the first sequence of non-whitespace characters in 'string' is not a valid float number
318
+ * as defined above, or if no such sequence exists because either 'string' is empty or it contains
319
+ * only whitespace characters, no conversion is performed.
320
+ *
321
+ * @param string The string to parse.
322
+ * @param endPos The position of the first character following the number.
323
+ * On success and when containing only numbers, position is at the end of string, meaning equal to 'string' length.
324
+ * On failure, position is sets always to 0.
325
+ * @return On success, the function returns the converted floating point number as float value.
326
+ * If no valid conversion could be performed, a zero value is returned.
327
+ */
328
+ native Float:strtof(const string[], &endPos = 0);
329
+
330
+ /**
331
+ * Converts a floating point number to a string.
332
+ *
333
+ * @param fl Floating point number to convert.
334
+ * @param string Buffer to store string in.
335
+ * @param len Maximum length of string buffer.
336
+ *
337
+ * @return Number of cells written to buffer.
338
+ */
339
+ native float_to_str(Float:fl, string[], len);
340
+
341
+ /**
342
+ * Converts a string to a floating point number.
343
+ *
344
+ * @param string String to convert to a foat.
345
+ * @return Floating point result, or 0.0 on error.
346
+ */
347
+ native Float:str_to_float(const string[]);
348
+
349
+ /**
350
+ * Returns whether two strings are equal.
351
+ *
352
+ * @param a First string (left).
353
+ * @param b Second string (right).
354
+ * @param c Number of characters to compare.
355
+ *
356
+ * @return True if equal, false otherwise.
357
+ */
358
+ native equal(const a[],const b[],c=0);
359
+
360
+ /**
361
+ * Returns whether two strings are equal with case ignoring.
362
+ *
363
+ * @note This supports multi-byte characters (UTF-8) on comparison.
364
+ *
365
+ * @param a First string (left).
366
+ * @param b Second string (right).
367
+ * @param c Number of characters to compare.
368
+ *
369
+ * @return True if equal, false otherwise.
370
+ */
371
+ native equali(const a[], const b[], c = 0);
372
+
373
+ /**
374
+ * Copies one string to another string.
375
+ *
376
+ * @note If the destination buffer is too small to hold the source string, the
377
+ * destination will be truncated.
378
+ *
379
+ * @param dest Destination string buffer to copy to.
380
+ * @param len Destination buffer length.
381
+ * @param src Source string buffer to copy from.
382
+ *
383
+ * @return Number of cells written.
384
+ */
385
+ native copy(dest[],len,const src[]);
386
+
387
+ /**
388
+ * Copies one string to another string until ch is found.
389
+ *
390
+ * @param dest Destination string buffer to copy to.
391
+ * @param len Destination buffer length.
392
+ * @param src Source string buffer to copy from.
393
+ * @param ch Character to search for.
394
+ *
395
+ * @return Number of cells written.
396
+ */
397
+ native copyc(dest[],len,const src[],ch);
398
+
399
+ /**
400
+ * Sets string with given character.
401
+ *
402
+ * @param src Destination string buffer to copy to.
403
+ * @param len Destination buffer length.
404
+ * @param ch Character to set string.
405
+ *
406
+ * @noreturn
407
+ */
408
+ native setc(src[],len,ch);
409
+
410
+ /**
411
+ * Gets parameters from text.
412
+ *
413
+ * @note Example: to split text: "^"This is^" the best year",
414
+ * call function like this: parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
415
+ * and you will get: "This is", "the", "best", "year"
416
+ * Function returns number of parsed parameters.
417
+ *
418
+ * @param text String to parse.
419
+ * @param ... Variable number of format parameters.
420
+ *
421
+ * @return Number of parsed parameters.
422
+ */
423
+ native parse(const text[], ... );
424
+
425
+ /**
426
+ * Breaks a string in two by token.
427
+ *
428
+ * @note Trimming spaces is buggy. Consider strtok2 instead.
429
+ *
430
+ * @note See argbreak() for doing this with parameters.
431
+ * Example:
432
+ * str1[] = This *is*some text
433
+ * strtok(str1, left, 24, right, 24, '*')
434
+ * left will be "This "
435
+ * Right will be "is*some text"
436
+ * If you use trimSpaces, all spaces are trimmed from Left.
437
+ *
438
+ * @param text String to tokenize
439
+ * @param Left Buffer to store left half
440
+ * @param leftLen Size of left buffer
441
+ * @param Right Buffer to store right half
442
+ * @param rightLen Size of right buffer
443
+ * @param token Token to split by
444
+ * @param trimSpaces Whether spaces are trimmed.
445
+ *
446
+ * @noreturn
447
+ */
448
+ native strtok(const text[], Left[], leftLen, Right[], rightLen, token=' ', trimSpaces=0);
449
+
450
+ /**
451
+ * Breaks a string in two by token.
452
+ *
453
+ * @note Only available in 1.8.3 and above.
454
+ *
455
+ * @param text String to tokenize
456
+ * @param left Buffer to store left half
457
+ * @param llen Size of left buffer
458
+ * @param right Buffer to store right half
459
+ * @param rlen Size of right buffer
460
+ * @param token Token to split by
461
+ * @param trim Flags for trimming behavior, see above
462
+ *
463
+ * @return Returns position of token in string if found,
464
+ * -1 if token was not found
465
+ */
466
+ native strtok2(const text[], left[], const llen, right[], const rlen, const token = ' ', const trim = 0);
467
+
468
+ /**
469
+ * Removes whitespace characters from the beginning and end of a string.
470
+ *
471
+ * @param text The string to trim.
472
+ * @return Number of bytes written.
473
+ */
474
+ native trim(text[]);
475
+
476
+ /**
477
+ * Converts all chars in string to lower case.
478
+ *
479
+ * @param string The string to convert.
480
+ * @return Number of bytes written.
481
+ */
482
+ native strtolower(string[]);
483
+
484
+ /**
485
+ * Performs a multi-byte safe (UTF-8) conversion of all chars in string to lower case.
486
+ *
487
+ * @note Although most code points can be converted in-place, there are notable
488
+ * exceptions and the final length can vary.
489
+ * @note Case mapping is not reversible. That is, toUpper(toLower(x)) != toLower(toUpper(x)).
490
+ *
491
+ * @param string The string to convert.
492
+ * @param maxlength Optional size of the buffer. If 0, the length of the original string
493
+ * will be used instead.
494
+ *
495
+ * @return Number of bytes written.
496
+ */
497
+ native mb_strtolower(string[], maxlength = 0);
498
+
499
+ /**
500
+ * Converts all chars in string to upper case.
501
+ *
502
+ * @param string The string to convert.
503
+ * @return Number of bytes written.
504
+ */
505
+ native strtoupper(string[]);
506
+
507
+ /**
508
+ * Performs a multi-byte safe (UTF-8) conversion of all chars in string to upper case.
509
+ *
510
+ * @note Although most code points can be converted in-place, there are notable
511
+ * exceptions and the final length can vary.
512
+ * @note Case mapping is not reversible. That is, toUpper(toLower(x)) != toLower(toUpper(x)).
513
+ *
514
+ * @param string The string to convert.
515
+ * @param maxlength Optional size of the buffer. If 0, the length of the original string
516
+ * will be used instead.
517
+ *
518
+ * @return Number of bytes written.
519
+ */
520
+ native mb_strtoupper(string[], maxlength = 0);
521
+
522
+ /**
523
+ * Make a string's first character uppercase.
524
+ *
525
+ * @param string The string to convert.
526
+ * @return 1 on success, otherwise 0.
527
+ */
528
+ native ucfirst(string[]);
529
+
530
+ /**
531
+ * Performs a multi-byte safe (UTF-8) conversion of a string's first character to upper case.
532
+ *
533
+ * @note Although most code points can be converted in-place, there are notable
534
+ * exceptions and the final length can vary.
535
+ *
536
+ * @param string The string to convert.
537
+ * @param maxlength Optional size of the buffer. If 0, the length of the original string
538
+ * will be used instead.
539
+ *
540
+ * @return Number of bytes written.
541
+ */
542
+ native mb_ucfirst(string[], maxlength = 0);
543
+
544
+ /**
545
+ * Performs a multi-byte safe (UTF-8) conversion of all chars in string to title case.
546
+ *
547
+ * @note Although most code points can be converted in-place, there are notable
548
+ * exceptions and the final length can vary.
549
+ * @note Any type of punctuation can break up a word, even if this is
550
+ * not grammatically valid. This happens because the titlecasing algorithm
551
+ * does not and cannot take grammar rules into account.
552
+ * @note Examples:
553
+ * The running man | The Running Man
554
+ * NATO Alliance | Nato Alliance
555
+ * You're amazing at building libraries | You'Re Amazing At Building Libraries
556
+ *
557
+ * @param string The string to convert.
558
+ * @param maxlength Optional size of the buffer. If 0, the length of the original string
559
+ * will be used instead.
560
+ *
561
+ * @return Number of bytes written.
562
+ */
563
+ native mb_strtotitle(string[], maxlength = 0);
564
+
565
+ /**
566
+ * Checks if the input string conforms to the category specified by the flags.
567
+ *
568
+ * @note This function can be used to check if the code points in a string are part
569
+ * of a category. Valid flags are part of the UTF8C_* list of defines.
570
+ * The category for a code point is defined as part of the entry in
571
+ * UnicodeData.txt, the data file for the Unicode code point database.
572
+ * @note Flags parameter must be a combination of UTF8C_* flags or a single UTF8C_IS* flag.
573
+ * In order to main backwards compatibility with POSIX functions like `isdigit`
574
+ * and `isspace`, compatibility flags have been provided. Note, however, that
575
+ * the result is only guaranteed to be correct for code points in the Basic
576
+ * Latin range, between U+0000 and 0+007F. Combining a compatibility flag with
577
+ * a regular category flag will result in undefined behavior.
578
+ * @note The function is greedy. This means it will try to match as many code
579
+ * points with the matching category flags as possible and return the offset in
580
+ * the input in bytes.
581
+ *
582
+ * @param input The string to check
583
+ * @param input_size Size of the string, use 1 to check one character regardless its size
584
+ * @param flags Requested category, see UTF8C_* flags
585
+ * @param output_size Number of bytes in the input that conform to the specified
586
+ * category flags
587
+ * @return True if the whole input of `input_size` conforms to the specified
588
+ * category flags, false otherwise
589
+ */
590
+ native bool:is_string_category(const input[], input_size, flags, &output_size = 0);
591
+
592
+ /**
593
+ * Returns whether a character is numeric.
594
+ *
595
+ * @note Multi-byte characters will always return false.
596
+ *
597
+ * @param ch Character to test.
598
+ * @return True if character is numeric, otherwise false.
599
+ */
600
+ native isdigit(ch);
601
+
602
+ /**
603
+ * Returns whether a character is an ASCII alphabet character.
604
+ *
605
+ * @note Multi-byte characters will always return false.
606
+ *
607
+ * @param ch Character to test.
608
+ * @return True if character is alphabetical, otherwise false.
609
+ */
610
+ native isalpha(ch);
611
+
612
+ /**
613
+ * Returns whether a character is whitespace.
614
+ *
615
+ * @note Multi-byte characters will always return false.
616
+ *
617
+ * @param ch Character to test.
618
+ * @return True if character is whitespace, otherwise false.
619
+ */
620
+ native isspace(ch);
621
+
622
+ /**
623
+ * Returns whether a character is numeric or an ASCII alphabet character.
624
+ *
625
+ * @note Multi-byte characters will always return false.
626
+ *
627
+ * @param ch Character to test.
628
+ * @return True if character is numeric, otherwise false.
629
+ */
630
+ native isalnum(ch);
631
+
632
+ /**
633
+ * Returns if a character is multi-byte or not.
634
+ *
635
+ * @note Only available in 1.8.3 and above.
636
+ *
637
+ * @param ch Character to test.
638
+ * @return 0 for a normal 7-bit ASCII character,
639
+ * otherwise number of bytes in multi-byte character.
640
+ */
641
+ native is_char_mb(ch);
642
+
643
+ /**
644
+ * Returns whether an alphabetic character is uppercase.
645
+ *
646
+ * @note Only available in 1.8.3 and above.
647
+ * @note Multi-byte characters will always return false.
648
+ *
649
+ * @param ch Character to test.
650
+ * @return True if character is uppercase, otherwise false.
651
+ */
652
+ native bool:is_char_upper(ch);
653
+
654
+ /**
655
+ * Returns whether an alphabetic character is lowercase.
656
+ *
657
+ * @note Only available in 1.8.3 and above.
658
+ * @note Multi-byte characters will always return false.
659
+ *
660
+ * @param ch Character to test.
661
+ * @return True if character is lowercase, otherwise false.
662
+ */
663
+ native bool:is_char_lower(ch);
664
+
665
+ /**
666
+ * Returns the number of bytes a character is using. This is
667
+ * for multi-byte characters (UTF-8). For normal ASCII characters,
668
+ * this will return 1.
669
+ *
670
+ * @note Only available in 1.8.3 and above.
671
+ *
672
+ * @param source Source input string.
673
+ * @return Number of bytes the current character uses.
674
+ */
675
+ native get_char_bytes(const source[]);
676
+
677
+ /**
678
+ * Concatenates one string onto another.
679
+ *
680
+ * @param dest String to append to.
681
+ * @param source Source string to concatenate.
682
+ * @param maxlength Maximum length of entire buffer.
683
+ * @return Number of bytes written.
684
+ */
685
+ native strcat(dest[], const source[], maxlength);
686
+
687
+ /**
688
+ * Tests whether a string is found inside another string.
689
+ *
690
+ * @note This supports multi-byte characters (UTF-8) on case insensitive comparison.
691
+ *
692
+ * @param string String to search in.
693
+ * @param sub Substring to find inside the original string.
694
+ * @param ignorecase If true, search is case insensitive.
695
+ * If false (default), search is case sensitive.
696
+ * @param pos Start position to search from.
697
+ * @return -1 on failure (no match found). Any other value
698
+ * indicates a position in the string where the match starts.
699
+ */
700
+ native strfind(const string[], const sub[], bool:ignorecase = false, pos = 0);
701
+
702
+ /**
703
+ * Compares two strings lexographically.
704
+ *
705
+ * @note This supports multi-byte characters (UTF-8) on case insensitive comparison.
706
+ *
707
+ * @param string1 First string (left).
708
+ * @param string2 Second string (right).
709
+ * @param ignorecase If true, comparison is case insensitive.
710
+ * If false (default), comparison is case sensitive.
711
+ * @return -1 if string1 < string2
712
+ * 0 if string1 == string2
713
+ * 1 if string1 > string2
714
+ */
715
+ native strcmp(const string1[], const string2[], bool:ignorecase = false);
716
+
717
+ /**
718
+ * Compares two strings parts lexographically.
719
+ *
720
+ * @note Only available in 1.8.3 and above.
721
+ * @note This supports multi-byte characters (UTF-8) on case insensitive comparison.
722
+ *
723
+ * @param string1 First string (left).
724
+ * @param string2 Second string (right).
725
+ * @param num Number of characters to compare.
726
+ * @param ignorecase If true, comparison is case insensitive.
727
+ * If false (default), comparison is case sensitive.
728
+ * @return -1 if string1 < string2
729
+ * 0 if string1 == string2
730
+ * 1 if string1 > string2
731
+ */
732
+ native strncmp(const string1[], const string2[], num, bool:ignorecase = false);
733
+
734
+ /**
735
+ * Parses an argument string to find the first argument. You can use this to
736
+ * replace strbreak().
737
+ *
738
+ * @note Only available in 1.8.3 and above.
739
+ *
740
+ * @note You can use argparse() to break a string into all of its arguments:
741
+ * new arg[N], pos;
742
+ * while (true) {
743
+ * pos = argparse(string, pos, arg, sizeof(arg) - 1);
744
+ * if (pos == -1)
745
+ * break;
746
+ * }
747
+ *
748
+ * @note All initial whitespace is removed. Remaining characters are read until an
749
+ * argument separator is encountered. A separator is any whitespace not inside
750
+ * a double-quotation pair (i.e. "x b" is one argument). If only one quotation
751
+ * mark appears, argparse() acts as if one existed at the end of the string.
752
+ * Quotation marks are never written back, and do not act as separators. For
753
+ * example, "a""b""c" will return "abc". An empty quote pair ("") will count
754
+ * as an argument containing no characters.
755
+ *
756
+ * @note argparse() will write an empty string to argbuffer if no argument is found.
757
+ *
758
+ * @param text String to tokenize.
759
+ * @param pos Position to start parsing from.
760
+ * @param argbuffer Buffer to store first argument.
761
+ * @param maxlen Size of the buffer.
762
+ * @return If no argument was found, -1 is returned. Otherwise,
763
+ * the index to the next position to parse from is
764
+ * returned. This might be the very end of the string.
765
+ */
766
+ native argparse(const text[], pos, argbuffer[], maxlen);
767
+
768
+ /**
769
+ * Returns text in a string up until a certain character sequence is reached.
770
+ *
771
+ * @note Only available in 1.8.3 and above.
772
+ *
773
+ * @param source Source input string.
774
+ * @param split A string which specifies a search point to break at.
775
+ * @param part Buffer to store string part.
776
+ * @param partLen Maximum length of the string part buffer.
777
+ *
778
+ * @return -1 if no match was found; otherwise, an index into source
779
+ * marking the first index after the searched text. The
780
+ * index is always relative to the start of the input string.
781
+ */
782
+ native split_string(const source[], const split[], part[], partLen);
783
+
784
+
785
+ // Always keep this at the bottom of this file.
786
+ #include <string_stocks>