@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,902 @@
|
|
|
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
|
+
#if defined _amxmisc_included
|
|
11
|
+
#endinput
|
|
12
|
+
#endif
|
|
13
|
+
#define _amxmisc_included
|
|
14
|
+
|
|
15
|
+
#if !defined _amxmodx_included
|
|
16
|
+
#include <amxmodx>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns if the client has any admin flags set
|
|
21
|
+
*
|
|
22
|
+
* @param id Client index
|
|
23
|
+
*
|
|
24
|
+
* @return 1 if client has any admin flags, 0 otherwise
|
|
25
|
+
*/
|
|
26
|
+
stock is_user_admin(id)
|
|
27
|
+
{
|
|
28
|
+
new __flags = get_user_flags(id);
|
|
29
|
+
return (__flags > 0 && !(__flags & ADMIN_USER));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns if the user can execute the current command by checking the necessary
|
|
34
|
+
* admin flags and parameter count. Displays a denied access message to the user
|
|
35
|
+
* if missing privileges or a usage example if too few parameters are provided.
|
|
36
|
+
*
|
|
37
|
+
* @note This should be used inside of a command forward as it uses read_argc()
|
|
38
|
+
* to check the parameter count.
|
|
39
|
+
*
|
|
40
|
+
* @param id Client index
|
|
41
|
+
* @param level Required admin flags
|
|
42
|
+
* @param cid Command id
|
|
43
|
+
* @param num Required number of parameters
|
|
44
|
+
* @param acesssilent If true no denied access message will be printed
|
|
45
|
+
*
|
|
46
|
+
* @return 1 if access granted and parameters provided, 0 otherwise
|
|
47
|
+
*/
|
|
48
|
+
stock cmd_access(id, level, cid, num, bool:accesssilent = false)
|
|
49
|
+
{
|
|
50
|
+
new has_access = 0;
|
|
51
|
+
if (id == (is_dedicated_server() ? 0 : 1))
|
|
52
|
+
{
|
|
53
|
+
has_access = 1;
|
|
54
|
+
}
|
|
55
|
+
else if (level == ADMIN_ADMIN)
|
|
56
|
+
{
|
|
57
|
+
if (is_user_admin(id))
|
|
58
|
+
{
|
|
59
|
+
has_access = 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (get_user_flags(id) & level)
|
|
63
|
+
{
|
|
64
|
+
has_access = 1;
|
|
65
|
+
}
|
|
66
|
+
else if (level == ADMIN_ALL)
|
|
67
|
+
{
|
|
68
|
+
has_access = 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (has_access == 0)
|
|
72
|
+
{
|
|
73
|
+
if (!accesssilent)
|
|
74
|
+
{
|
|
75
|
+
console_print(id, "%L", id, "NO_ACC_COM");
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
if (read_argc() < num)
|
|
80
|
+
{
|
|
81
|
+
new hcmd[32], hinfo[128], hflag, bool:info_ml;
|
|
82
|
+
get_concmd(cid, hcmd, charsmax(hcmd), hflag, hinfo, charsmax(hinfo), level, _, info_ml);
|
|
83
|
+
|
|
84
|
+
if (info_ml)
|
|
85
|
+
{
|
|
86
|
+
LookupLangKey(hinfo, charsmax(hinfo), hinfo, id);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console_print(id, "%L: %s %s", id, "USAGE", hcmd, hinfo);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns if the client has the specified admin flags.
|
|
98
|
+
*
|
|
99
|
+
* @param id Client index
|
|
100
|
+
* @param level Required admin flags
|
|
101
|
+
*
|
|
102
|
+
* @return 1 if client has the admin flags, 0 otherwise
|
|
103
|
+
*/
|
|
104
|
+
stock access(id, level)
|
|
105
|
+
{
|
|
106
|
+
if (level == ADMIN_ADMIN)
|
|
107
|
+
{
|
|
108
|
+
return is_user_admin(id);
|
|
109
|
+
}
|
|
110
|
+
else if (level == ADMIN_ALL)
|
|
111
|
+
{
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (get_user_flags(id) & level);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* cmd_target flags
|
|
120
|
+
*/
|
|
121
|
+
#define CMDTARGET_OBEY_IMMUNITY (1<<0) // Obey immunity
|
|
122
|
+
#define CMDTARGET_ALLOW_SELF (1<<1) // Allow self targeting
|
|
123
|
+
#define CMDTARGET_ONLY_ALIVE (1<<2) // Target must be alive
|
|
124
|
+
#define CMDTARGET_NO_BOTS (1<<3) // Target can't be a bot
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Processes a generic target pattern and tries to match it to a client based
|
|
128
|
+
* on filtering flags. If no unique target is found an appropriate message is
|
|
129
|
+
* displayed to the admin.
|
|
130
|
+
*
|
|
131
|
+
* @note The pattern is first matched case insensitively against client names.
|
|
132
|
+
* If no match is found it is matched against client authids. If still no
|
|
133
|
+
* match is found and the pattern starts with '#' it is finally matched
|
|
134
|
+
* against client userids.
|
|
135
|
+
* @note Since client names are matched by substring the pattern can potentially
|
|
136
|
+
* match multiple targets. In that case the function will return 0 and ask
|
|
137
|
+
* the admin to provide a unique pattern.
|
|
138
|
+
* @note The filtering flags are applied after the pattern matching has
|
|
139
|
+
* finished. That means the pattern has to be unique against all clients
|
|
140
|
+
* on the server even if some of them are not eligible.
|
|
141
|
+
*
|
|
142
|
+
* @param id Client index of admin performing an action
|
|
143
|
+
* @param arg Target pattern
|
|
144
|
+
* @param flags Filtering flags, see CMDTARGET_* constants above
|
|
145
|
+
*
|
|
146
|
+
* @return Client index, or 0 if no or multiple clients matched
|
|
147
|
+
*/
|
|
148
|
+
stock cmd_target(id, const arg[], flags = CMDTARGET_OBEY_IMMUNITY)
|
|
149
|
+
{
|
|
150
|
+
new player = find_player("bl", arg);
|
|
151
|
+
if (player)
|
|
152
|
+
{
|
|
153
|
+
if (player != find_player("blj", arg))
|
|
154
|
+
{
|
|
155
|
+
console_print(id, "%L", id, "MORE_CL_MATCHT");
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if ((player = find_player("c", arg)) == 0 && arg[0] == '#' && arg[1])
|
|
160
|
+
{
|
|
161
|
+
player = find_player("k", str_to_num(arg[1]));
|
|
162
|
+
}
|
|
163
|
+
if (!player)
|
|
164
|
+
{
|
|
165
|
+
console_print(id, "%L", id, "CL_NOT_FOUND");
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
if (flags & CMDTARGET_OBEY_IMMUNITY)
|
|
169
|
+
{
|
|
170
|
+
if ((get_user_flags(player) & ADMIN_IMMUNITY) && ((flags & CMDTARGET_ALLOW_SELF) ? (id != player) : true))
|
|
171
|
+
{
|
|
172
|
+
new imname[MAX_NAME_LENGTH];
|
|
173
|
+
get_user_name(player, imname, charsmax(imname));
|
|
174
|
+
console_print(id, "%L", id, "CLIENT_IMM", imname);
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (flags & CMDTARGET_ONLY_ALIVE)
|
|
179
|
+
{
|
|
180
|
+
if (!is_user_alive(player))
|
|
181
|
+
{
|
|
182
|
+
new imname[MAX_NAME_LENGTH];
|
|
183
|
+
get_user_name(player, imname, charsmax(imname));
|
|
184
|
+
console_print(id, "%L", id, "CANT_PERF_DEAD", imname);
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (flags & CMDTARGET_NO_BOTS)
|
|
189
|
+
{
|
|
190
|
+
if (is_user_bot(player))
|
|
191
|
+
{
|
|
192
|
+
new imname[MAX_NAME_LENGTH];
|
|
193
|
+
get_user_name(player, imname, charsmax(imname));
|
|
194
|
+
console_print(id, "%L", id, "CANT_PERF_BOT", imname);
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return player;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Standard method to show admin activity to clients connected to the server.
|
|
204
|
+
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
205
|
+
*
|
|
206
|
+
* @param id Client index performing the action
|
|
207
|
+
* @param name Name of client performing the action
|
|
208
|
+
* @param fmt Formatting rules
|
|
209
|
+
* @param ... Variable number of formatting parameters
|
|
210
|
+
*
|
|
211
|
+
* @noreturn
|
|
212
|
+
*/
|
|
213
|
+
stock show_activity(id, const name[], const fmt[], any:...)
|
|
214
|
+
{
|
|
215
|
+
static __amx_show_activity;
|
|
216
|
+
if (__amx_show_activity == 0)
|
|
217
|
+
{
|
|
218
|
+
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
|
219
|
+
|
|
220
|
+
// if still not found, then register the cvar as a dummy
|
|
221
|
+
if (__amx_show_activity == 0)
|
|
222
|
+
{
|
|
223
|
+
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
new prefix[10];
|
|
228
|
+
if (is_user_admin(id))
|
|
229
|
+
{
|
|
230
|
+
copy(prefix, charsmax(prefix), "ADMIN");
|
|
231
|
+
}
|
|
232
|
+
else
|
|
233
|
+
{
|
|
234
|
+
copy(prefix, charsmax(prefix), "PLAYER");
|
|
235
|
+
}
|
|
236
|
+
new buffer[512];
|
|
237
|
+
vformat(buffer, charsmax(buffer), fmt, 4);
|
|
238
|
+
|
|
239
|
+
switch (get_pcvar_num(__amx_show_activity))
|
|
240
|
+
{
|
|
241
|
+
case 5: // hide name only to admins, show nothing to normal users
|
|
242
|
+
{
|
|
243
|
+
for (new i = 1; i <= MaxClients; i++)
|
|
244
|
+
{
|
|
245
|
+
if (is_user_connected(i))
|
|
246
|
+
{
|
|
247
|
+
if (is_user_admin(i))
|
|
248
|
+
{
|
|
249
|
+
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
case 4: // show name only to admins, show nothing to normal users
|
|
255
|
+
{
|
|
256
|
+
for (new i = 1; i <= MaxClients; i++)
|
|
257
|
+
{
|
|
258
|
+
if (is_user_connected(i))
|
|
259
|
+
{
|
|
260
|
+
if (is_user_admin(i))
|
|
261
|
+
{
|
|
262
|
+
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
case 3: // show name only to admins, hide name from normal users
|
|
268
|
+
{
|
|
269
|
+
for (new i = 1; i <= MaxClients; i++)
|
|
270
|
+
{
|
|
271
|
+
if (is_user_connected(i))
|
|
272
|
+
{
|
|
273
|
+
if (is_user_admin(i))
|
|
274
|
+
{
|
|
275
|
+
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
|
|
276
|
+
}
|
|
277
|
+
else
|
|
278
|
+
{
|
|
279
|
+
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
case 2: // show name to all
|
|
285
|
+
{
|
|
286
|
+
client_print(0, print_chat, "%L %s: %s", LANG_PLAYER, prefix , name , buffer);
|
|
287
|
+
}
|
|
288
|
+
case 1: // hide name to all
|
|
289
|
+
{
|
|
290
|
+
client_print(0, print_chat, "%L: %s", LANG_PLAYER, prefix, buffer);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Standard method to show admin activity to a single client.
|
|
297
|
+
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
298
|
+
*
|
|
299
|
+
* @param idtarget Client index to display message to
|
|
300
|
+
* @param id Client index performing the action
|
|
301
|
+
* @param name Name of client performing the action
|
|
302
|
+
* @param fmt Formatting rules
|
|
303
|
+
* @param ... Variable number of formatting parameters
|
|
304
|
+
*
|
|
305
|
+
* @noreturn
|
|
306
|
+
*/
|
|
307
|
+
stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...)
|
|
308
|
+
{
|
|
309
|
+
if (idtarget == 0 || !is_user_connected(idtarget))
|
|
310
|
+
{
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
static __amx_show_activity;
|
|
315
|
+
if (__amx_show_activity == 0)
|
|
316
|
+
{
|
|
317
|
+
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
|
318
|
+
|
|
319
|
+
// if still not found, then register the cvar as a dummy
|
|
320
|
+
if (__amx_show_activity == 0)
|
|
321
|
+
{
|
|
322
|
+
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
static prefix[10];
|
|
327
|
+
if (is_user_admin(idadmin))
|
|
328
|
+
{
|
|
329
|
+
copy(prefix, charsmax(prefix), "ADMIN");
|
|
330
|
+
}
|
|
331
|
+
else
|
|
332
|
+
{
|
|
333
|
+
copy(prefix, charsmax(prefix), "PLAYER");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
static buffer[512];
|
|
337
|
+
vformat(buffer, charsmax(buffer), fmt, 5);
|
|
338
|
+
|
|
339
|
+
switch (get_pcvar_num(__amx_show_activity))
|
|
340
|
+
{
|
|
341
|
+
case 5: // hide name only to admins, show nothing to normal users
|
|
342
|
+
{
|
|
343
|
+
if (is_user_admin(idtarget))
|
|
344
|
+
{
|
|
345
|
+
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
case 4: // show name only to admins, show nothing to normal users
|
|
349
|
+
{
|
|
350
|
+
if (is_user_admin(idtarget))
|
|
351
|
+
{
|
|
352
|
+
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
case 3: // show name only to admins, hide name from normal users
|
|
356
|
+
{
|
|
357
|
+
if (is_user_admin(idtarget))
|
|
358
|
+
{
|
|
359
|
+
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
360
|
+
}
|
|
361
|
+
else
|
|
362
|
+
{
|
|
363
|
+
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
case 2: // show name to all
|
|
367
|
+
{
|
|
368
|
+
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
369
|
+
}
|
|
370
|
+
case 1: // hide name to all
|
|
371
|
+
{
|
|
372
|
+
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Standard method to show activity to one single client with normal language keys.
|
|
379
|
+
* These keys need to be in the format of standard AMXX keys:
|
|
380
|
+
* eg: ADMIN_KICK_1 = ADMIN: kick %s
|
|
381
|
+
* ADMIN_KICK_2 = ADMIN %s: kick %s
|
|
382
|
+
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
383
|
+
*
|
|
384
|
+
* @param KeyWithoutName The language key that does not have the name field.
|
|
385
|
+
* @param KeyWithName The language key that does have the name field.
|
|
386
|
+
* @param __AdminName The name of the person doing the action.
|
|
387
|
+
* @extra Pass any extra format arguments for the language key in the variable arguments list.
|
|
388
|
+
*
|
|
389
|
+
* @noreturn
|
|
390
|
+
*/
|
|
391
|
+
stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...)
|
|
392
|
+
{
|
|
393
|
+
// The variable gets used via vformat, but the compiler doesn't know that, so it still cries.
|
|
394
|
+
#pragma unused ___AdminName
|
|
395
|
+
static __amx_show_activity;
|
|
396
|
+
if (__amx_show_activity == 0)
|
|
397
|
+
{
|
|
398
|
+
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
|
399
|
+
|
|
400
|
+
// if still not found, then register the cvar as a dummy
|
|
401
|
+
if (__amx_show_activity == 0)
|
|
402
|
+
{
|
|
403
|
+
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
new buffer[512];
|
|
408
|
+
new keyfmt[256];
|
|
409
|
+
new i;
|
|
410
|
+
|
|
411
|
+
switch (get_pcvar_num(__amx_show_activity))
|
|
412
|
+
{
|
|
413
|
+
case 5: // hide name to admins, display nothing to normal players
|
|
414
|
+
{
|
|
415
|
+
while (i++ < MaxClients)
|
|
416
|
+
{
|
|
417
|
+
if (is_user_connected(i))
|
|
418
|
+
{
|
|
419
|
+
if (is_user_admin(i))
|
|
420
|
+
{
|
|
421
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
|
422
|
+
|
|
423
|
+
// skip the "adminname" argument if not showing name
|
|
424
|
+
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
425
|
+
client_print(i, print_chat, "%s", buffer);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
case 4: // show name only to admins, display nothing to normal players
|
|
431
|
+
{
|
|
432
|
+
while (i++ < MaxClients)
|
|
433
|
+
{
|
|
434
|
+
if (is_user_connected(i))
|
|
435
|
+
{
|
|
436
|
+
if (is_user_admin(i))
|
|
437
|
+
{
|
|
438
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
439
|
+
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
440
|
+
client_print(i, print_chat, "%s", buffer);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
case 3: // show name only to admins, hide name from normal users
|
|
446
|
+
{
|
|
447
|
+
while (i++ < MaxClients)
|
|
448
|
+
{
|
|
449
|
+
if (is_user_connected(i))
|
|
450
|
+
{
|
|
451
|
+
if (is_user_admin(i))
|
|
452
|
+
{
|
|
453
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
454
|
+
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
455
|
+
}
|
|
456
|
+
else
|
|
457
|
+
{
|
|
458
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
|
459
|
+
|
|
460
|
+
// skip the "adminname" argument if not showing name
|
|
461
|
+
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
462
|
+
}
|
|
463
|
+
client_print(i, print_chat, "%s", buffer);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
case 2: // show name to all users
|
|
468
|
+
{
|
|
469
|
+
while (i++ < MaxClients)
|
|
470
|
+
{
|
|
471
|
+
if (is_user_connected(i))
|
|
472
|
+
{
|
|
473
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
474
|
+
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
475
|
+
client_print(i, print_chat, "%s", buffer);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
case 1: // hide name from all users
|
|
480
|
+
{
|
|
481
|
+
while (i++ < MaxClients)
|
|
482
|
+
{
|
|
483
|
+
if (is_user_connected(i))
|
|
484
|
+
{
|
|
485
|
+
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
|
486
|
+
|
|
487
|
+
// skip the "adminname" argument if not showing name
|
|
488
|
+
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
489
|
+
client_print(i, print_chat, "%s", buffer);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Returns if the mod running on the server supports colored menus.
|
|
498
|
+
*
|
|
499
|
+
* @note The full list of mods supporting colored menus:
|
|
500
|
+
* Counter-Strike, Counter-Strike: Condition Zero, Deathmatch Classic,
|
|
501
|
+
* Day of Defeat, Team Fortress Classic and Half-Life: Deathmatch.
|
|
502
|
+
* @note Since this is a stock and compiled into the plugin, the list of
|
|
503
|
+
* supported mods will not update and require recompilation of the plugin
|
|
504
|
+
* if the list ever changed.
|
|
505
|
+
*
|
|
506
|
+
* @return 1 if colored menus are supported, 0 otherwise
|
|
507
|
+
*/
|
|
508
|
+
stock colored_menus()
|
|
509
|
+
{
|
|
510
|
+
static ColoredMenus = -1;
|
|
511
|
+
|
|
512
|
+
if (ColoredMenus == -1)
|
|
513
|
+
{
|
|
514
|
+
new const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" };
|
|
515
|
+
new ModName[32];
|
|
516
|
+
|
|
517
|
+
get_modname(ModName, charsmax(ModName));
|
|
518
|
+
|
|
519
|
+
for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++)
|
|
520
|
+
{
|
|
521
|
+
if (equal(ModName, ModNames[Iterator]))
|
|
522
|
+
{
|
|
523
|
+
ColoredMenus = 1;
|
|
524
|
+
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (ColoredMenus == -1)
|
|
530
|
+
ColoredMenus = 0;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return ColoredMenus;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Returns if the mod running on the server is a version of Counter-Strike.
|
|
538
|
+
*
|
|
539
|
+
* @return 1 if mod is Counter-Strike, 0 otherwise
|
|
540
|
+
*/
|
|
541
|
+
stock cstrike_running()
|
|
542
|
+
{
|
|
543
|
+
new mod_name[32];
|
|
544
|
+
get_modname(mod_name, charsmax(mod_name));
|
|
545
|
+
|
|
546
|
+
return (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"));
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Returns if the server is running a specific mod.
|
|
551
|
+
*
|
|
552
|
+
* @param mod Mod name to check for
|
|
553
|
+
*
|
|
554
|
+
* @return 1 if mod name matches, 0 otherwise
|
|
555
|
+
*/
|
|
556
|
+
stock is_running(const mod[])
|
|
557
|
+
{
|
|
558
|
+
new mod_name[32];
|
|
559
|
+
get_modname(mod_name, charsmax(mod_name));
|
|
560
|
+
|
|
561
|
+
return equal(mod_name, mod);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Retrieves the path to the AMXX base directory.
|
|
566
|
+
*
|
|
567
|
+
* @param name Buffer to copy path to
|
|
568
|
+
* @param len Maximum buffer size
|
|
569
|
+
*
|
|
570
|
+
* @return Number of cells written to buffer
|
|
571
|
+
*/
|
|
572
|
+
stock get_basedir(name[], len)
|
|
573
|
+
{
|
|
574
|
+
return get_localinfo("amxx_basedir", name, len);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Retrieves the path to the AMXX configs directory.
|
|
579
|
+
*
|
|
580
|
+
* @param name Buffer to copy path to
|
|
581
|
+
* @param len Maximum buffer size
|
|
582
|
+
*
|
|
583
|
+
* @return Number of cells written to buffer
|
|
584
|
+
*/
|
|
585
|
+
stock get_configsdir(name[], len)
|
|
586
|
+
{
|
|
587
|
+
return get_localinfo("amxx_configsdir", name, len);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Retrieves the path to the AMXX data directory.
|
|
592
|
+
*
|
|
593
|
+
* @param name Buffer to copy path to
|
|
594
|
+
* @param len Maximum buffer size
|
|
595
|
+
*
|
|
596
|
+
* @return Number of cells written to buffer
|
|
597
|
+
*/
|
|
598
|
+
stock get_datadir(name[], len)
|
|
599
|
+
{
|
|
600
|
+
return get_localinfo("amxx_datadir", name, len);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Provides a shorthand to register a working menu.
|
|
605
|
+
*
|
|
606
|
+
* @note Combines the necessary calls to register_menuid() and
|
|
607
|
+
* register_menucmd() into a single function.
|
|
608
|
+
*
|
|
609
|
+
* @param title Menu name
|
|
610
|
+
* @param keys Key flags
|
|
611
|
+
* @param function Callback function
|
|
612
|
+
* @param outside Catch menus outside the calling plugin
|
|
613
|
+
*
|
|
614
|
+
* @noreturn
|
|
615
|
+
* @error If an invalid callback function is specified, an error will
|
|
616
|
+
* be thrown.
|
|
617
|
+
*/
|
|
618
|
+
stock register_menu(const title[], keys, const function[], outside = 0)
|
|
619
|
+
{
|
|
620
|
+
register_menucmd(register_menuid(title, outside), keys, function);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Alias to get_configsdir provided for backwards compatibility. Originally
|
|
625
|
+
* intended to retrieve the AMXX custom directory.
|
|
626
|
+
*
|
|
627
|
+
* @deprecated Should not be used as the concept of a custom directory does no
|
|
628
|
+
* longer exists in AMXX.
|
|
629
|
+
*
|
|
630
|
+
* @param name Buffer to copy path to
|
|
631
|
+
* @param len Maximum buffer size
|
|
632
|
+
*
|
|
633
|
+
* @return Number of cells written to buffer
|
|
634
|
+
*/
|
|
635
|
+
#pragma deprecated The concept of a custom directory no longer exists in AMXX. Do not use.
|
|
636
|
+
stock get_customdir(name[], len)
|
|
637
|
+
{
|
|
638
|
+
return get_configsdir(name, len);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Adds a menu item/command to the admin menu (amxmodmenu) handled by the
|
|
643
|
+
* "Menus Front-End" plugin, if it is loaded.
|
|
644
|
+
*
|
|
645
|
+
* @param MENU_TEXT Item text that will be displayed in the menu
|
|
646
|
+
* @param MENU_CMD Command that will be executed on the client
|
|
647
|
+
* @param MENU_ACCESS Admin access required for menu command
|
|
648
|
+
* @param MENU_PLUGIN Case-insensitive name or filename of plugin providing
|
|
649
|
+
* the menu command
|
|
650
|
+
*
|
|
651
|
+
* @noreturn
|
|
652
|
+
*/
|
|
653
|
+
stock AddMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
|
|
654
|
+
{
|
|
655
|
+
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, false);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Adds a menu item/command to the client menu (amx_menu) handled by the
|
|
660
|
+
* "Menus Front-End" plugin, if it is loaded. Items should be accessible by
|
|
661
|
+
* non-admins.
|
|
662
|
+
*
|
|
663
|
+
* @param MENU_TEXT Item text that will be displayed in the menu
|
|
664
|
+
* @param MENU_CMD Command that will be executed on the client
|
|
665
|
+
* @param MENU_ACCESS Admin access required for menu command
|
|
666
|
+
* @param MENU_PLUGIN Case-insensitive name or filename of plugin providing
|
|
667
|
+
* the menu command
|
|
668
|
+
*
|
|
669
|
+
* @noreturn
|
|
670
|
+
*/
|
|
671
|
+
stock AddClientMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
|
|
672
|
+
{
|
|
673
|
+
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, true);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Helper function used by AddMenuItem() and AddClientMenuItem()
|
|
678
|
+
*
|
|
679
|
+
* @param MENU_TEXT Item text that will be displayed in the menu
|
|
680
|
+
* @param MENU_CMD Command that will be executed on the client
|
|
681
|
+
* @param MENU_ACCESS Admin access required for menu command
|
|
682
|
+
* @param MENU_PLUGIN Case-insensitive name or filename of plugin
|
|
683
|
+
* providing the menu command
|
|
684
|
+
* @param ADD_TO_CLIENT_MENU If true adds command to client menu, false adds
|
|
685
|
+
* to admin menu
|
|
686
|
+
*
|
|
687
|
+
* @noreturn
|
|
688
|
+
*/
|
|
689
|
+
stock AddMenuItem_call(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[], const bool:ADD_TO_CLIENT_MENU)
|
|
690
|
+
{
|
|
691
|
+
new pluginid = is_plugin_loaded("Menus Front-End");
|
|
692
|
+
if (pluginid == -1)
|
|
693
|
+
{
|
|
694
|
+
log_amx("Can't add menu item ^"%s^" from plugin ^"%s^" to menu set because the Menus Front-End plugin itself is not loaded!", MENU_TEXT, MENU_PLUGIN);
|
|
695
|
+
return; // Menus Front-End doesn't exist, return.
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
new filename[64], b[1];
|
|
699
|
+
get_plugin(pluginid, filename, charsmax(filename), b, charsmax(b), b, charsmax(b), b, charsmax(b), b, charsmax(b));
|
|
700
|
+
|
|
701
|
+
new status = callfunc_begin(ADD_TO_CLIENT_MENU ? "AddClientMenu" : "AddMenu", filename);
|
|
702
|
+
new bool:failed = true;
|
|
703
|
+
switch (status)
|
|
704
|
+
{
|
|
705
|
+
case 1:
|
|
706
|
+
{
|
|
707
|
+
failed = false;
|
|
708
|
+
}
|
|
709
|
+
case 0:
|
|
710
|
+
{
|
|
711
|
+
log_amx("Run time error! (AddMenuItem_call failed)");
|
|
712
|
+
}
|
|
713
|
+
case -2:
|
|
714
|
+
{
|
|
715
|
+
log_amx("Function not found! (AddMenuItem_call failed)");
|
|
716
|
+
}
|
|
717
|
+
case -1:
|
|
718
|
+
{
|
|
719
|
+
log_amx("Plugin not found! (AddMenuItem_call failed)");
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (failed)
|
|
723
|
+
{
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
// Item text
|
|
727
|
+
callfunc_push_str(MENU_TEXT);
|
|
728
|
+
// Cmd
|
|
729
|
+
callfunc_push_str(MENU_CMD);
|
|
730
|
+
// Access
|
|
731
|
+
callfunc_push_int(MENU_ACCESS);
|
|
732
|
+
// Menu exists in this plugin
|
|
733
|
+
callfunc_push_str(MENU_PLUGIN);
|
|
734
|
+
|
|
735
|
+
callfunc_end();
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Computes an offset from a given value while constraining it between the
|
|
740
|
+
* specified bounds, rolling over if necessary.
|
|
741
|
+
*
|
|
742
|
+
* @note Example: The range is 1-5 and the base value (seed) is 3, the offset
|
|
743
|
+
* that the value should be moved by is also 3. Offsetting the value by 3
|
|
744
|
+
* would result in 6, but it is to be constrained between 1 and 5. With
|
|
745
|
+
* clamp() this would result in 5, but this function rolls the value over
|
|
746
|
+
* and returns 1 instead.
|
|
747
|
+
*
|
|
748
|
+
* @param low Lower bound
|
|
749
|
+
* @param high Higher bound
|
|
750
|
+
* @param seed Base value
|
|
751
|
+
* @param offset Offset to move
|
|
752
|
+
*
|
|
753
|
+
* @return Computed offset value between specified bounds
|
|
754
|
+
*/
|
|
755
|
+
stock constraint_offset(low, high, seed, offset)
|
|
756
|
+
{
|
|
757
|
+
new numElements = high - low + 1;
|
|
758
|
+
offset += seed - low;
|
|
759
|
+
|
|
760
|
+
if (offset >= 0)
|
|
761
|
+
{
|
|
762
|
+
return low + (offset % numElements);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
return high - (abs(offset) % numElements) + 1;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Returns if the client has any of the specified admin flags.
|
|
770
|
+
*
|
|
771
|
+
* @param id Client index
|
|
772
|
+
* @param flags Flag string
|
|
773
|
+
*
|
|
774
|
+
* @return 1 if the user has any of the specified flags, 0 otherwise
|
|
775
|
+
*/
|
|
776
|
+
stock has_flag(id, const flags[])
|
|
777
|
+
{
|
|
778
|
+
return (get_user_flags(id) & read_flags(flags));
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Returns if the client has all of the specified admin flags.
|
|
783
|
+
*
|
|
784
|
+
* @param id Client index
|
|
785
|
+
* @param flags Flag string
|
|
786
|
+
*
|
|
787
|
+
* @return 1 if the user has all of the specified flags, 0 otherwise
|
|
788
|
+
*/
|
|
789
|
+
stock has_all_flags(id, const flags[])
|
|
790
|
+
{
|
|
791
|
+
new FlagsNumber = read_flags(flags);
|
|
792
|
+
return ((get_user_flags(id) & FlagsNumber) == FlagsNumber);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Resets the client's menu.
|
|
797
|
+
*
|
|
798
|
+
* @note This is a wrapper around show_menu() for the sake of readability.
|
|
799
|
+
*
|
|
800
|
+
* @param index Client to reset menu of, 0 to reset all clients
|
|
801
|
+
*
|
|
802
|
+
* @noreturn
|
|
803
|
+
*/
|
|
804
|
+
stock reset_menu(index)
|
|
805
|
+
{
|
|
806
|
+
show_menu(index, 0, "", 0);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Calls a function after a specified time has elapsed.
|
|
811
|
+
*
|
|
812
|
+
* @note The function is called in the following manner if data is passed:
|
|
813
|
+
* data[] - Data passed
|
|
814
|
+
* id - Task index
|
|
815
|
+
*
|
|
816
|
+
* @note The function is called in the following manner if no data is passed:
|
|
817
|
+
* id - Task index
|
|
818
|
+
*
|
|
819
|
+
* @param time Time interval to assign
|
|
820
|
+
* @param function Function to execute
|
|
821
|
+
* @param id Task id to assign
|
|
822
|
+
* @param parameter Data to pass through to callback
|
|
823
|
+
* @param len Size of data
|
|
824
|
+
* @param flags Optional flags (enum SetTaskFlags); valid flags are:
|
|
825
|
+
* SetTask_Once - Execute callback once (Default)
|
|
826
|
+
* SetTask_RepeatTimes - repeat timer a set amount of times
|
|
827
|
+
* SetTask_Repeat - loop indefinitely until timer is stopped
|
|
828
|
+
* SetTask_AfterMapStart - time interval is treated as absolute
|
|
829
|
+
* time after map start
|
|
830
|
+
* SetTask_BeforeMapChange - time interval is treated as absolute
|
|
831
|
+
* time before map change
|
|
832
|
+
* @param repeat If the SetTask_RepeatTimes flag is set, the task will be repeated this
|
|
833
|
+
* many times
|
|
834
|
+
*
|
|
835
|
+
* @noreturn
|
|
836
|
+
* @error If an invalid callback function is provided, an error is
|
|
837
|
+
* thrown.
|
|
838
|
+
*/
|
|
839
|
+
stock set_task_ex(Float:time, const function[], id = 0, const any:parameter[] = "", len = 0, SetTaskFlags:flags = SetTask_Once, repeat = 0)
|
|
840
|
+
{
|
|
841
|
+
new strFlags[2]; // There should never be a need to set more than 1 flag
|
|
842
|
+
get_flags(_:flags, strFlags, charsmax(strFlags));
|
|
843
|
+
set_task(time, function, id, parameter, len, strFlags, repeat);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Stores a filtered list of client indexes to an array.
|
|
848
|
+
*
|
|
849
|
+
* @note Example retrieving all alive CTs:
|
|
850
|
+
* get_players_ex(players, num, GetPlayers_ExcludeDead | GetPlayers_MatchTeam, "CT")
|
|
851
|
+
*
|
|
852
|
+
* @param players Array to store indexes to
|
|
853
|
+
* @param num Variable to store number of indexes to
|
|
854
|
+
* @param flags Optional filtering flags (enum GetPlayersFlags); valid flags are:
|
|
855
|
+
* GetPlayers_None - No filter (Default)
|
|
856
|
+
* GetPlayers_ExcludeDead - do not include dead clients
|
|
857
|
+
* GetPlayers_ExcludeAlive - do not include alive clients
|
|
858
|
+
* GetPlayers_ExcludeBots - do not include bots
|
|
859
|
+
* GetPlayers_ExcludeHuman - do not include human clients
|
|
860
|
+
* GetPlayers_MatchTeam - match with team
|
|
861
|
+
* GetPlayers_MatchNameSubstring - match with part of name
|
|
862
|
+
* GetPlayers_CaseInsensitive - match case insensitive
|
|
863
|
+
* GetPlayers_ExcludeHLTV - do not include HLTV proxies
|
|
864
|
+
* GetPlayers_IncludeConnecting - include connecting clients
|
|
865
|
+
* @param team String to match against if the "e" or "f" flag is specified
|
|
866
|
+
*
|
|
867
|
+
* @noreturn
|
|
868
|
+
*/
|
|
869
|
+
stock get_players_ex(players[MAX_PLAYERS] = {}, &num, GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
|
|
870
|
+
{
|
|
871
|
+
new strFlags[10];
|
|
872
|
+
get_flags(_:flags, strFlags, charsmax(strFlags));
|
|
873
|
+
get_players(players, num, strFlags, team);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Returns the number of clients on the server that match the specified flags.
|
|
878
|
+
*
|
|
879
|
+
* @note Example retrieving all alive CTs:
|
|
880
|
+
* new AliveCt = get_playersnum_ex(GetPlayers_ExcludeDead | GetPlayers_MatchTeam, "CT")
|
|
881
|
+
*
|
|
882
|
+
* @param flags Optional filtering flags (enum GetPlayersFlags); valid flags are:
|
|
883
|
+
* GetPlayers_None - No filter (Default)
|
|
884
|
+
* GetPlayers_ExcludeDead - do not include dead clients
|
|
885
|
+
* GetPlayers_ExcludeAlive - do not include alive clients
|
|
886
|
+
* GetPlayers_ExcludeBots - do not include bots
|
|
887
|
+
* GetPlayers_ExcludeHuman - do not include human clients
|
|
888
|
+
* GetPlayers_MatchTeam - match with team
|
|
889
|
+
* GetPlayers_MatchNameSubstring - match with part of name
|
|
890
|
+
* GetPlayers_CaseInsensitive - match case insensitive
|
|
891
|
+
* GetPlayers_ExcludeHLTV - do not include HLTV proxies
|
|
892
|
+
* GetPlayers_IncludeConnecting - include connecting clients
|
|
893
|
+
* @param team String to match against if the GetPlayers_MatchTeam or GetPlayers_MatchNameSubstring flag is specified
|
|
894
|
+
*
|
|
895
|
+
* @return Number of clients on the server that match the specified flags
|
|
896
|
+
*/
|
|
897
|
+
stock get_playersnum_ex(GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
|
|
898
|
+
{
|
|
899
|
+
new PlayersNum;
|
|
900
|
+
get_players_ex(_, PlayersNum, flags, team);
|
|
901
|
+
return PlayersNum;
|
|
902
|
+
}
|