@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.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/README.ru.md +162 -0
- package/amxmodx/base/include/amxconst.inc +594 -0
- package/amxmodx/base/include/amxmisc.inc +902 -0
- package/amxmodx/base/include/amxmodx.inc +3447 -0
- package/amxmodx/base/include/amxmodx_version.inc +20 -0
- package/amxmodx/base/include/cellarray.inc +525 -0
- package/amxmodx/base/include/cellstack.inc +166 -0
- package/amxmodx/base/include/celltrie.inc +412 -0
- package/amxmodx/base/include/core.inc +202 -0
- package/amxmodx/base/include/csstats.inc +298 -0
- package/amxmodx/base/include/csstats_const.inc +29 -0
- package/amxmodx/base/include/cstrike.inc +1287 -0
- package/amxmodx/base/include/cstrike_const.inc +521 -0
- package/amxmodx/base/include/csx.inc +259 -0
- package/amxmodx/base/include/cvars.inc +547 -0
- package/amxmodx/base/include/datapack.inc +161 -0
- package/amxmodx/base/include/dbi.inc +154 -0
- package/amxmodx/base/include/dodconst.inc +152 -0
- package/amxmodx/base/include/dodfun.inc +152 -0
- package/amxmodx/base/include/dodstats.inc +69 -0
- package/amxmodx/base/include/dodx.inc +161 -0
- package/amxmodx/base/include/engine.inc +1343 -0
- package/amxmodx/base/include/engine_const.inc +310 -0
- package/amxmodx/base/include/engine_stocks.inc +248 -0
- package/amxmodx/base/include/esf.inc +70 -0
- package/amxmodx/base/include/esf_const.inc +74 -0
- package/amxmodx/base/include/fakemeta.inc +1127 -0
- package/amxmodx/base/include/fakemeta_const.inc +793 -0
- package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
- package/amxmodx/base/include/fakemeta_util.inc +882 -0
- package/amxmodx/base/include/file.inc +666 -0
- package/amxmodx/base/include/float.inc +422 -0
- package/amxmodx/base/include/fun.inc +333 -0
- package/amxmodx/base/include/gameconfig.inc +93 -0
- package/amxmodx/base/include/geoip.inc +264 -0
- package/amxmodx/base/include/ham_const.inc +4352 -0
- package/amxmodx/base/include/hamsandwich.inc +439 -0
- package/amxmodx/base/include/hlsdk_const.inc +808 -0
- package/amxmodx/base/include/json.inc +777 -0
- package/amxmodx/base/include/lang.inc +119 -0
- package/amxmodx/base/include/message_const.inc +1130 -0
- package/amxmodx/base/include/message_stocks.inc +161 -0
- package/amxmodx/base/include/messages.inc +604 -0
- package/amxmodx/base/include/newmenus.inc +387 -0
- package/amxmodx/base/include/ns.inc +754 -0
- package/amxmodx/base/include/ns_const.inc +196 -0
- package/amxmodx/base/include/nvault.inc +154 -0
- package/amxmodx/base/include/regex.inc +348 -0
- package/amxmodx/base/include/sockets.inc +183 -0
- package/amxmodx/base/include/sorting.inc +107 -0
- package/amxmodx/base/include/sqlx.inc +582 -0
- package/amxmodx/base/include/string.inc +786 -0
- package/amxmodx/base/include/string_const.inc +156 -0
- package/amxmodx/base/include/string_stocks.inc +325 -0
- package/amxmodx/base/include/textparse_ini.inc +214 -0
- package/amxmodx/base/include/textparse_smc.inc +261 -0
- package/amxmodx/base/include/tfcconst.inc +84 -0
- package/amxmodx/base/include/tfcstats.inc +62 -0
- package/amxmodx/base/include/tfcx.inc +148 -0
- package/amxmodx/base/include/time.inc +118 -0
- package/amxmodx/base/include/tsconst.inc +154 -0
- package/amxmodx/base/include/tsfun.inc +198 -0
- package/amxmodx/base/include/tsstats.inc +65 -0
- package/amxmodx/base/include/tsx.inc +88 -0
- package/amxmodx/base/include/vault.inc +60 -0
- package/amxmodx/base/include/vector.inc +131 -0
- package/amxmodx/base/include/xs.inc +1570 -0
- package/as/amxts.d.ts +153 -0
- package/as/constants.ts +4730 -0
- package/as/effects.ts +1449 -0
- package/as/entities.ts +5482 -0
- package/as/events.ts +3054 -0
- package/as/facade.ts +4639 -0
- package/as/flags.ts +299 -0
- package/as/fs.ts +287 -0
- package/as/hooks.ts +18536 -0
- package/as/kit.ts +25 -0
- package/as/lib/check.ts +86 -0
- package/as/modules/http.ts +184 -0
- package/as/natives.ts +11845 -0
- package/as/os.ts +30 -0
- package/as/promise.ts +1392 -0
- package/as/promise.types.d.ts +82 -0
- package/as/remote.ts +288 -0
- package/as/tsconfig.json +22 -0
- package/as/vector.ts +65 -0
- package/bin/amxts.mjs +10 -0
- package/includes/menu_core.inc +355 -0
- package/includes/order.txt +54 -0
- package/includes/sources.json +27 -0
- package/includes/universal_config.inc +355 -0
- package/lint/oxlint-plugin.mjs +77 -0
- package/node_modules/assemblyscript/LICENSE +201 -0
- package/node_modules/assemblyscript/NOTICE +93 -0
- package/node_modules/assemblyscript/package.json +63 -0
- package/node_modules/assemblyscript/std/README.md +6 -0
- package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
- package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
- package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
- package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
- package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
- package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
- package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
- package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
- package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
- package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
- package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
- package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
- package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
- package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
- package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
- package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
- package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
- package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
- package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
- package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
- package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
- package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
- package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
- package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
- package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
- package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
- package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
- package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
- package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
- package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
- package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
- package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
- package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
- package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
- package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
- package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
- package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
- package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
- package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
- package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
- package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
- package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
- package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
- package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
- package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
- package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
- package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
- package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
- package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
- package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
- package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
- package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
- package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
- package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
- package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
- package/node_modules/assemblyscript/std/assembly.json +16 -0
- package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
- package/node_modules/assemblyscript/std/portable/index.js +416 -0
- package/node_modules/assemblyscript/std/portable.json +11 -0
- package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
- package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
- package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
- package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
- package/node_modules/assemblyscript/tsconfig-base.json +13 -0
- package/package.json +112 -0
- package/runtime/deps/assemblyscript/LICENSE +201 -0
- package/runtime/deps/assemblyscript/NOTICE +93 -0
- package/runtime/deps/assemblyscript/bin/asc.js +35 -0
- package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
- package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
- package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
- package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
- package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
- package/runtime/deps/assemblyscript/package.json +114 -0
- package/runtime/host/amxts.inc +85 -0
- package/runtime/licenses/AMXX-LICENSE.txt +34 -0
- package/runtime/licenses/AssemblyScript-LICENSE +201 -0
- package/runtime/licenses/AssemblyScript-NOTICE +93 -0
- package/runtime/licenses/Binaryen-LICENSE +201 -0
- package/runtime/licenses/Bun-LICENSE.md +84 -0
- package/runtime/licenses/GPL-3.0.txt +674 -0
- package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
- package/runtime/licenses/README.md +25 -0
- package/runtime/licenses/WAMR-LICENSE +219 -0
- package/runtime/natives.txt +1095 -0
- package/runtime/patches/README.md +59 -0
- package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
- package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
- package/scripts/apply-docs.ts +508 -0
- package/scripts/asc.ts +27 -0
- package/scripts/auto-imports.ts +258 -0
- package/scripts/build-wasm.ts +595 -0
- package/scripts/check.ts +93 -0
- package/scripts/compile-cache.ts +179 -0
- package/scripts/compile.ts +401 -0
- package/scripts/docker-server.ts +73 -0
- package/scripts/docs/as/amxts.ts +210 -0
- package/scripts/docs/as/effects.ts +1684 -0
- package/scripts/docs/as/facade.ts +3302 -0
- package/scripts/docs/as/fs.ts +173 -0
- package/scripts/docs/as/lib/check.ts +68 -0
- package/scripts/docs/as/modules/http.ts +66 -0
- package/scripts/docs/as/os.ts +16 -0
- package/scripts/docs/as/promise.ts +132 -0
- package/scripts/docs/as/promise.types.ts +63 -0
- package/scripts/docs/as/vector.ts +48 -0
- package/scripts/docs/entities.ts +2338 -0
- package/scripts/docs/events.ts +245 -0
- package/scripts/docs/game.ts +497 -0
- package/scripts/docs/messages.ts +148 -0
- package/scripts/file-contents.ts +74 -0
- package/scripts/includes.ts +134 -0
- package/scripts/player-fields.ts +866 -0
- package/scripts/plugin-cache.ts +92 -0
- package/scripts/plugin-natives.ts +1157 -0
- package/scripts/prebuilt.ts +268 -0
- package/scripts/prepare.ts +134 -0
- package/scripts/project.ts +973 -0
- package/scripts/run.ts +28 -0
- package/scripts/shared-modules.ts +906 -0
- package/scripts/system.ts +33 -0
- package/scripts/tracked-fs.ts +115 -0
- package/scripts/typed-configs.ts +788 -0
- package/scripts/ui.ts +77 -0
- package/src/cli-api.mjs +175 -0
- package/src/parser/include-parser.ts +506 -0
- package/src/system.mjs +155 -0
- package/src/testing/compile-cache.ts +31 -0
- package/src/testing/compile.ts +222 -0
- package/src/testing/coroutines.ts +191 -0
- package/src/testing/index.ts +39 -0
- package/src/testing/kits.ts +55 -0
- package/src/testing/memory.ts +125 -0
- package/src/testing/natives.ts +925 -0
- package/src/testing/server.ts +1874 -0
- package/src/testing/setup.ts +63 -0
- package/src/testing/tables.ts +139 -0
- package/src/types.ts +51 -0
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
// SMC Parser Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _textparse_smc_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _textparse_smc_included
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Everything below describes the SMC Parse, or "SourceMod Configuration" format.
|
|
21
|
+
* This parser is entirely event based. You must hook events to receive data.
|
|
22
|
+
* The file format itself is nearly identical to Valve's KeyValues format (also known as VDF).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The SMC file format is defined as:
|
|
27
|
+
* WHITESPACE: 0x20, \n, \t, \r
|
|
28
|
+
* IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, / *, or WHITESPACE.
|
|
29
|
+
* STRING : Any set of symbols enclosed in quotes.
|
|
30
|
+
*
|
|
31
|
+
* Note: if a STRING does not have quotes, it is parsed as an IDENTIFIER.
|
|
32
|
+
*
|
|
33
|
+
* Basic syntax is comprised of SECTIONBLOCKs.
|
|
34
|
+
* A SECTIONBLOCK defined as:
|
|
35
|
+
*
|
|
36
|
+
* SECTIONNAME
|
|
37
|
+
* {
|
|
38
|
+
* OPTION
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* OPTION can be repeated any number of times inside a SECTIONBLOCK.
|
|
42
|
+
* A new line will terminate an OPTION, but there can be more than one OPTION per line.
|
|
43
|
+
* OPTION is defined any of:
|
|
44
|
+
* "KEY" "VALUE"
|
|
45
|
+
* SECTIONBLOCK
|
|
46
|
+
*
|
|
47
|
+
* SECTIONNAME, KEY, VALUE, and SINGLEKEY are strings
|
|
48
|
+
* SECTIONNAME cannot have trailing characters if quoted, but the quotes can be optionally removed.
|
|
49
|
+
* If SECTIONNAME is not enclosed in quotes, the entire sectionname string is used (minus surrounding whitespace).
|
|
50
|
+
* If KEY is not enclosed in quotes, the key is terminated at first whitespace.
|
|
51
|
+
* If VALUE is not properly enclosed in quotes, the entire value string is used (minus surrounding whitespace).
|
|
52
|
+
* The VALUE may have inner quotes, but the key string may not.
|
|
53
|
+
*
|
|
54
|
+
* For an example, see scripting/testsuite/textparse_test.cfg
|
|
55
|
+
*
|
|
56
|
+
* WHITESPACE should be ignored.
|
|
57
|
+
* Comments are text occurring inside the following tokens, and should be stripped
|
|
58
|
+
* unless they are inside literal strings:
|
|
59
|
+
* ;<TEXT>
|
|
60
|
+
* //<TEXT>
|
|
61
|
+
* / *<TEXT> * /
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parser invalid code.
|
|
66
|
+
*/
|
|
67
|
+
enum SMCParser
|
|
68
|
+
{
|
|
69
|
+
Invalid_SMCParser = 0
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Parse result directive.
|
|
74
|
+
*/
|
|
75
|
+
enum SMCResult
|
|
76
|
+
{
|
|
77
|
+
SMCParse_Continue, /* Continue parsing */
|
|
78
|
+
SMCParse_Halt, /* Stop parsing here */
|
|
79
|
+
SMCParse_HaltFail /* Stop parsing and return failure */
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Parse error codes.
|
|
84
|
+
*/
|
|
85
|
+
enum SMCError
|
|
86
|
+
{
|
|
87
|
+
SMCError_Okay = 0, /* No error */
|
|
88
|
+
SMCError_StreamOpen, /* Stream failed to open */
|
|
89
|
+
SMCError_StreamError, /* The stream died... somehow */
|
|
90
|
+
SMCError_Custom, /* A custom handler threw an error */
|
|
91
|
+
SMCError_InvalidSection1, /* A section was declared without quotes, and had extra tokens */
|
|
92
|
+
SMCError_InvalidSection2, /* A section was declared without any header */
|
|
93
|
+
SMCError_InvalidSection3, /* A section ending was declared with too many unknown tokens */
|
|
94
|
+
SMCError_InvalidSection4, /* A section ending has no matching beginning */
|
|
95
|
+
SMCError_InvalidSection5, /* A section beginning has no matching ending */
|
|
96
|
+
SMCError_InvalidTokens, /* There were too many unidentifiable strings on one line */
|
|
97
|
+
SMCError_TokenOverflow, /* The token buffer overflowed */
|
|
98
|
+
SMCError_InvalidProperty1, /* A property was declared outside of any section */
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new SMC parser.
|
|
103
|
+
* This is used to set parse hooks.
|
|
104
|
+
*
|
|
105
|
+
* @return A new handle to an SMC Parse structure.
|
|
106
|
+
*/
|
|
107
|
+
native SMCParser:SMC_CreateParser();
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Disposes of an SMC parser.
|
|
111
|
+
*
|
|
112
|
+
* @param handle Handle to an SMC Parse structure.
|
|
113
|
+
*
|
|
114
|
+
* @return True if disposed, false otherwise.
|
|
115
|
+
*/
|
|
116
|
+
native SMC_DestroyParser(&SMCParser:handle);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Parses a config file.
|
|
120
|
+
*
|
|
121
|
+
* @param handle A handle to an SMC Parse structure.
|
|
122
|
+
* @param file A string containing the file path.
|
|
123
|
+
* @param line An optional by reference cell to store the last line number read.
|
|
124
|
+
* @param col An optional by reference cell to store the last column number read.
|
|
125
|
+
* @param data An optional handle or value to pass through to callback functions
|
|
126
|
+
*
|
|
127
|
+
* @return An SMCParseError result.
|
|
128
|
+
* @error Invalid or corrupt handle.
|
|
129
|
+
*/
|
|
130
|
+
native SMCError:SMC_ParseFile(SMCParser:handle, const file[], &line = 0, &col = 0, any:data = 0);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Sets the SMC_ParseStart function of a parse handle.
|
|
134
|
+
*
|
|
135
|
+
* @note Below is the prototype of callback:
|
|
136
|
+
* -
|
|
137
|
+
* Called when parsing is started.
|
|
138
|
+
*
|
|
139
|
+
* @param handle Handle to an SMC Parse structure.
|
|
140
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
141
|
+
*
|
|
142
|
+
* @noreturn
|
|
143
|
+
*
|
|
144
|
+
* public OnParseStart(SMCParser:handle, any:data)
|
|
145
|
+
* -
|
|
146
|
+
* @param handle Handle to an SMC Parse structure.
|
|
147
|
+
* @param func A ParseStart callback.
|
|
148
|
+
*
|
|
149
|
+
* @noreturn
|
|
150
|
+
* @error Invalid or corrupt handle.
|
|
151
|
+
*/
|
|
152
|
+
native SMC_SetParseStart(SMCParser:handle, const func[]);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Sets the SMC_ParseEnd function of a parse handle.
|
|
156
|
+
*
|
|
157
|
+
* @note Below is the prototype of callback:
|
|
158
|
+
* -
|
|
159
|
+
* Called when parsing is halted.
|
|
160
|
+
*
|
|
161
|
+
* @param handle Handle to an SMC Parse structure.
|
|
162
|
+
* @param halted True if abnormally halted, false otherwise.
|
|
163
|
+
* @param failed True if parsing failed, false otherwise.
|
|
164
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
165
|
+
*
|
|
166
|
+
* @noreturn
|
|
167
|
+
*
|
|
168
|
+
* public OnParseEnd(SMCParser:handle, bool:halted, bool:failed, any:data)
|
|
169
|
+
* -
|
|
170
|
+
* @param handle Handle to an SMC Parse structure.
|
|
171
|
+
* @param func A ParseEnd callback.
|
|
172
|
+
*
|
|
173
|
+
* @noreturn
|
|
174
|
+
* @error Invalid or corrupt handle.
|
|
175
|
+
*/
|
|
176
|
+
native SMC_SetParseEnd(SMCParser:handle, const func[]);
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sets the three main reader functions.
|
|
180
|
+
*
|
|
181
|
+
* @note Enclosing quotes are always stripped.
|
|
182
|
+
* @note Below is the prototype of callbacks:
|
|
183
|
+
* -
|
|
184
|
+
* NewSection:
|
|
185
|
+
* Called when the parser finds a new section or sub-section.
|
|
186
|
+
*
|
|
187
|
+
* @param handle Handle to an SMC Parse structure.
|
|
188
|
+
* @param name String containing section name.
|
|
189
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
190
|
+
*
|
|
191
|
+
* @return An SMCResult action to take.
|
|
192
|
+
*
|
|
193
|
+
* public SMCResult:OnNewSection(SMCParser:handle, const name[], any:data)
|
|
194
|
+
*
|
|
195
|
+
* KeyValue:
|
|
196
|
+
* Called when the parser finds a new key/value pair.
|
|
197
|
+
*
|
|
198
|
+
* @param handle Handle to an SMC Parse structure.
|
|
199
|
+
* @param key String containing key name.
|
|
200
|
+
* @param value String containing value name.
|
|
201
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
202
|
+
*
|
|
203
|
+
* @return An SMCResult action to take.
|
|
204
|
+
*
|
|
205
|
+
* public SMCResult:OnKeyValue(SMCParser:handle, const key[], const value[], any:data)
|
|
206
|
+
*
|
|
207
|
+
* EndSection:
|
|
208
|
+
* Called when the parser finds the end of the current section.
|
|
209
|
+
*
|
|
210
|
+
* @param handle Handle to an SMC Parse structure.
|
|
211
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
212
|
+
*
|
|
213
|
+
* @return An SMCResult action to take.
|
|
214
|
+
*
|
|
215
|
+
* public SMCResult:OnEndSection(SMCParser:handle, any:data)
|
|
216
|
+
* -
|
|
217
|
+
* @param handle Handle to an SMC Parse structure.
|
|
218
|
+
* @param kv A KeyValue callback.
|
|
219
|
+
* @param ns An optional NewSection callback.
|
|
220
|
+
* @param es An optional EndSection callback.
|
|
221
|
+
*
|
|
222
|
+
* @noreturn
|
|
223
|
+
*/
|
|
224
|
+
native SMC_SetReaders(SMCParser:smc, const kvFunc[], const nsFunc[] = "", const esFunc[] = "");
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Sets a raw line reader on an text parser handle.
|
|
228
|
+
*
|
|
229
|
+
* @note Below is the prototype of callbacks:
|
|
230
|
+
* -
|
|
231
|
+
* Called whenever a raw line is read.
|
|
232
|
+
*
|
|
233
|
+
* @param handle Handle to an SMC Parse structure.
|
|
234
|
+
* @param line A string containing the raw line from the file.
|
|
235
|
+
* @param lineno The line number it occurs on.
|
|
236
|
+
* @param data Handle or value passed in SMC_ParseFile
|
|
237
|
+
*
|
|
238
|
+
* @return An SMCResult action to take.
|
|
239
|
+
*
|
|
240
|
+
* public SMCResult:SMC_RawLine(SMCParser:handle, const line[], lineno, any:data)
|
|
241
|
+
* -
|
|
242
|
+
* @param handle Handle to an SMC Parse structure.
|
|
243
|
+
* @param func A RawLine callback.
|
|
244
|
+
*
|
|
245
|
+
* @noreturn
|
|
246
|
+
*/
|
|
247
|
+
native SMC_SetRawLine(SMCParser:handle, const func[]);
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Gets an error string for an SMCError code.
|
|
251
|
+
*
|
|
252
|
+
* @note SMCError_Okay returns false.
|
|
253
|
+
* @note SMCError_Custom (which is thrown on SMCParse_HaltFail) returns false.
|
|
254
|
+
*
|
|
255
|
+
* @param error The SMCParseError code.
|
|
256
|
+
* @param buffer A string buffer for the error (contents undefined on failure).
|
|
257
|
+
* @param buf_max The maximum size of the buffer.
|
|
258
|
+
*
|
|
259
|
+
* @return True on success, false otherwise.
|
|
260
|
+
*/
|
|
261
|
+
native bool:SMC_GetErrorString(SMCError:error, buffer[], buf_max);
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
// TFCX Constants
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _tfcconst_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _tfcconst_included
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#define TFCMAX_WEAPONS 37
|
|
21
|
+
|
|
22
|
+
enum {
|
|
23
|
+
TFC_AMMO_SHELLS = 0,
|
|
24
|
+
TFC_AMMO_BULLETS,
|
|
25
|
+
TFC_AMMO_CELLS,
|
|
26
|
+
TFC_AMMO_ROCKETS,
|
|
27
|
+
TFC_AMMO_NADE1,
|
|
28
|
+
TFC_AMMO_NADE2,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
enum {
|
|
32
|
+
TFC_WPN_NONE = 0,
|
|
33
|
+
TFC_WPN_TIMER,//TFC_WPN_UNK1,
|
|
34
|
+
TFC_WPN_SENTRYGUN,//TFC_WPN_UNK2,
|
|
35
|
+
TFC_WPN_MEDIKIT,
|
|
36
|
+
TFC_WPN_SPANNER,
|
|
37
|
+
TFC_WPN_AXE,
|
|
38
|
+
TFC_WPN_SNIPERRIFLE,
|
|
39
|
+
TFC_WPN_AUTORIFLE,
|
|
40
|
+
TFC_WPN_SHOTGUN,
|
|
41
|
+
TFC_WPN_SUPERSHOTGUN,
|
|
42
|
+
TFC_WPN_NG,
|
|
43
|
+
TFC_WPN_SUPERNG,
|
|
44
|
+
TFC_WPN_GL,
|
|
45
|
+
TFC_WPN_FLAMETHROWER,
|
|
46
|
+
TFC_WPN_RPG,
|
|
47
|
+
TFC_WPN_IC,
|
|
48
|
+
TFC_WPN_FLAMES,//TFC_WPN_UNK16,
|
|
49
|
+
TFC_WPN_AC,
|
|
50
|
+
TFC_WPN_UNK18,
|
|
51
|
+
TFC_WPN_UNK19,
|
|
52
|
+
TFC_WPN_TRANQ,
|
|
53
|
+
TFC_WPN_RAILGUN,
|
|
54
|
+
TFC_WPN_PL,
|
|
55
|
+
TFC_WPN_KNIFE,
|
|
56
|
+
TFC_WPN_CALTROP, // 24
|
|
57
|
+
TFC_WPN_CONCUSSIONGRENADE,
|
|
58
|
+
TFC_WPN_NORMALGRENADE,
|
|
59
|
+
TFC_WPN_NAILGRENADE,
|
|
60
|
+
TFC_WPN_MIRVGRENADE,
|
|
61
|
+
TFC_WPN_NAPALMGRENADE,
|
|
62
|
+
TFC_WPN_GASGRENADE,
|
|
63
|
+
TFC_WPN_EMPGRENADE,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
enum {
|
|
67
|
+
TFC_PC_SCOUT = 1,
|
|
68
|
+
TFC_PC_SNIPER,
|
|
69
|
+
TFC_PC_SOLDIER,
|
|
70
|
+
TFC_PC_DEMOMAN,
|
|
71
|
+
TFC_PC_MEDIC,
|
|
72
|
+
TFC_PC_HWGUY,
|
|
73
|
+
TFC_PC_PYRO,
|
|
74
|
+
TFC_PC_SPY,
|
|
75
|
+
TFC_PC_ENGENEER, // Typo; preserved for backward compatibility
|
|
76
|
+
TFC_PC_ENGINEER = 9,
|
|
77
|
+
TFC_PC_CIVILIAN = 11,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Goal items
|
|
81
|
+
#define TFC_GOALITEM_BLUE (1 << 17)
|
|
82
|
+
#define TFC_GOALITEM_RED (1 << 18)
|
|
83
|
+
#define TFC_GOALITEM_YELLOW (1 << 24)
|
|
84
|
+
#define TFC_GOALITEM_GREEN (1 << 25)
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
// TFCX Stats Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _tfcstats_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _tfcstats_included
|
|
18
|
+
|
|
19
|
+
/* Gets stats from given weapon index. If wpnindex is 0
|
|
20
|
+
* then the stats are from all weapons. If weapon has not been used function
|
|
21
|
+
* returns 0 in other case 1. Fields in stats are:
|
|
22
|
+
* 0 - kills
|
|
23
|
+
* 1 - deaths
|
|
24
|
+
* 2 - headshots
|
|
25
|
+
* 3 - teamkilling
|
|
26
|
+
* 4 - shots
|
|
27
|
+
* 5 - hits
|
|
28
|
+
* 6 - damage
|
|
29
|
+
* For body hits fields see amxconst.inc. */
|
|
30
|
+
native get_user_wstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]);
|
|
31
|
+
|
|
32
|
+
/* Gets round stats from given weapon index.*/
|
|
33
|
+
native get_user_wrstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]);
|
|
34
|
+
|
|
35
|
+
/* Gets overall stats which are stored in file on server
|
|
36
|
+
* and updated on every respawn or user disconnect.
|
|
37
|
+
* Function returns the position in stats by diff. kills to deaths. */
|
|
38
|
+
native get_user_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]);
|
|
39
|
+
|
|
40
|
+
/* Gets round stats of player. */
|
|
41
|
+
native get_user_rstats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]);
|
|
42
|
+
|
|
43
|
+
/* Gets stats with which user have killed/hurt his victim. If victim is 0
|
|
44
|
+
* then stats are from all victims. If victim has not been hurt, function
|
|
45
|
+
* returns 0 in other case 1. User stats are reset on his respawn. */
|
|
46
|
+
native get_user_vstats(index,victim,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0);
|
|
47
|
+
|
|
48
|
+
/* Gets stats with which user have been killed/hurt. If killer is 0
|
|
49
|
+
* then stats are from all attacks. If killer has not hurt user, function
|
|
50
|
+
* returns 0 in other case 1. User stats are reset on his respawn. */
|
|
51
|
+
native get_user_astats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0);
|
|
52
|
+
|
|
53
|
+
/* Resets life, weapon, victims and attackers user stats. */
|
|
54
|
+
native reset_user_wstats(index);
|
|
55
|
+
|
|
56
|
+
/* Gets overall stats which stored in stats.dat file in amx folder
|
|
57
|
+
* and updated on every mapchange or user disconnect.
|
|
58
|
+
* Function returns next index of stats entry or 0 if no more exists. */
|
|
59
|
+
native get_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],name[],len);
|
|
60
|
+
|
|
61
|
+
/* Returns number of all entries in stats. */
|
|
62
|
+
native get_statsnum();
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
// TFCX Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _tfcx_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _tfcx_included
|
|
18
|
+
|
|
19
|
+
#include <tfcconst>
|
|
20
|
+
#include <tfcstats>
|
|
21
|
+
|
|
22
|
+
#pragma reqclass xstats
|
|
23
|
+
#if !defined AMXMODX_NOAUTOLOAD
|
|
24
|
+
#pragma defclasslib xstats tfcx
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
/************* Shared Natives Start ********************************/
|
|
28
|
+
|
|
29
|
+
/* Forward types */
|
|
30
|
+
enum {
|
|
31
|
+
XMF_DAMAGE = 0,
|
|
32
|
+
XMF_DEATH,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/* Use this function to register forwards */
|
|
36
|
+
native register_statsfwd( ftype );
|
|
37
|
+
|
|
38
|
+
/* Function is called after player to player attacks ,
|
|
39
|
+
* if players were damaged by teammate TA is set to 1 */
|
|
40
|
+
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA);
|
|
41
|
+
|
|
42
|
+
/* Function is called after player death ,
|
|
43
|
+
* if player was killed by teammate TK is set to 1 */
|
|
44
|
+
forward client_death(killer,victim,wpnindex,hitplace,TK);
|
|
45
|
+
|
|
46
|
+
/* Custom Weapon Support */
|
|
47
|
+
/* function will return index of new weapon */
|
|
48
|
+
native custom_weapon_add( const wpnname[],melee = 0,const logname[]="" );
|
|
49
|
+
/* Function will pass damage done by this custom weapon to stats module and other plugins */
|
|
50
|
+
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
|
|
51
|
+
/* Function will pass info about custom weapon shot to stats module */
|
|
52
|
+
native custom_weapon_shot( weapon,index ); // weapon id , player id
|
|
53
|
+
|
|
54
|
+
/* function will return 1 if true */
|
|
55
|
+
native xmod_is_melee_wpn(wpnindex);
|
|
56
|
+
|
|
57
|
+
/* Returns weapon name. */
|
|
58
|
+
native xmod_get_wpnname(wpnindex,name[],len);
|
|
59
|
+
|
|
60
|
+
/* Returns weapon logname. */
|
|
61
|
+
native xmod_get_wpnlogname(wpnindex,name[],len);
|
|
62
|
+
|
|
63
|
+
/* Returns weapons array size */
|
|
64
|
+
native xmod_get_maxweapons();
|
|
65
|
+
|
|
66
|
+
/* Returns stats array size ex. 8 in TS , 9 in DoD */
|
|
67
|
+
native xmod_get_stats_size();
|
|
68
|
+
|
|
69
|
+
/* Returns 1 if true */
|
|
70
|
+
native xmod_is_custom_wpn(wpnindex);
|
|
71
|
+
|
|
72
|
+
/************* Shared Natives End ********************************/
|
|
73
|
+
|
|
74
|
+
stock tfc_isgrenade( weapon ){
|
|
75
|
+
switch( weapon )
|
|
76
|
+
{
|
|
77
|
+
case TFC_WPN_CALTROP,
|
|
78
|
+
TFC_WPN_CONCUSSIONGRENADE,
|
|
79
|
+
TFC_WPN_NORMALGRENADE,
|
|
80
|
+
TFC_WPN_NAILGRENADE,
|
|
81
|
+
TFC_WPN_MIRVGRENADE,
|
|
82
|
+
TFC_WPN_NAPALMGRENADE,
|
|
83
|
+
TFC_WPN_GASGRENADE,
|
|
84
|
+
TFC_WPN_EMPGRENADE:
|
|
85
|
+
return 1;
|
|
86
|
+
default: return 0;
|
|
87
|
+
}
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
native tfc_userkill( index );
|
|
92
|
+
|
|
93
|
+
/* Use this function to set private data offsets if needed
|
|
94
|
+
Default offsets:
|
|
95
|
+
timer: 932
|
|
96
|
+
sentrygun: 83
|
|
97
|
+
from AssKicR
|
|
98
|
+
shells: 53
|
|
99
|
+
bullets: 55
|
|
100
|
+
cells: 57
|
|
101
|
+
rockets: 59
|
|
102
|
+
nade1: 14
|
|
103
|
+
nade2: 15
|
|
104
|
+
*/
|
|
105
|
+
native tfc_setpddata(timer,sentrygun,shells,bullets,cells,rockets,nade1,nade2);
|
|
106
|
+
|
|
107
|
+
/*********************************************************************/
|
|
108
|
+
|
|
109
|
+
native tfc_setmodel(index, const Model[], const Skin[]);
|
|
110
|
+
native tfc_clearmodel(index);
|
|
111
|
+
|
|
112
|
+
/* Get amount of ammo in backpack on a user for a specific weapon */
|
|
113
|
+
/* Ammo Types in tfcconst.inc */
|
|
114
|
+
native tfc_getbammo(index, ammo);
|
|
115
|
+
|
|
116
|
+
/* Set amount of ammo in backpack on a user for a specific weapon */
|
|
117
|
+
native tfc_setbammo(index, ammo, value);
|
|
118
|
+
|
|
119
|
+
/* Returns amount of ammo in weapon's clip (backpack) */
|
|
120
|
+
/* Weapons list in tfcconst.inc */
|
|
121
|
+
native tfc_getweaponbammo(index, weapon);
|
|
122
|
+
|
|
123
|
+
/* Sets amount of ammo in weapon's clip (backpack) */
|
|
124
|
+
native tfc_setweaponbammo(index, weapon, value);
|
|
125
|
+
|
|
126
|
+
/* Returns amount of ammo in weapon's clip */
|
|
127
|
+
/* Index must be weapon's entity index */
|
|
128
|
+
native tfc_getweaponammo(index);
|
|
129
|
+
|
|
130
|
+
/* Sets amount of ammo in weapon's clip */
|
|
131
|
+
/* Index must be weapon's entity index */
|
|
132
|
+
native tfc_setweaponammo(index, value);
|
|
133
|
+
|
|
134
|
+
/* Returns 1 if user is carrying a goal item such as a flag or a keycard, else 0.
|
|
135
|
+
* Team is by reference parameter that will be set to owning team(s) of the goal item.
|
|
136
|
+
* Use the TFC_GOALITEM_* constants to determine the owning team.
|
|
137
|
+
*/
|
|
138
|
+
native tfc_get_user_goalitem(index, &team);
|
|
139
|
+
|
|
140
|
+
/* Returns 1 if the player is a spy and is currently feigning death */
|
|
141
|
+
native tfc_is_user_feigning(index);
|
|
142
|
+
|
|
143
|
+
/* Returns 1 if the two teams are allies, 0 otherwise
|
|
144
|
+
* Note: Team must be 1->4
|
|
145
|
+
* Team 0 will always return 0
|
|
146
|
+
* Any other team will result in an error
|
|
147
|
+
*/
|
|
148
|
+
native tfc_is_team_ally(TeamA,TeamB);
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
// Time Specific Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _time_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _time_included
|
|
18
|
+
|
|
19
|
+
/* Time unit types for get_time_length() */
|
|
20
|
+
enum
|
|
21
|
+
{
|
|
22
|
+
timeunit_seconds = 0,
|
|
23
|
+
timeunit_minutes,
|
|
24
|
+
timeunit_hours,
|
|
25
|
+
timeunit_days,
|
|
26
|
+
timeunit_weeks,
|
|
27
|
+
timeunit_months,
|
|
28
|
+
timeunit_years,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/* Seconds in each time unit */
|
|
32
|
+
#define SECONDS_IN_MINUTE 60
|
|
33
|
+
#define SECONDS_IN_HOUR 3600
|
|
34
|
+
#define SECONDS_IN_DAY 86400
|
|
35
|
+
#define SECONDS_IN_WEEK 604800
|
|
36
|
+
#define SECONDS_IN_MONTH 2592000
|
|
37
|
+
#define SECONDS_IN_YEAR 31536000
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Stock by Brad.
|
|
41
|
+
*
|
|
42
|
+
* @note You must add register_dictionary("time.txt") in plugin_init()
|
|
43
|
+
*
|
|
44
|
+
* @param id The player whose language the length should be translated to
|
|
45
|
+
* @param unitCnt The number of time units you want translated into verbose text
|
|
46
|
+
* @param type The type of unit (i.e. seconds, minutes, hours, days, weeks, months, years) that you are passing in
|
|
47
|
+
* @param output The variable you want the verbose text to be placed in
|
|
48
|
+
* @param outputLen The length of the output variable
|
|
49
|
+
*
|
|
50
|
+
* @noreturn
|
|
51
|
+
*/
|
|
52
|
+
stock get_time_length(id, unitCnt, type, output[], outputLen)
|
|
53
|
+
{
|
|
54
|
+
if (unitCnt > 0)
|
|
55
|
+
{
|
|
56
|
+
// determine the number of each time unit there are
|
|
57
|
+
new yearCnt = 0, monthCnt = 0, weekCnt = 0, dayCnt = 0, hourCnt = 0, minuteCnt = 0, secondCnt = 0;
|
|
58
|
+
|
|
59
|
+
switch (type)
|
|
60
|
+
{
|
|
61
|
+
case timeunit_seconds: secondCnt = unitCnt;
|
|
62
|
+
case timeunit_minutes: secondCnt = unitCnt * SECONDS_IN_MINUTE;
|
|
63
|
+
case timeunit_hours: secondCnt = unitCnt * SECONDS_IN_HOUR;
|
|
64
|
+
case timeunit_days: secondCnt = unitCnt * SECONDS_IN_DAY;
|
|
65
|
+
case timeunit_weeks: secondCnt = unitCnt * SECONDS_IN_WEEK;
|
|
66
|
+
case timeunit_months: secondCnt = unitCnt * SECONDS_IN_MONTH;
|
|
67
|
+
case timeunit_years: secondCnt = unitCnt * SECONDS_IN_YEAR;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
yearCnt = secondCnt / SECONDS_IN_YEAR;
|
|
71
|
+
secondCnt -= (yearCnt * SECONDS_IN_YEAR);
|
|
72
|
+
|
|
73
|
+
monthCnt = secondCnt / SECONDS_IN_MONTH;
|
|
74
|
+
secondCnt -= (monthCnt * SECONDS_IN_MONTH);
|
|
75
|
+
|
|
76
|
+
weekCnt = secondCnt / SECONDS_IN_WEEK;
|
|
77
|
+
secondCnt -= (weekCnt * SECONDS_IN_WEEK);
|
|
78
|
+
|
|
79
|
+
dayCnt = secondCnt / SECONDS_IN_DAY;
|
|
80
|
+
secondCnt -= (dayCnt * SECONDS_IN_DAY);
|
|
81
|
+
|
|
82
|
+
hourCnt = secondCnt / SECONDS_IN_HOUR;
|
|
83
|
+
secondCnt -= (hourCnt * SECONDS_IN_HOUR);
|
|
84
|
+
|
|
85
|
+
minuteCnt = secondCnt / SECONDS_IN_MINUTE;
|
|
86
|
+
secondCnt -= (minuteCnt * SECONDS_IN_MINUTE);
|
|
87
|
+
|
|
88
|
+
// translate the unit counts into verbose text
|
|
89
|
+
new maxElementIdx = -1;
|
|
90
|
+
new timeElement[7][33];
|
|
91
|
+
|
|
92
|
+
if (yearCnt > 0)
|
|
93
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", yearCnt, id, (yearCnt == 1) ? "TIME_ELEMENT_YEAR" : "TIME_ELEMENT_YEARS");
|
|
94
|
+
if (monthCnt > 0)
|
|
95
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", monthCnt, id, (monthCnt == 1) ? "TIME_ELEMENT_MONTH" : "TIME_ELEMENT_MONTHS");
|
|
96
|
+
if (weekCnt > 0)
|
|
97
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", weekCnt, id, (weekCnt == 1) ? "TIME_ELEMENT_WEEK" : "TIME_ELEMENT_WEEKS");
|
|
98
|
+
if (dayCnt > 0)
|
|
99
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", dayCnt, id, (dayCnt == 1) ? "TIME_ELEMENT_DAY" : "TIME_ELEMENT_DAYS");
|
|
100
|
+
if (hourCnt > 0)
|
|
101
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", hourCnt, id, (hourCnt == 1) ? "TIME_ELEMENT_HOUR" : "TIME_ELEMENT_HOURS");
|
|
102
|
+
if (minuteCnt > 0)
|
|
103
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", minuteCnt, id, (minuteCnt == 1) ? "TIME_ELEMENT_MINUTE" : "TIME_ELEMENT_MINUTES");
|
|
104
|
+
if (secondCnt > 0)
|
|
105
|
+
format(timeElement[++maxElementIdx], charsmax(timeElement[]), "%i %L", secondCnt, id, (secondCnt == 1) ? "TIME_ELEMENT_SECOND" : "TIME_ELEMENT_SECONDS");
|
|
106
|
+
|
|
107
|
+
switch(maxElementIdx)
|
|
108
|
+
{
|
|
109
|
+
case 0: formatex(output, outputLen, "%s", timeElement[0]);
|
|
110
|
+
case 1: formatex(output, outputLen, "%s %L %s", timeElement[0], id, "TIME_ELEMENT_AND", timeElement[1]);
|
|
111
|
+
case 2: formatex(output, outputLen, "%s, %s %L %s", timeElement[0], timeElement[1], id, "TIME_ELEMENT_AND", timeElement[2]);
|
|
112
|
+
case 3: formatex(output, outputLen, "%s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], id, "TIME_ELEMENT_AND", timeElement[3]);
|
|
113
|
+
case 4: formatex(output, outputLen, "%s, %s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], timeElement[3], id, "TIME_ELEMENT_AND", timeElement[4]);
|
|
114
|
+
case 5: formatex(output, outputLen, "%s, %s, %s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], timeElement[3], timeElement[4], id, "TIME_ELEMENT_AND", timeElement[5]);
|
|
115
|
+
case 6: formatex(output, outputLen, "%s, %s, %s, %s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], timeElement[3], timeElement[4], timeElement[5], id, "TIME_ELEMENT_AND", timeElement[6]);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|