mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2025-04-14 21:01:21 +00:00
Compare commits
378 commits
Author | SHA1 | Date | |
---|---|---|---|
|
8eb29aca14 | ||
|
3193d2f708 | ||
|
e507cbd000 | ||
|
eb39bef8bc | ||
|
b097f51b13 | ||
|
3784b3d9cd | ||
|
cb47d833cb | ||
|
a5415cf595 | ||
|
43750ba5a0 | ||
|
95da07cdae | ||
|
3027d49847 | ||
|
5ed7319b3e | ||
|
f03044563a | ||
|
8c58482efb | ||
|
5327c47e30 | ||
|
53e411f862 | ||
|
506db84674 | ||
|
f5da5b151b | ||
|
5a0952678f | ||
|
af51a7fa60 | ||
|
2bef5f87db | ||
|
30dd74965d | ||
|
2d1c7a22f4 | ||
|
b2c357b03f | ||
|
b4a6bcbb16 | ||
|
5aeb70d179 | ||
|
71c8de4c0d | ||
|
a660a13876 | ||
|
2e2c471d98 | ||
|
1562e74489 | ||
|
9c799b8f4d | ||
|
4d5e69d785 | ||
|
d35ed96d26 | ||
|
17286223d4 | ||
|
4f5d0befca | ||
|
d8ef69a6da | ||
|
d00d30b2ba | ||
|
f835d8c6ec | ||
|
311f4877c7 | ||
|
217456cbb6 | ||
|
2bd45363e5 | ||
|
a253e00d15 | ||
|
5c0c9d3cee | ||
|
61ac6de86c | ||
|
d18127fea0 | ||
|
1a8e1f6af5 | ||
|
2d349919d0 | ||
|
d5f051890a | ||
|
4d332c36a0 | ||
|
e9a4704df1 | ||
|
251d85ab66 | ||
|
57904d6a5c | ||
|
910c0e15a6 | ||
|
f5e2a65e2e | ||
|
7b70c7e7e8 | ||
|
2d145254fe | ||
|
11c0903b95 | ||
|
b2b3fae5ce | ||
|
14ebac44d9 | ||
|
adb469a29f | ||
|
511b663f2a | ||
|
cd701f187b | ||
|
6d3197413a | ||
|
415835c723 | ||
|
2762ff7507 | ||
|
2754faf98f | ||
|
f671d02a5b | ||
|
1ab9877e77 | ||
|
5e3c966453 | ||
|
fee38fcee5 | ||
|
0d36516e60 | ||
|
c7917c1e73 | ||
|
19c18fd11a | ||
|
7f0583485f | ||
|
45002153c9 | ||
|
1549f950e0 | ||
|
93eb1a9544 | ||
|
c4da960bb8 | ||
|
d3874d3896 | ||
|
c7009e91d3 | ||
|
b98bccbba6 | ||
|
0212af1a6b | ||
|
47f9baf277 | ||
|
6d0ba325f1 | ||
|
2a71ab2bb1 | ||
|
241910ad38 | ||
|
aef9e0d426 | ||
|
a2f7f1dec4 | ||
|
9e2359363b | ||
|
da4fd9d235 | ||
|
7675419d61 | ||
|
b4b2b9d2b0 | ||
|
98d4a30b21 | ||
|
aa67685e45 | ||
|
e66d78bd35 | ||
|
b8688d7fca | ||
|
78139e6e0f | ||
|
53e31020a1 | ||
|
44f78fb1d3 | ||
|
1872921e52 | ||
|
84f008080d | ||
|
27986cbf7a | ||
|
de27a4172b | ||
|
6a3459d988 | ||
|
30750d7062 | ||
|
6282c0e9bf | ||
|
48522b8dcf | ||
|
25af884c7e | ||
|
8ef2d13015 | ||
|
ddb2c6fc21 | ||
|
d27921ea1a | ||
|
49fbd3a8f0 | ||
|
ed882c58f0 | ||
|
68a31b62dd | ||
|
ecdd4d96c2 | ||
|
3927788b66 | ||
|
875da02712 | ||
|
2de8a2511c | ||
|
62126f4b98 | ||
|
fba434cf10 | ||
|
cfd494a5e0 | ||
|
65a8ca1854 | ||
|
f9609a3260 | ||
|
034a926bc9 | ||
|
a767d7d82a | ||
|
ab5403da14 | ||
|
78213fbc78 | ||
|
3ecbb438cd | ||
|
db83c8f53f | ||
|
88512ebca7 | ||
|
f9b141e675 | ||
|
8e45df170b | ||
|
71949e069f | ||
|
2298864acf | ||
|
815af34004 | ||
|
fe30fe8d87 | ||
|
5898b079bf | ||
|
87950f36ce | ||
|
370ec98e38 | ||
|
0cc4aefcee | ||
|
730bbbeb17 | ||
|
39caf003a7 | ||
|
90c5af82dc | ||
|
8034b9ab91 | ||
|
8d14486d61 | ||
|
a24eefa248 | ||
|
164e1a4569 | ||
|
f3eab54330 | ||
|
16891a37c8 | ||
|
0a230d592d | ||
|
d31c6ff0a0 | ||
|
17ea943c64 | ||
|
f3aa6dfad5 | ||
|
144a34b3b9 | ||
|
abb6c45e55 | ||
|
1a3b91fb06 | ||
|
0c0392b3c5 | ||
|
8e181447b2 | ||
|
2442f49408 | ||
|
db6a378032 | ||
|
e9d17e8572 | ||
|
cf0988d442 | ||
|
380aba96cb | ||
|
5df1a0ac41 | ||
|
8b9bfd54a6 | ||
|
c47c6572da | ||
|
c73a41f7e7 | ||
|
d7217cfa88 | ||
|
ba24089a80 | ||
|
24e3242d13 | ||
|
7e0b9c5aba | ||
|
a65fe28c9a | ||
|
0d5e1ceaca | ||
|
cd7ad4fd9c | ||
|
6eeec2d20a | ||
|
2c32671304 | ||
|
a72f15b058 | ||
|
6c95703678 | ||
|
3ed215ee44 | ||
|
fafc53710b | ||
|
935f71d4ab | ||
|
74f761f39e | ||
|
d567d076bb | ||
|
10fd153b0a | ||
|
f02f91dc34 | ||
|
3954583bc5 | ||
|
77eaec7ef9 | ||
|
11c75c5738 | ||
|
4a80ab729b | ||
|
d7d5565355 | ||
|
68688385a0 | ||
|
56d822b417 | ||
|
416b3bbbfc | ||
|
291b109c06 | ||
|
0105d181ab | ||
|
bc2aebe671 | ||
|
95ab757cdc | ||
|
a3e6241081 | ||
|
2c848f0237 | ||
|
e473bae2f1 | ||
|
e3345faa90 | ||
|
b81894db87 | ||
|
2d2e64ea2b | ||
|
a22859dd3d | ||
|
4253955dbb | ||
|
4149d3163b | ||
|
218dce31b8 | ||
|
7484421845 | ||
|
f17df67a9b | ||
|
1fe77fdaa4 | ||
|
e962fde32e | ||
|
70417c1298 | ||
|
6380068889 | ||
|
f619805f40 | ||
|
c9060064de | ||
|
5840c0a1f8 | ||
|
acf0b698e7 | ||
|
a5067afd67 | ||
|
179ac058cb | ||
|
891a91fdf1 | ||
|
329eb3afc7 | ||
|
cf959be65d | ||
|
aeb43f991b | ||
|
7ddde82e8d | ||
|
074999037a | ||
|
dc066b7fba | ||
|
31c4bce960 | ||
|
263998681e | ||
|
f7f3a5c724 | ||
|
d58a228ed2 | ||
|
531b156cd7 | ||
|
539be1ee7b | ||
|
72f5b32cd2 | ||
|
f2458bb3a5 | ||
|
ad7b7c64e3 | ||
|
5df8c2874f | ||
|
f39284074b | ||
|
04c78f0886 | ||
|
3231ea6c74 | ||
|
99817beb31 | ||
|
9fdd36e772 | ||
|
7e5c009484 | ||
|
f0618d8274 | ||
|
75a19dfcc2 | ||
|
1ca7070646 | ||
|
0531d27220 | ||
|
7dce37972b | ||
|
449e6c856f | ||
|
839036eb23 | ||
|
e36d70aefa | ||
|
9012d54da4 | ||
|
004ebea736 | ||
|
86a427964d | ||
|
702ed2748d | ||
|
a2808f3130 | ||
|
cd4bf52aea | ||
|
7a93c4bfc9 | ||
|
4ae1421f0b | ||
|
9eee8e8564 | ||
|
c261a10c9f | ||
|
dcb2859378 | ||
|
87ece57322 | ||
|
c0d2aa0e92 | ||
|
f54e5aec36 | ||
|
44c10910e1 | ||
|
7620862fc1 | ||
|
0001bc7a12 | ||
|
2d4191f03f | ||
|
9d4aaa7a62 | ||
|
c7319028b6 | ||
|
c9889d4598 | ||
|
f8ec599932 | ||
|
3252c6a563 | ||
|
039855b4d0 | ||
|
8977ba41cb | ||
|
958b2de6f9 | ||
|
b2a5fb53fe | ||
|
a9004cdb21 | ||
|
f8cbba943f | ||
|
f0af3cfe03 | ||
|
a14f5f1b32 | ||
|
2e26cbc257 | ||
|
74b9490433 | ||
|
2275d4830f | ||
|
d33beade2b | ||
|
0c3f0d84ee | ||
|
4145dd87ba | ||
|
02dd69efea | ||
|
de294b23d6 | ||
|
c3cb849eb1 | ||
|
01e60a5055 | ||
|
d3449f847b | ||
|
2fa0815a97 | ||
|
6facbf0a7d | ||
|
d43e8adaaf | ||
|
f947e8567b | ||
|
0fffcca1c2 | ||
|
7f5a18b779 | ||
|
f5bd2d0f23 | ||
|
c272eb67fe | ||
|
7befbbf9aa | ||
|
03b18f9c0a | ||
|
5ea4fc90e4 | ||
|
f2667e558f | ||
|
b3573b231c | ||
|
98e8f6d341 | ||
|
c0e1974893 | ||
|
dd5f3ac175 | ||
|
1f89591410 | ||
|
e745fe4c2c | ||
|
e993fcc89e | ||
|
73d66589e7 | ||
|
de9e7b50fe | ||
|
4ce4ee9b9b | ||
|
913545af00 | ||
|
441e4cf7bb | ||
|
06d4413b02 | ||
|
e33b9480c9 | ||
|
f9b73ed8d6 | ||
|
0aa330ad1b | ||
|
b8b4abdfb1 | ||
|
0d5a4d0adf | ||
|
9b9836d40b | ||
|
793db53aa2 | ||
|
7babdb893b | ||
|
6a6ba42d7c | ||
|
dfa2533d7b | ||
|
a02f933722 | ||
|
0640c4bc3b | ||
|
5c9e93f62a | ||
|
0cbdf407cb | ||
|
32bd456fa7 | ||
|
88cf6c1d70 | ||
|
6e4b5b97a7 | ||
|
e8a226cb53 | ||
|
85ac4e8d84 | ||
|
730db32608 | ||
|
c2f5867ca9 | ||
|
32bf814562 | ||
|
c9c971bc30 | ||
|
ea90a08989 | ||
|
bb67eb3f69 | ||
|
1be2b0f2eb | ||
|
ef8d478cf9 | ||
|
0529afb7ff | ||
|
00c487a6ef | ||
|
2524a1be9e | ||
|
fc88fcfc4b | ||
|
7445e7b173 | ||
|
f286ab78bc | ||
|
dad2ead47c | ||
|
057c37d7e7 | ||
|
3c60513190 | ||
|
5de6be4e12 | ||
|
cb3e80b49f | ||
|
6a76718c01 | ||
|
356e6951ce | ||
|
5e6b336139 | ||
|
b69b58005d | ||
|
a1910edb28 | ||
|
9ab81bd4ac | ||
|
72fd6f5d32 | ||
|
27c62df026 | ||
|
abf57e2469 | ||
|
0764a16046 | ||
|
54ec0621ef | ||
|
1adeb63acf | ||
|
eabf1a5fbb | ||
|
ae8ae5a417 | ||
|
f883b92292 | ||
|
72f31282ca | ||
|
7e9009ab17 | ||
|
b2e68bd99c | ||
|
776695b074 | ||
|
a9684b26f3 | ||
|
cc91bb480c | ||
|
63d66463d7 | ||
|
5dcc5d2a82 |
165 changed files with 10956 additions and 3109 deletions
68
INSTALL
68
INSTALL
|
@ -1,68 +0,0 @@
|
|||
WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
REQUIREMENTS
|
||||
|
||||
* Wolfenstein: Enemy Territory server
|
||||
* NoQuarter mod (1.2.7 or higher, maybe 1.2.5 works as well)
|
||||
* Lua 5.1 library and Lua modules enabled (installed binaries)
|
||||
* A MySQL server is required if you want to use alias listing, warn and
|
||||
level history. Otherwise the module will not work, so please make sure
|
||||
you have one. If you want to make use of a MySQL server, the module
|
||||
requires an additional MySQL library (luasql.mysql).
|
||||
In case you do not have the LuaSQL MySQL library installed, you are
|
||||
able to download this library from the WolfAdmin file database at
|
||||
http://dev.timosmit.com/files/wolfadmin/.
|
||||
|
||||
INSTRUCTIONS (NEW)
|
||||
|
||||
* Unpack the /luascripts folder into your /nq directory
|
||||
* Unpack the contents of the /config folder into your /nq directory (or
|
||||
/.etwolf/nq on Linux systems)
|
||||
* Optionally, copy the contents of the cvars.cfg to your own server
|
||||
configuration file
|
||||
* Copy the .pk3 file corresponding to this WolfAdmin version to your
|
||||
/nq directory
|
||||
* Modify /nq/wolfadmin.cfg to your needs
|
||||
* Modify /nq/shrubbot.cfg to add WolfAdmin specific flags
|
||||
* Add /luascripts/wolfadmin/main.lua to the lua_modules cvar
|
||||
* Run the .sql script in /database/new on your MySQL server
|
||||
* Run your server
|
||||
|
||||
INSTRUCTIONS (UPGRADE)
|
||||
|
||||
* Unpack the /luascripts folder into your /nq directory
|
||||
* Run the .sql script in /database/upgrade/previous-version-here on your
|
||||
MySQL server
|
||||
* Run your server
|
||||
|
||||
TROUBLESHOOTING
|
||||
|
||||
* libmysqlclient.so.15: cannot open shared object file: No such file or
|
||||
directory
|
||||
This means you need an additional library for the LuaSQL module, which is
|
||||
used by WolfAdmin for the database connection. This file can usually be
|
||||
downloaded via your package manager or from the WolfAdmin file database
|
||||
at http://dev.timosmit.com/files/wolfadmin/. After downloading you will
|
||||
have to copy this file to your fs_basepath (usually the root folder of
|
||||
the server, where the etded file is located).
|
||||
* WolfAdmin config will not get loaded/one of greetings/rules is not loaded
|
||||
Make sure that there are two empty lines (containing no spaces) at the
|
||||
end of your .cfg files. Due to the loading mechanism WolfAdmin uses, you
|
||||
have to add these completely empty lines, right at the end. Additionally,
|
||||
between two blocks of information you also have to leave an empty line.
|
||||
Check the config files in the /config folder for an example.
|
||||
|
||||
WEBSITE
|
||||
|
||||
Check out the website for a full documentation.
|
||||
|
||||
http://dev.timosmit.com/wolfadmin/
|
||||
|
||||
BUGS
|
||||
|
||||
Please report your bugs at
|
||||
|
||||
http://dev.timosmit.com/bugtracker/?project_id=1
|
||||
|
||||
Thanks in advance :-) Happy bug hunting!
|
675
LICENSE.md
Normal file
675
LICENSE.md
Normal file
|
@ -0,0 +1,675 @@
|
|||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
25
README.md
25
README.md
|
@ -1,2 +1,23 @@
|
|||
# wolfadmin
|
||||
WolfAdmin is a Lua module for Wolfenstein: Enemy Territory servers.
|
||||
# WolfAdmin
|
||||
[WolfAdmin](https://dev.timosmit.com/wolfadmin) is a game manager for Wolfenstein: Enemy Territory servers. Written as a Lua module, it provides you with extra tools to administrate your server. Since the module is run on the server, players do not have to install anything.
|
||||
|
||||
Among the features are many different commands that your administrators may use, automated team balancing, logging of player data and a new set of custom voting options.
|
||||
|
||||
## Installation
|
||||
* Download WolfAdmin from the [website](https://dev.timosmit.com/wolfadmin/download.html).
|
||||
* Follow the [installation instructions](https://dev.timosmit.com/wolfadmin/setup.html).
|
||||
|
||||
### Dependencies
|
||||
Make sure the following dependencies are installed:
|
||||
|
||||
* **luasql.sqlite3** and/or **luasql.mysql**
|
||||
* **lua-toml**
|
||||
|
||||
## Documentation
|
||||
Read the [configuration documentation](https://dev.timosmit.com/wolfadmin/configuration.html) and learn about the vast amount of options.
|
||||
|
||||
## Contributing
|
||||
You can report any issues or feature requests to [Mantis](https://dev.timosmit.com/bugtracker/). Alternatively, you can fix or implement it yourself and send a pull request.
|
||||
|
||||
## License
|
||||
Source code is released under [GNU General Public License 3](http://www.gnu.org/licenses/gpl-3.0.html) license.
|
||||
|
|
16
config/banners.toml
Normal file
16
config/banners.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[[banner]]
|
||||
welcome = true
|
||||
text = "This server is running WolfAdmin."
|
||||
|
||||
[[banner]]
|
||||
welcome = true
|
||||
text = "Type ^7/wolfadmin ^9for more information."
|
||||
|
||||
[[banner]]
|
||||
welcome = true
|
||||
info = true
|
||||
text = "Type ^7!help ^9to view your available commands."
|
||||
|
||||
[[banner]]
|
||||
info = true
|
||||
text = "Remember to have fun!"
|
|
@ -1,27 +0,0 @@
|
|||
// WolfAdmin specific CVARs
|
||||
set g_fileGreetings "greetings.cfg"
|
||||
set g_fileRules "rules.cfg"
|
||||
set g_fileSprees "sprees.cfg"
|
||||
|
||||
set g_welcomeMessage "^dwolfadmin: ^9This server is running WolfAdmin, type ^7/wolfadmin ^9for more information."
|
||||
set g_welcomeArea 3
|
||||
|
||||
set g_greetingArea 3
|
||||
set g_botGreetings 1
|
||||
|
||||
set g_evenerMinDifference 2
|
||||
set g_evenerMaxDifference 5
|
||||
set g_evenerInterval 30
|
||||
|
||||
set g_voteNextMapTimeout 0
|
||||
set g_restrictedVotes ""
|
||||
|
||||
set g_renameLimit 3
|
||||
set g_renameInterval 60
|
||||
|
||||
set g_spreeRecords 1
|
||||
set g_botRecords 1
|
||||
|
||||
set g_warnHistory 1
|
||||
|
||||
set g_announceRevives 1
|
|
@ -1,8 +0,0 @@
|
|||
[level]
|
||||
level = 0
|
||||
greeting = Welcome ^7[N]^9!
|
||||
|
||||
[user]
|
||||
guid = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
greeting = Welcome the console!
|
||||
|
7
config/greetings.toml
Normal file
7
config/greetings.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[[level]]
|
||||
level = 0
|
||||
greeting = "Welcome ^7[N]^9!"
|
||||
|
||||
[[user]]
|
||||
guid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
greeting = "Welcome the console!"
|
|
@ -1,40 +0,0 @@
|
|||
[rule]
|
||||
shortcut = sk
|
||||
rule = ^1NO ^7spawnkilling^9!
|
||||
|
||||
[rule]
|
||||
shortcut = tk
|
||||
rule = ^1NO ^7teamkilling^9!
|
||||
|
||||
[rule]
|
||||
shortcut = tb
|
||||
rule = ^1NO ^7teambleeding^9!
|
||||
|
||||
[rule]
|
||||
shortcut = xp
|
||||
rule = ^1NO ^7XP whoring^9!
|
||||
|
||||
[rule]
|
||||
shortcut = lan
|
||||
rule = ^7English ^9in ^7main ^9and ^7team chat^9.
|
||||
|
||||
[rule]
|
||||
shortcut = chat
|
||||
rule = ^1NO ^7insulting ^9or ^7swearing^9!
|
||||
|
||||
[rule]
|
||||
shortcut = advert
|
||||
rule = ^7Do ^1NOT ^7advertise^9!
|
||||
|
||||
[rule]
|
||||
shortcut = push
|
||||
rule = ^7Do ^1NOT ^9push your ^7team mates^9!
|
||||
|
||||
[rule]
|
||||
shortcut = level
|
||||
rule = ^7Do ^1NOT ^9ask for ^7admin levels^9!
|
||||
|
||||
[rule]
|
||||
shortcut = bug
|
||||
rule = ^7Do ^1NOT ^9use ^7map bugs^9/^7exploits^9!
|
||||
|
39
config/rules.toml
Normal file
39
config/rules.toml
Normal file
|
@ -0,0 +1,39 @@
|
|||
[[rule]]
|
||||
shortcut = "sk"
|
||||
rule = "^1NO ^7spawnkilling^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "tk"
|
||||
rule = "^1NO ^7teamkilling^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "tb"
|
||||
rule = "^1NO ^7teambleeding^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "xp"
|
||||
rule = "^1NO ^7XP whoring^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "lan"
|
||||
rule = "^7English ^9in ^7main ^9and ^7team chat^9."
|
||||
|
||||
[[rule]]
|
||||
shortcut = "chat"
|
||||
rule = "^1NO ^7insulting ^9or ^7swearing^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "advert"
|
||||
rule = "^7Do ^1NOT ^7advertise^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "push"
|
||||
rule = "^7Do ^1NOT ^9push your ^7team mates^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "level"
|
||||
rule = "^7Do ^1NOT ^9ask for ^7admin levels^9!"
|
||||
|
||||
[[rule]]
|
||||
shortcut = "bug"
|
||||
rule = "^7Do ^1NOT ^9use ^7map bugs^9/^7exploits^9!"
|
|
@ -1,8 +0,0 @@
|
|||
[db]
|
||||
type = mysql
|
||||
hostname = localhost
|
||||
port = 3306
|
||||
database = wolfadmin
|
||||
username = wolfadmin
|
||||
password = suchasecret
|
||||
|
59
config/wolfadmin.toml
Normal file
59
config/wolfadmin.toml
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Sample config file for WolfAdmin. Adjust to your needs.
|
||||
|
||||
# See https://dev.timosmit.com/wolfadmin/
|
||||
# https://dev.timosmit.com/wolfadmin/configuration.html
|
||||
|
||||
[main]
|
||||
# uncomment if you need to override these settings
|
||||
# os = "unix"
|
||||
# standalone = 1
|
||||
debug = 0
|
||||
|
||||
[db]
|
||||
type = "sqlite3"
|
||||
file = "wolfadmin.db"
|
||||
# the settings below are only used for type 'mysql', uncomment if needed
|
||||
# hostname = "localhost"
|
||||
# port = 3306
|
||||
# database = "wolfadmin"
|
||||
# username = "wolfadmin"
|
||||
# password = "suchasecret"
|
||||
|
||||
[logs]
|
||||
chat = "chat.log"
|
||||
admin = "admin.log"
|
||||
|
||||
[omnibot]
|
||||
minbots = -1
|
||||
maxbots = 16
|
||||
|
||||
[admin]
|
||||
history = 1
|
||||
maxrenames = 80
|
||||
|
||||
[balancer]
|
||||
mindif = 2
|
||||
maxdif = 5
|
||||
selection = 0
|
||||
interval = 30
|
||||
|
||||
[game]
|
||||
announcerevives = 0
|
||||
|
||||
[voting]
|
||||
timeout = 0
|
||||
restricted = []
|
||||
|
||||
[banners]
|
||||
file = "banners.toml"
|
||||
interval = 120
|
||||
random = 1
|
||||
area = 3
|
||||
|
||||
[rules]
|
||||
file = "rules.toml"
|
||||
|
||||
[greetings]
|
||||
file = "greetings.toml"
|
||||
area = 3
|
||||
bots = 1
|
345
database/new/mysql.sql
Normal file
345
database/new/mysql.sql
Normal file
|
@ -0,0 +1,345 @@
|
|||
CREATE TABLE IF NOT EXISTS `config` (
|
||||
`id` varchar(64) NOT NULL PRIMARY KEY,
|
||||
`value` longtext NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `level` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `level_permission` (
|
||||
`level_id` int(11) NOT NULL,
|
||||
`permission` varchar(32) NOT NULL,
|
||||
PRIMARY KEY (`level_id`,`permission`),
|
||||
CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `player` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`guid` char(32) NOT NULL,
|
||||
`ip` varchar(40) NOT NULL,
|
||||
`level_id` int(11) NOT NULL,
|
||||
`lastseen` int(11) NOT NULL,
|
||||
`seen` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `guid` (`guid`),
|
||||
KEY `player_level_idx` (`level_id`),
|
||||
CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `player_permission` (
|
||||
`player_id` int(10) unsigned NOT NULL,
|
||||
`permission` varchar(32) NOT NULL,
|
||||
PRIMARY KEY (`player_id`,`permission`),
|
||||
CONSTRAINT `player_permission_level` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `alias` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`player_id` int(10) unsigned NOT NULL,
|
||||
`alias` varchar(128) NOT NULL,
|
||||
`cleanalias` varchar(128) NOT NULL,
|
||||
`lastused` int(10) unsigned NOT NULL,
|
||||
`used` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `player_idx` (`player_id`),
|
||||
CONSTRAINT `alias_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `history` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`victim_id` int(10) unsigned NOT NULL,
|
||||
`invoker_id` int(10) unsigned NOT NULL,
|
||||
`type` varchar(16) NOT NULL,
|
||||
`datetime` int(10) unsigned NOT NULL,
|
||||
`reason` varchar(128) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `history_victim_idx` (`victim_id`),
|
||||
KEY `history_invoker_idx` (`invoker_id`),
|
||||
CONSTRAINT `history_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `history_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mute` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`victim_id` int(10) unsigned NOT NULL,
|
||||
`invoker_id` int(10) unsigned NOT NULL,
|
||||
`type` smallint(5) unsigned NOT NULL,
|
||||
`issued` int(10) unsigned NOT NULL,
|
||||
`expires` int(10) unsigned NOT NULL,
|
||||
`duration` int(10) unsigned NOT NULL,
|
||||
`reason` varchar(128) CHARACTER SET utf8 NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `mute_victim_idx` (`victim_id`),
|
||||
KEY `mute_invoker_idx` (`invoker_id`),
|
||||
CONSTRAINT `mute_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `mute_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ban` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`victim_id` int(10) unsigned DEFAULT NULL,
|
||||
`invoker_id` int(10) unsigned NOT NULL,
|
||||
`issued` int(10) unsigned NOT NULL,
|
||||
`expires` int(10) unsigned NOT NULL,
|
||||
`duration` int(10) unsigned NOT NULL,
|
||||
`reason` varchar(128) CHARACTER SET utf8 NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ban_victim_idx` (`victim_id`),
|
||||
KEY `ban_invoker_idx` (`invoker_id`),
|
||||
CONSTRAINT `ban_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `ban_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `map` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(128) NOT NULL,
|
||||
`lastplayed` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `record` (
|
||||
`map_id` int(10) unsigned NOT NULL,
|
||||
`type` tinyint(3) unsigned NOT NULL,
|
||||
`date` int(10) unsigned NOT NULL,
|
||||
`record` smallint(5) unsigned NOT NULL,
|
||||
`player_id` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`map_id`,`type`),
|
||||
KEY `player_idx` (`player_id`),
|
||||
CONSTRAINT `record_map` FOREIGN KEY (`map_id`) REFERENCES `map` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `record_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- insert database version in config
|
||||
INSERT INTO `config` (`id`, `value`) VALUES ('schema_version', '1.2.0');
|
||||
|
||||
-- add levels
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (1, 'Regular');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (2, 'VIP');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
|
||||
|
||||
-- add permissions for level 0
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
|
||||
|
||||
-- add permissions for level 1
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
|
||||
|
||||
-- add permissions for level 2
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999');
|
||||
|
||||
-- add permissions for level 3
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
|
||||
|
||||
-- add permissions for level 4
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
|
||||
|
||||
-- add permissions for level 5
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listusers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'incognito');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy');
|
||||
|
||||
-- add console to players table
|
||||
INSERT INTO `player` (`id`, `guid`, `ip`, `level_id`, `lastseen`, `seen`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1', 5, 0, 0);
|
||||
INSERT INTO `alias` (`id`, `player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES (1, 1, 'console', 'console', 0, 0);
|
357
database/new/sqlite.sql
Normal file
357
database/new/sqlite.sql
Normal file
|
@ -0,0 +1,357 @@
|
|||
CREATE TABLE IF NOT EXISTS `config` (
|
||||
`id` TEXT NOT NULL PRIMARY KEY,
|
||||
`value` TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `level` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `level_permission` (
|
||||
`level_id` INTEGER NOT NULL,
|
||||
`permission` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level_id`, `permission`),
|
||||
CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `player` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`guid` TEXT NOT NULL UNIQUE,
|
||||
`ip` TEXT NOT NULL,
|
||||
`level_id` INTEGER NOT NULL,
|
||||
`lastseen` INTEGER NOT NULL,
|
||||
`seen` INTEGER NOT NULL,
|
||||
CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `player_permission` (
|
||||
`player_id` INTEGER NOT NULL,
|
||||
`permission` TEXT NOT NULL,
|
||||
PRIMARY KEY (`player_id`, `permission`),
|
||||
CONSTRAINT `player_permission_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `alias` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`player_id` INTEGER NOT NULL,
|
||||
`alias` TEXT NOT NULL,
|
||||
`cleanalias` TEXT NOT NULL,
|
||||
`lastused` INTEGER NOT NULL,
|
||||
`used` INTEGER NOT NULL,
|
||||
CONSTRAINT `alias_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `alias_player_idx` ON `alias` (`player_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `history` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`type` TEXT NOT NULL,
|
||||
`datetime` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `history_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `history_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `history_victim_idx` ON `history` (`victim_id`);
|
||||
CREATE INDEX IF NOT EXISTS `history_invoker_idx` ON `history` (`invoker_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mute` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`issued` INTEGER NOT NULL,
|
||||
`expires` INTEGER NOT NULL,
|
||||
`duration` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `mute_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `mute_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `mute_victim_idx` ON `mute` (`victim_id`);
|
||||
CREATE INDEX IF NOT EXISTS `mute_invoker_idx` ON `mute` (`invoker_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ban` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`issued` INTEGER NOT NULL,
|
||||
`expires` INTEGER NOT NULL,
|
||||
`duration` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `ban_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `ban_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `ban_victim_idx` ON `ban` (`victim_id`);
|
||||
CREATE INDEX IF NOT EXISTS `ban_invoker_idx` ON `ban` (`invoker_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `map` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`lastplayed` INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `record` (
|
||||
`map_id` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`date` INTEGER NOT NULL,
|
||||
`record` INTEGER NOT NULL,
|
||||
`player_id` INTEGER NOT NULL,
|
||||
PRIMARY KEY (`map_id`, `type`),
|
||||
CONSTRAINT `record_map` FOREIGN KEY (`map_id`) REFERENCES `map` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `record_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `record_player_idx` ON `record` (`player_id`);
|
||||
|
||||
-- insert database version in config
|
||||
INSERT INTO `config` (`id`, `value`) VALUES ('schema_version', '1.2.0');
|
||||
|
||||
-- add levels
|
||||
BEGIN;
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (1, 'Regular');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (2, 'VIP');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin');
|
||||
INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 0
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 1
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 2
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 3
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 4
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');
|
||||
COMMIT;
|
||||
|
||||
-- add permissions for level 5
|
||||
BEGIN;
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listusers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'incognito');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds');
|
||||
|
||||
INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy');
|
||||
COMMIT;
|
||||
|
||||
-- add console to players table
|
||||
BEGIN;
|
||||
INSERT INTO `player` (`id`, `guid`, `ip`, `level_id`, `lastseen`, `seen`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1', 5, 0, 0);
|
||||
INSERT INTO `alias` (`id`, `player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES (1, 1, 'console', 'console', 0, 0);
|
||||
COMMIT;
|
|
@ -1,67 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS `players` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`guid` char(32) NOT NULL,
|
||||
`ip` varchar(40) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `guid` (`guid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `aliases` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`player` int(10) unsigned NOT NULL,
|
||||
`alias` varchar(128) NOT NULL,
|
||||
`cleanalias` varchar(128) NOT NULL,
|
||||
`lastused` int(10) unsigned NOT NULL,
|
||||
`used` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `playerid_idx` (`player`),
|
||||
CONSTRAINT `aliasplayer` FOREIGN KEY (`player`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `levels` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`player` int(10) unsigned NOT NULL,
|
||||
`level` int(11) NOT NULL,
|
||||
`admin` int(10) unsigned NOT NULL,
|
||||
`datetime` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `leveladmin_idx` (`admin`),
|
||||
KEY `levelplayer` (`player`),
|
||||
CONSTRAINT `leveladmin` FOREIGN KEY (`admin`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `levelplayer` FOREIGN KEY (`player`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `warns` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`player` int(10) unsigned NOT NULL,
|
||||
`reason` varchar(128) NOT NULL,
|
||||
`admin` int(10) unsigned NOT NULL,
|
||||
`datetime` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `playerid_idx` (`player`),
|
||||
KEY `invoker_idx` (`admin`),
|
||||
CONSTRAINT `warnadmin` FOREIGN KEY (`admin`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `warnplayer` FOREIGN KEY (`player`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `maps` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(128) NOT NULL,
|
||||
`lastplayed` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `records` (
|
||||
`mapid` int(10) unsigned NOT NULL,
|
||||
`type` tinyint(3) unsigned NOT NULL,
|
||||
`date` int(10) unsigned NOT NULL,
|
||||
`record` smallint(5) unsigned NOT NULL,
|
||||
`player` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`mapid`,`type`),
|
||||
KEY `ksplayer_idx` (`player`),
|
||||
CONSTRAINT `kspreeplayer` FOREIGN KEY (`player`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `spreemap` FOREIGN KEY (`mapid`) REFERENCES `maps` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO `players` (`id`, `guid`, `ip`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1');
|
||||
INSERT INTO `aliases` (`id`, `player`, `alias`, `lastused`, `used`) VALUES (1, 1, 'console', 0, 0);
|
|
@ -1,21 +0,0 @@
|
|||
CREATE TABLE `maps` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(128) NOT NULL,
|
||||
`lastplayed` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `records` (
|
||||
`mapid` int(10) unsigned NOT NULL,
|
||||
`type` tinyint(3) unsigned NOT NULL,
|
||||
`date` int(10) unsigned NOT NULL,
|
||||
`record` smallint(5) unsigned NOT NULL,
|
||||
`player` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`mapid`,`type`),
|
||||
KEY `ksplayer_idx` (`player`),
|
||||
CONSTRAINT `kspreeplayer` FOREIGN KEY (`player`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `spreemap` FOREIGN KEY (`mapid`) REFERENCES `maps` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO `wolfadmin`.`players` (`id`, `guid`, `ip`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1');
|
||||
INSERT INTO `wolfadmin`.`aliases` (`id`, `player`, `alias`, `lastused`, `used`) VALUES (1, 1, 'console', 0, 0);
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE `wolfadmin`.`aliases`
|
||||
ADD COLUMN `cleanalias` VARCHAR(128) NOT NULL AFTER `alias`;
|
2
database/upgrade/1.2.0/mysql.sql
Normal file
2
database/upgrade/1.2.0/mysql.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- rename 'incognito' permission to 'noaka'
|
||||
UPDATE `player_permission` SET `permission`='noaka' WHERE `permission`='incognito';
|
27
database/upgrade/1.2.0/sqlite.sql
Normal file
27
database/upgrade/1.2.0/sqlite.sql
Normal file
|
@ -0,0 +1,27 @@
|
|||
-- rename 'incognito' permission to 'noaka'
|
||||
UPDATE `player_permission` SET `permission`='noaka' WHERE `permission`='incognito';
|
||||
|
||||
-- fix mute type column type
|
||||
ALTER TABLE `mute` RENAME TO `mute_old`;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mute` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`issued` INTEGER NOT NULL,
|
||||
`expires` INTEGER NOT NULL,
|
||||
`duration` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `mute_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `mute_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS `mute_victim_idx` ON `mute` (`victim_id`);
|
||||
CREATE INDEX IF NOT EXISTS `mute_invoker_idx` ON `mute` (`invoker_id`);
|
||||
|
||||
INSERT INTO `mute` (`id`, `victim_id`, `invoker_id`, `type`, `issued`, `expires`, `duration`, `reason`)
|
||||
SELECT `id`, `victim_id`, `invoker_id`, `type`, `issued`, `expires`, `duration`, `reason`
|
||||
FROM `mute_old`;
|
||||
|
||||
DROP TABLE `mute_old`;
|
408
deploy.sh
Normal file
408
deploy.sh
Normal file
|
@ -0,0 +1,408 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
# Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# at your option any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
curr_version="1.2.0"
|
||||
|
||||
read_config() {
|
||||
db_type=$(grep -oP '(?<=type = ")(sqlite3|mysql)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
|
||||
if [ $db_type == 'sqlite3' ]; then
|
||||
db_file=$(grep -oP '(?<=file = ")([a-zA-Z0-9_]+\.db)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
elif [ $db_type == 'mysql' ]; then
|
||||
db_hostname=$(grep -oP '(?<=hostname = ")([a-zA-Z0-9]+)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
db_port=$(grep -oP '(?<=port = ")([0-9]{0,5})(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
db_database=$(grep -oP '(?<=database = ")([a-zA-Z0-9_]+)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
db_username=$(grep -oP '(?<=username = ")([a-zA-Z0-9_]+)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
db_password=$(grep -oP '(?<=password = ")(.+)(?=")' $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml)
|
||||
fi
|
||||
|
||||
echo
|
||||
}
|
||||
|
||||
install_lualibs() {
|
||||
echo -n 'copying lualibs...'
|
||||
cp -r -u lualibs/ $fs_basepath/$fs_game/
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install_luascripts() {
|
||||
echo -n 'copying luascripts...'
|
||||
cp -r -u luascripts/ $fs_basepath/$fs_game/
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install_configs() {
|
||||
echo -n 'copying configs...'
|
||||
cp -n config/* $fs_homepath/$fs_homedir/$fs_game/
|
||||
|
||||
if [ $db_type == 'sqlite' ]; then
|
||||
sed -i -e "s/type = \"sqlite3\"/type = \"$db_type\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/file = \"wolfadmin.db\"/file = \"$db_file\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
elif [ $db_type == 'mysql' ]; then
|
||||
sed -i -e "s/type = \"sqlite3\"/type = \"$db_type\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/file = \"wolfadmin.db\"/# file = \"wolfadmin.db\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/# hostname = \"localhost\"/hostname = \"$db_hostname\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/# port = 3306/port = \"$db_port\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/# database = \"wolfadmin\"/database = \"$db_database\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/# username = \"wolfadmin\"/username = \"$db_username\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
sed -i -e "s/# password = \"suchasecret\"/password = \"$db_password\"/" $fs_homepath/$fs_homedir/$fs_game/wolfadmin.toml
|
||||
fi
|
||||
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install_db_sqlite() {
|
||||
echo "$fs_homepath/$fs_homedir/$fs_game/$db_file"
|
||||
|
||||
echo -n 'initializing database...';
|
||||
sqlite3 $fs_homepath/$fs_homedir/$fs_game/$db_file < database/new/sqlite.sql
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install_db_mysql() {
|
||||
echo -n 'initializing database...';
|
||||
mysql -h $db_hostname -D $db_database -u $db_username -p$db_password < database/new/mysql.sql
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install_pk3() {
|
||||
echo -n 'zipping pk3...';
|
||||
pushd pk3
|
||||
zip -r -q ../wolfadmin-$curr_version.pk3 .
|
||||
popd
|
||||
echo 'done.'
|
||||
echo -n 'copying pk3...';
|
||||
cp wolfadmin-$curr_version.pk3 $fs_basepath/$fs_game
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
install() {
|
||||
echo
|
||||
|
||||
if [ -d $fs_basepath/$fs_game/luascripts/wolfadmin ]; then
|
||||
echo 'WolfAdmin has already been installed'
|
||||
exit
|
||||
fi
|
||||
|
||||
install_lualibs
|
||||
install_luascripts
|
||||
|
||||
read -p 'db_type (sqlite3/mysql): ' db_type
|
||||
|
||||
if [ -z $db_type ]; then
|
||||
echo 'db_type cannot be empty'
|
||||
exit
|
||||
elif [ $db_type != 'sqlite3' ] && [ $db_type != 'mysql' ]; then
|
||||
echo 'unknown db_type'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $db_type == 'sqlite3' ]; then
|
||||
read -p 'db_file (wolfadmin.db): ' db_file
|
||||
|
||||
if [ -z $db_file ]; then
|
||||
db_file='wolfadmin.db'
|
||||
elif [[ $db_file != *.db ]]; then
|
||||
echo 'db_file should end with .db'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -e $fs_homepath/$fs_homedir/$fs_game/$db_file ]; then
|
||||
while true; do
|
||||
read -p 'database already exists, append? (y/n) ' yn
|
||||
case $yn in
|
||||
[Yy]* ) install_db_sqlite; break;;
|
||||
[Nn]* ) echo 'database not created'; break;;
|
||||
* ) echo 'please answer yes or no.';;
|
||||
esac
|
||||
done
|
||||
else
|
||||
install_db_sqlite
|
||||
fi
|
||||
elif [ $db_type == 'mysql' ]; then
|
||||
read -p 'db_hostname (localhost): ' db_hostname
|
||||
|
||||
if [ -z $db_hostname ]; then
|
||||
db_hostname='localhost'
|
||||
fi
|
||||
|
||||
read -p 'db_port (3306): ' db_port
|
||||
|
||||
if [ -z $db_port ]; then
|
||||
db_port=3306
|
||||
fi
|
||||
|
||||
read -p 'db_database (wolfadmin): ' db_database
|
||||
|
||||
if [ -z $db_database ]; then
|
||||
db_database='wolfadmin'
|
||||
fi
|
||||
|
||||
read -p 'db_username (wolfadmin): ' db_username
|
||||
|
||||
if [ -z $db_username ]; then
|
||||
echo 'db_username cannot be empty'
|
||||
exit
|
||||
fi
|
||||
|
||||
read -s -p 'db_password: ' db_password
|
||||
|
||||
if [ -z $db_password ]; then
|
||||
echo 'db_password cannot be empty'
|
||||
exit
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
install_db_mysql
|
||||
fi
|
||||
|
||||
install_configs
|
||||
|
||||
while true; do
|
||||
read -p 'install pk3 (y/n) ' yn
|
||||
case $yn in
|
||||
[Yy]* ) install_pk3; break;;
|
||||
[Nn]* ) echo 'pk3 not installed'; break;;
|
||||
* ) echo 'please answer yes or no.';;
|
||||
esac
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
echo 'install process finished.'
|
||||
}
|
||||
|
||||
update_lualibs() {
|
||||
install_lualibs
|
||||
}
|
||||
|
||||
update_luascripts() {
|
||||
echo -n 'removing old luascripts...'
|
||||
rm -r $fs_basepath/$fs_game/luascripts/wolfadmin/
|
||||
echo 'done.'
|
||||
|
||||
install_luascripts
|
||||
}
|
||||
|
||||
update_configs() {
|
||||
install_configs
|
||||
}
|
||||
|
||||
update_db_sqlite() {
|
||||
echo -n 'updating database...'
|
||||
sqlite3 $fs_homepath/$fs_homedir/$fs_game/$db_file < database/upgrade/$prev_version/sqlite.sql
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
update_db_mysql() {
|
||||
echo -n 'updating database...'
|
||||
mysql -h $db_hostname -D $db_database -u $db_username -p$db_password < database/upgrade/$prev_version/mysql.sql
|
||||
echo 'done.'
|
||||
}
|
||||
|
||||
update_pk3() {
|
||||
if [ ! -e $fs_homepath/$fs_homedir/$fs_game/wolfadmin*.pk3 ]; then
|
||||
while true; do
|
||||
read -p 'install pk3? (y/n) ' yn
|
||||
case $yn in
|
||||
[Yy]* ) break;;
|
||||
[Nn]* ) echo 'pk3 not updated'; return;; # break;;
|
||||
* ) echo 'please answer yes or no.';;
|
||||
esac
|
||||
done
|
||||
else
|
||||
rm $fs_homepath/$fs_homedir/$fs_game/wolfadmin*.pk3
|
||||
echo 'removed old pk3'
|
||||
fi
|
||||
|
||||
install_pk3
|
||||
}
|
||||
|
||||
update() {
|
||||
echo
|
||||
|
||||
if [ ! -d $fs_basepath/$fs_game/luascripts/wolfadmin ]; then
|
||||
echo 'WolfAdmin has not been installed'
|
||||
exit
|
||||
fi
|
||||
|
||||
read_config
|
||||
|
||||
read -p 'Have you backupped any changes/additions to WolfAdmin sources? (y/n) ' yn
|
||||
|
||||
if [ $yn != 'y' ]; then
|
||||
echo 'Please backup any modifications to WolfAdmin.'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $db_type == 'sqlite3' ]; then
|
||||
table_check=$(sqlite3 $fs_homepath/$fs_homedir/$fs_game/$db_file "SELECT 1 FROM player" 2>/dev/null)
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
echo 'Database does not exist'
|
||||
exit
|
||||
fi
|
||||
|
||||
prev_version=$(sqlite3 $fs_homepath/$fs_homedir/$fs_game/$db_file "SELECT value FROM config WHERE id='schema_version'" 2>/dev/null)
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
echo 'Database version unknown'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -x database/upgrade/$prev_version/sqlite.sql ]; then
|
||||
echo "Cannot update from version $prev_version to version $curr_version; no database scripts available."
|
||||
exit
|
||||
fi
|
||||
elif [ $db_type == 'mysql' ]; then
|
||||
table_check=$(mysql -h $db_hostname -D $db_database -u $db_username -p$db_password -e "SELECT 1 FROM player" 2>/dev/null)
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
echo 'Database does not exist'
|
||||
exit
|
||||
fi
|
||||
|
||||
prev_version=$(mysql -h $db_hostname -D $db_database -u $db_username -p$db_password -e "SELECT value FROM config WHERE id='schema_version'" 2>/dev/null)
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
echo 'Database version unknown'
|
||||
fi
|
||||
|
||||
if [ ! -x database/upgrade/$prev_version/mysql.sql ]; then
|
||||
echo "Cannot update from version $prev_version to version $curr_version; no database scripts available."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
update_lualibs
|
||||
update_luascripts
|
||||
|
||||
if [ $db_type == 'sqlite3' ]; then
|
||||
update_db_sqlite
|
||||
elif [ $db_type == 'mysql' ]; then
|
||||
update_db_mysql
|
||||
fi
|
||||
|
||||
update_pk3
|
||||
update_configs
|
||||
|
||||
echo
|
||||
|
||||
echo 'update process finished.'
|
||||
}
|
||||
|
||||
echo "WolfAdmin $curr_version deployment script"
|
||||
|
||||
echo
|
||||
|
||||
echo "This script is HIGHLY experimental. You cannot use this script for \
|
||||
WolfAdmin versions pre-1.1.0. Make sure you have backupped your database. I am \
|
||||
not responsible for any data loss."
|
||||
|
||||
echo
|
||||
|
||||
echo -n 'Checking package integrity...'
|
||||
if [ ! -d 'lualibs' ]; then
|
||||
echo
|
||||
echo 'lualibs dir does not exist'
|
||||
exit
|
||||
elif [ ! -d 'luascripts' ]; then
|
||||
echo
|
||||
echo 'luascripts dir does not exist'
|
||||
exit
|
||||
elif [ ! -d 'config' ]; then
|
||||
echo
|
||||
echo 'config dir does not exist'
|
||||
exit
|
||||
elif [ ! -d 'database' ] || [ ! -d 'database/new' ] || \
|
||||
[ ! -e 'database/new/sqlite.sql' ] || [ ! -e 'database/new/mysql.sql' ] || \
|
||||
[ ! -d 'database/upgrade' ]; then
|
||||
echo
|
||||
echo 'database dir does not exist or is incomplete'
|
||||
exit
|
||||
elif [ ! -d 'pk3' ]; then
|
||||
echo
|
||||
echo 'pk3 dir does not exist'
|
||||
exit
|
||||
fi
|
||||
echo 'OK'
|
||||
|
||||
echo -n 'Checking dependencies...'
|
||||
if [ ! -x "$(command -v sqlite3)" ]; then
|
||||
echo
|
||||
echo 'sqlite3 executable does not exist'
|
||||
fi
|
||||
if [ ! -x "$(command -v mysql)" ]; then
|
||||
echo
|
||||
echo 'mysql executable does not exist'
|
||||
fi
|
||||
echo 'OK'
|
||||
|
||||
read -p 'fs_basepath (install directory): ' fs_basepath
|
||||
fs_basepath=/home/timo/game/fsb
|
||||
|
||||
if [ -z $fs_basepath ]; then
|
||||
echo 'fs_basepath cannot be empty'
|
||||
exit
|
||||
elif [ ! -d $fs_basepath ]; then
|
||||
echo 'fs_basepath does not exist'
|
||||
exit
|
||||
fi
|
||||
|
||||
read -p 'fs_homepath (user directory): ' fs_homepath
|
||||
fs_homepath=/home/timo/game/fsh
|
||||
|
||||
if [ -z $fs_homepath ]; then
|
||||
echo 'fs_homepath cannot be empty'
|
||||
exit
|
||||
elif [ ! -d $fs_homepath ]; then
|
||||
echo 'fs_homepath does not exist'
|
||||
exit
|
||||
elif [ -d $fs_homepath/.etlegacy ]; then
|
||||
fs_homedir=.etlegacy
|
||||
elif [ -d $fs_homepath/.wolfet ]; then
|
||||
fs_homedir=.wolfet
|
||||
else
|
||||
echo 'fs_homepath does not contain a .etlegacy or .wolfet directory'
|
||||
exit
|
||||
fi
|
||||
|
||||
read -p 'fs_game (e.g. legacy, nq): ' fs_game
|
||||
fs_game=mod
|
||||
|
||||
if [ -z $fs_game ]; then
|
||||
echo 'fs_game cannot be empty'
|
||||
exit
|
||||
elif [ ! -d $fs_basepath/$fs_game ]; then
|
||||
echo 'fs_basepath/fs_game does not exist'
|
||||
exit
|
||||
elif [ ! -d $fs_homepath/$fs_homedir/$fs_game ]; then
|
||||
echo 'fs_basepath/fs_homedir/fs_game does not exist'
|
||||
exit
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
while true; do
|
||||
read -p 'install or update? (i/u) ' mode
|
||||
case $mode in
|
||||
[Ii]* ) install; break;;
|
||||
[Uu]* ) update; break;;
|
||||
esac
|
||||
done
|
419
lualibs/legacydb.lua
Normal file
419
lualibs/legacydb.lua
Normal file
|
@ -0,0 +1,419 @@
|
|||
--[[
|
||||
Author: [ET:Legacy Team]
|
||||
License: GPLv3
|
||||
Website: http://www.etlegacy.com
|
||||
Mod: compatible with Legacy mod only
|
||||
Description: WolfAdmin 'plug and play' integration
|
||||
]]--
|
||||
|
||||
local function createDb()
|
||||
-- FIXME: Do bulk insert
|
||||
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `config` (
|
||||
`id` TEXT NOT NULL PRIMARY KEY,
|
||||
`value` TEXT NOT NULL
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `level` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `level_permission` (
|
||||
`level_id` INTEGER NOT NULL,
|
||||
`permission` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level_id`, `permission`),
|
||||
CONSTRAINT `level_permission_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `player` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`guid` TEXT NOT NULL UNIQUE,
|
||||
`ip` TEXT NOT NULL,
|
||||
`level_id` INTEGER NOT NULL,
|
||||
`lastseen` INTEGER NOT NULL,
|
||||
`seen` INTEGER NOT NULL,
|
||||
CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `player_permission` (
|
||||
`player_id` INTEGER NOT NULL,
|
||||
`permission` TEXT NOT NULL,
|
||||
PRIMARY KEY (`player_id`, `permission`),
|
||||
CONSTRAINT `player_permission_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `alias` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`player_id` INTEGER NOT NULL,
|
||||
`alias` TEXT NOT NULL,
|
||||
`cleanalias` TEXT NOT NULL,
|
||||
`lastused` INTEGER NOT NULL,
|
||||
`used` INTEGER NOT NULL,
|
||||
CONSTRAINT `alias_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `alias_player_idx` ON `alias` (`player_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `history` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`type` TEXT NOT NULL,
|
||||
`datetime` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `history_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `history_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `history_victim_idx` ON `history` (`victim_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `history_invoker_idx` ON `history` (`invoker_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `mute` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`type` TEXT NOT NULL,
|
||||
`issued` INTEGER NOT NULL,
|
||||
`expires` INTEGER NOT NULL,
|
||||
`duration` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `mute_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `mute_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `mute_victim_idx` ON `mute` (`victim_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `mute_invoker_idx` ON `mute` (`invoker_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `ban` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`victim_id` INTEGER NOT NULL,
|
||||
`invoker_id` INTEGER NOT NULL,
|
||||
`issued` INTEGER NOT NULL,
|
||||
`expires` INTEGER NOT NULL,
|
||||
`duration` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
CONSTRAINT `ban_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `ban_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `ban_victim_idx` ON `ban` (`victim_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `ban_invoker_idx` ON `ban` (`invoker_id`);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `map` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`lastplayed` INTEGER NOT NULL
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE TABLE IF NOT EXISTS `record` (
|
||||
`map_id` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`date` INTEGER NOT NULL,
|
||||
`record` INTEGER NOT NULL,
|
||||
`player_id` INTEGER NOT NULL,
|
||||
PRIMARY KEY (`map_id`, `type`),
|
||||
CONSTRAINT `record_map` FOREIGN KEY (`map_id`) REFERENCES `map` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `record_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
]])
|
||||
cur = assert(con:execute[[
|
||||
CREATE INDEX IF NOT EXISTS `record_player_idx` ON `record` (`player_id`);
|
||||
]])
|
||||
-- cur:close()
|
||||
end
|
||||
|
||||
local function populateDb()
|
||||
|
||||
-- FIXME: Do bulk insert
|
||||
-- cur = assert(con:setautocommit(true))
|
||||
-- cur = assert(con:commit(true, "IMMEDIATE"))
|
||||
-- cur = assert(con:execute[[
|
||||
-- BEGIN;
|
||||
-- ...
|
||||
-- COMMIT;
|
||||
-- ]])
|
||||
|
||||
-- insert database version in config
|
||||
cur = assert(con:execute[[INSERT INTO `config` (`id`, `value`) VALUES ('schema_version', '1.2.0');]])
|
||||
|
||||
-- add levels
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (0, 'Guest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (1, 'Regular');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (2, 'VIP');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (3, 'Admin');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (4, 'Senior Admin');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level` (`id`, `name`) VALUES (5, 'Server Owner');]])
|
||||
|
||||
-- add permissions for level 0
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (0, 'greeting');]])
|
||||
|
||||
-- add permissions for level 1
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'greeting');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listmaps');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listsprees');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (1, 'listrules');]])
|
||||
|
||||
-- add permissions for level 2
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'greeting');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listteams');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listmaps');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listsprees');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'listrules');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (2, 'spec999');]])
|
||||
|
||||
-- add permissions for level 3
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'greeting');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listteams');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listmaps');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listsprees');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listrules');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listhistory');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'listbans');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'liststats');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'adminchat');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'put');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'dropweapons');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'warn');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'mute');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'voicemute');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'spec999');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'balance');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'cointoss');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'pause');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nextmap');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'restart');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'botadmin');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'enablevote');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'noinactivity');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'nocensor');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (3, 'novotelimit');]])
|
||||
|
||||
-- add permissions for level 4
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'greeting');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listteams');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listmaps');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listsprees');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listrules');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listhistory');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listwarns');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listbans');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'listaliases');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'liststats');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'finger');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'adminchat');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'put');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'dropweapons');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'rename');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'freeze');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'disorient');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'burn');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'slap');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'gib');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'throw');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'glow');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pants');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pop');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'warn');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'mute');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'voicemute');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'kick');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'ban');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'spec999');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'balance');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'lockteam');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'shuffle');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'swap');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cointoss');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'pause');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nextmap');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'restart');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'botadmin');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'enablevote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'cancelvote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'passvote');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'news');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noinactivity');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nocensor');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'nobalance');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'novotelimit');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'noreason');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'teamcmds');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (4, 'silentcmds');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'admintest');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'help');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'time');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'greeting');]])
|
||||
|
||||
-- add permissions for level 5
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listteams');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listmaps');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listsprees');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listrules');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listhistory');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listwarns');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listbans');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'listaliases');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'liststats');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'finger');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'adminchat');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'put');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'dropweapons');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'rename');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'freeze');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'disorient');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'burn');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'slap');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'gib');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'throw');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'glow');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pants');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pop');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'warn');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'mute');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'voicemute');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'kick');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'ban');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spec999');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'balance');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockplayers');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'lockteam');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'shuffle');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'swap');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cointoss');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'pause');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nextmap');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'restart');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'botadmin');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'enablevote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'cancelvote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'passvote');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'news');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'uptime');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'setlevel');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'readconfig');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noinactivity');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novote');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nocensor');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'nobalance');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'novotelimit');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'noreason');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'perma');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'teamcmds');]])
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'silentcmds');]])
|
||||
|
||||
cur = assert(con:execute[[INSERT INTO `level_permission`(`level_id`, `permission`) VALUES (5, 'spy');]])
|
||||
|
||||
-- add console to players table
|
||||
cur = assert(con:execute[[INSERT INTO `player` (`id`, `guid`, `ip`, `level_id`, `lastseen`, `seen`) VALUES (1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '127.0.0.1', 5, 0, 0);]])
|
||||
cur = assert(con:execute[[INSERT INTO `alias` (`id`, `player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES (1, 1, 'console', 'console', 0, 0);]])
|
||||
|
||||
-- cur:close()
|
||||
end
|
||||
|
||||
-- load sqlite driver
|
||||
local luasql = require "luasql.sqlite3"
|
||||
|
||||
-- database path
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local dbpath = wolfa_getHomePath()..settings.get("db_file")
|
||||
|
||||
-- check if database exists
|
||||
local file=io.open(dbpath,"r")
|
||||
if file~=nil then io.close(file)
|
||||
return
|
||||
else
|
||||
outputDebug("^3[Legacy] Initial database not found...")
|
||||
end
|
||||
|
||||
-- create environement object
|
||||
env = assert(luasql.sqlite3())
|
||||
|
||||
-- connect to database
|
||||
con = assert(env:connect(dbpath))
|
||||
|
||||
-- create database
|
||||
outputDebug("^3[Legacy] Creating database...")
|
||||
createDb()
|
||||
|
||||
-- populate database
|
||||
outputDebug("^3[Legacy] Populating database... this will take a few seconds")
|
||||
populateDb()
|
665
lualibs/toml.lua
Normal file
665
lualibs/toml.lua
Normal file
|
@ -0,0 +1,665 @@
|
|||
-- TOML in Lua by Jonathan Stoler
|
||||
-- https://github.com/jonstoler/lua-toml
|
||||
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
|
||||
-- The above copyright notice and this permission notice shall be included in
|
||||
-- all copies or substantial portions of the Software.
|
||||
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
|
||||
local TOML = {
|
||||
-- denotes the current supported TOML version
|
||||
version = 0.40,
|
||||
|
||||
-- sets whether the parser should follow the TOML spec strictly
|
||||
-- currently, no errors are thrown for the following rules if strictness is turned off:
|
||||
-- tables having mixed keys
|
||||
-- redefining a table
|
||||
-- redefining a key within a table
|
||||
strict = true,
|
||||
}
|
||||
|
||||
-- converts TOML data into a lua table
|
||||
TOML.parse = function(toml, options)
|
||||
options = options or {}
|
||||
local strict = (options.strict ~= nil and options.strict or TOML.strict)
|
||||
|
||||
-- the official TOML definition of whitespace
|
||||
local ws = "[\009\032]"
|
||||
|
||||
-- the official TOML definition of newline
|
||||
local nl = "[\10"
|
||||
do
|
||||
local crlf = "\13\10"
|
||||
nl = nl .. crlf
|
||||
end
|
||||
nl = nl .. "]"
|
||||
|
||||
-- stores text data
|
||||
local buffer = ""
|
||||
|
||||
-- the current location within the string to parse
|
||||
local cursor = 1
|
||||
|
||||
-- the output table
|
||||
local out = {}
|
||||
|
||||
-- the current table to write to
|
||||
local obj = out
|
||||
|
||||
-- returns the next n characters from the current position
|
||||
local function char(n)
|
||||
n = n or 0
|
||||
return toml:sub(cursor + n, cursor + n)
|
||||
end
|
||||
|
||||
-- moves the current position forward n (default: 1) characters
|
||||
local function step(n)
|
||||
n = n or 1
|
||||
cursor = cursor + n
|
||||
end
|
||||
|
||||
-- move forward until the next non-whitespace character
|
||||
local function skipWhitespace()
|
||||
while(char():match(ws)) do
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
-- remove the (Lua) whitespace at the beginning and end of a string
|
||||
local function trim(str)
|
||||
return str:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
|
||||
-- divide a string into a table around a delimiter
|
||||
local function split(str, delim)
|
||||
if str == "" then return {} end
|
||||
local result = {}
|
||||
local append = delim
|
||||
if delim:match("%%") then
|
||||
append = delim:gsub("%%", "")
|
||||
end
|
||||
for match in (str .. append):gmatch("(.-)" .. delim) do
|
||||
table.insert(result, match)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- produce a parsing error message
|
||||
-- the error contains the line number of the current position
|
||||
local function err(message, strictOnly)
|
||||
if not strictOnly or (strictOnly and strict) then
|
||||
local line = 1
|
||||
local c = 0
|
||||
for l in toml:gmatch("(.-)" .. nl) do
|
||||
c = c + l:len()
|
||||
if c >= cursor then
|
||||
break
|
||||
end
|
||||
line = line + 1
|
||||
end
|
||||
error("TOML: " .. message .. " on line " .. line .. ".", 4)
|
||||
end
|
||||
end
|
||||
|
||||
-- prevent infinite loops by checking whether the cursor is
|
||||
-- at the end of the document or not
|
||||
local function bounds()
|
||||
return cursor <= toml:len()
|
||||
end
|
||||
|
||||
local function parseString()
|
||||
local quoteType = char() -- should be single or double quote
|
||||
|
||||
-- this is a multiline string if the next 2 characters match
|
||||
local multiline = (char(1) == char(2) and char(1) == char())
|
||||
|
||||
-- buffer to hold the string
|
||||
local str = ""
|
||||
|
||||
-- skip the quotes
|
||||
step(multiline and 3 or 1)
|
||||
|
||||
while(bounds()) do
|
||||
if multiline and char():match(nl) and str == "" then
|
||||
-- skip line break line at the beginning of multiline string
|
||||
step()
|
||||
end
|
||||
|
||||
-- keep going until we encounter the quote character again
|
||||
if char() == quoteType then
|
||||
if multiline then
|
||||
if char(1) == char(2) and char(1) == quoteType then
|
||||
step(3)
|
||||
break
|
||||
end
|
||||
else
|
||||
step()
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if char():match(nl) and not multiline then
|
||||
err("Single-line string cannot contain line break")
|
||||
end
|
||||
|
||||
-- if we're in a double-quoted string, watch for escape characters!
|
||||
if quoteType == '"' and char() == "\\" then
|
||||
if multiline and char(1):match(nl) then
|
||||
-- skip until first non-whitespace character
|
||||
step(1) -- go past the line break
|
||||
while(bounds()) do
|
||||
if not char():match(ws) and not char():match(nl) then
|
||||
break
|
||||
end
|
||||
step()
|
||||
end
|
||||
else
|
||||
-- all available escape characters
|
||||
local escape = {
|
||||
b = "\b",
|
||||
t = "\t",
|
||||
n = "\n",
|
||||
f = "\f",
|
||||
r = "\r",
|
||||
['"'] = '"',
|
||||
["\\"] = "\\",
|
||||
}
|
||||
-- utf function from http://stackoverflow.com/a/26071044
|
||||
-- converts \uXXX into actual unicode
|
||||
local function utf(char)
|
||||
local bytemarkers = {{0x7ff, 192}, {0xffff, 224}, {0x1fffff, 240}}
|
||||
if char < 128 then return string.char(char) end
|
||||
local charbytes = {}
|
||||
for bytes, vals in pairs(bytemarkers) do
|
||||
if char <= vals[1] then
|
||||
for b = bytes + 1, 2, -1 do
|
||||
local mod = char % 64
|
||||
char = (char - mod) / 64
|
||||
charbytes[b] = string.char(128 + mod)
|
||||
end
|
||||
charbytes[1] = string.char(vals[2] + char)
|
||||
break
|
||||
end
|
||||
end
|
||||
return table.concat(charbytes)
|
||||
end
|
||||
|
||||
if escape[char(1)] then
|
||||
-- normal escape
|
||||
str = str .. escape[char(1)]
|
||||
step(2) -- go past backslash and the character
|
||||
elseif char(1) == "u" then
|
||||
-- utf-16
|
||||
step()
|
||||
local uni = char(1) .. char(2) .. char(3) .. char(4)
|
||||
step(5)
|
||||
uni = tonumber(uni, 16)
|
||||
if (uni >= 0 and uni <= 0xd7ff) and not (uni >= 0xe000 and uni <= 0x10ffff) then
|
||||
str = str .. utf(uni)
|
||||
else
|
||||
err("Unicode escape is not a Unicode scalar")
|
||||
end
|
||||
elseif char(1) == "U" then
|
||||
-- utf-32
|
||||
step()
|
||||
local uni = char(1) .. char(2) .. char(3) .. char(4) .. char(5) .. char(6) .. char(7) .. char(8)
|
||||
step(9)
|
||||
uni = tonumber(uni, 16)
|
||||
if (uni >= 0 and uni <= 0xd7ff) and not (uni >= 0xe000 and uni <= 0x10ffff) then
|
||||
str = str .. utf(uni)
|
||||
else
|
||||
err("Unicode escape is not a Unicode scalar")
|
||||
end
|
||||
else
|
||||
err("Invalid escape")
|
||||
end
|
||||
end
|
||||
else
|
||||
-- if we're not in a double-quoted string, just append it to our buffer raw and keep going
|
||||
str = str .. char()
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
return {value = str, type = "string"}
|
||||
end
|
||||
|
||||
local function parseNumber()
|
||||
local num = ""
|
||||
local exp
|
||||
local date = false
|
||||
while(bounds()) do
|
||||
if char():match("[%+%-%.eE_0-9]") then
|
||||
if not exp then
|
||||
if char():lower() == "e" then
|
||||
-- as soon as we reach e or E, start appending to exponent buffer instead of
|
||||
-- number buffer
|
||||
exp = ""
|
||||
elseif char() ~= "_" then
|
||||
num = num .. char()
|
||||
end
|
||||
elseif char():match("[%+%-0-9]") then
|
||||
exp = exp .. char()
|
||||
else
|
||||
err("Invalid exponent")
|
||||
end
|
||||
elseif char():match(ws) or char() == "#" or char():match(nl) or char() == "," or char() == "]" or char() == "}" then
|
||||
break
|
||||
elseif char() == "T" or char() == "Z" then
|
||||
-- parse the date (as a string, since lua has no date object)
|
||||
date = true
|
||||
while(bounds()) do
|
||||
if char() == "," or char() == "]" or char() == "#" or char():match(nl) or char():match(ws) then
|
||||
break
|
||||
end
|
||||
num = num .. char()
|
||||
step()
|
||||
end
|
||||
else
|
||||
err("Invalid number")
|
||||
end
|
||||
step()
|
||||
end
|
||||
|
||||
if date then
|
||||
return {value = num, type = "date"}
|
||||
end
|
||||
|
||||
local float = false
|
||||
if num:match("%.") then float = true end
|
||||
|
||||
exp = exp and tonumber(exp) or 0
|
||||
num = tonumber(num)
|
||||
|
||||
if not float then
|
||||
return {
|
||||
-- lua will automatically convert the result
|
||||
-- of a power operation to a float, so we have
|
||||
-- to convert it back to an int with math.floor
|
||||
value = math.floor(num * 10^exp),
|
||||
type = "int",
|
||||
}
|
||||
end
|
||||
|
||||
return {value = num * 10^exp, type = "float"}
|
||||
end
|
||||
|
||||
local parseArray, getValue
|
||||
|
||||
function parseArray()
|
||||
step() -- skip [
|
||||
skipWhitespace()
|
||||
|
||||
local arrayType
|
||||
local array = {}
|
||||
|
||||
while(bounds()) do
|
||||
if char() == "]" then
|
||||
break
|
||||
elseif char():match(nl) then
|
||||
-- skip
|
||||
step()
|
||||
skipWhitespace()
|
||||
elseif char() == "#" then
|
||||
while(bounds() and not char():match(nl)) do
|
||||
step()
|
||||
end
|
||||
else
|
||||
-- get the next object in the array
|
||||
local v = getValue()
|
||||
if not v then break end
|
||||
|
||||
-- set the type if it hasn't been set before
|
||||
if arrayType == nil then
|
||||
arrayType = v.type
|
||||
elseif arrayType ~= v.type then
|
||||
err("Mixed types in array", true)
|
||||
end
|
||||
|
||||
array = array or {}
|
||||
table.insert(array, v.value)
|
||||
|
||||
if char() == "," then
|
||||
step()
|
||||
end
|
||||
skipWhitespace()
|
||||
end
|
||||
end
|
||||
step()
|
||||
|
||||
return {value = array, type = "array"}
|
||||
end
|
||||
|
||||
local function parseInlineTable()
|
||||
step() -- skip opening brace
|
||||
|
||||
local buffer = ""
|
||||
local quoted = false
|
||||
local tbl = {}
|
||||
|
||||
while bounds() do
|
||||
if char() == "}" then
|
||||
break
|
||||
elseif char() == "'" or char() == '"' then
|
||||
buffer = parseString().value
|
||||
quoted = true
|
||||
elseif char() == "=" then
|
||||
if not quoted then
|
||||
buffer = trim(buffer)
|
||||
end
|
||||
|
||||
step() -- skip =
|
||||
skipWhitespace()
|
||||
|
||||
if char():match(nl) then
|
||||
err("Newline in inline table")
|
||||
end
|
||||
|
||||
local v = getValue().value
|
||||
tbl[buffer] = v
|
||||
|
||||
skipWhitespace()
|
||||
|
||||
if char() == "," then
|
||||
step()
|
||||
elseif char():match(nl) then
|
||||
err("Newline in inline table")
|
||||
end
|
||||
|
||||
quoted = false
|
||||
buffer = ""
|
||||
else
|
||||
buffer = buffer .. char()
|
||||
step()
|
||||
end
|
||||
end
|
||||
step() -- skip closing brace
|
||||
|
||||
return {value = tbl, type = "array"}
|
||||
end
|
||||
|
||||
local function parseBoolean()
|
||||
local v
|
||||
if toml:sub(cursor, cursor + 3) == "true" then
|
||||
step(4)
|
||||
v = {value = true, type = "boolean"}
|
||||
elseif toml:sub(cursor, cursor + 4) == "false" then
|
||||
step(5)
|
||||
v = {value = false, type = "boolean"}
|
||||
else
|
||||
err("Invalid primitive")
|
||||
end
|
||||
|
||||
skipWhitespace()
|
||||
if char() == "#" then
|
||||
while(not char():match(nl)) do
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
||||
|
||||
-- figure out the type and get the next value in the document
|
||||
function getValue()
|
||||
if char() == '"' or char() == "'" then
|
||||
return parseString()
|
||||
elseif char():match("[%+%-0-9]") then
|
||||
return parseNumber()
|
||||
elseif char() == "[" then
|
||||
return parseArray()
|
||||
elseif char() == "{" then
|
||||
return parseInlineTable()
|
||||
else
|
||||
return parseBoolean()
|
||||
end
|
||||
-- date regex (for possible future support):
|
||||
-- %d%d%d%d%-[0-1][0-9]%-[0-3][0-9]T[0-2][0-9]%:[0-6][0-9]%:[0-6][0-9][Z%:%+%-%.0-9]*
|
||||
end
|
||||
|
||||
-- track whether the current key was quoted or not
|
||||
local quotedKey = false
|
||||
|
||||
-- parse the document!
|
||||
while(cursor <= toml:len()) do
|
||||
|
||||
-- skip comments and whitespace
|
||||
if char() == "#" then
|
||||
while(not char():match(nl)) do
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
if char():match(nl) then
|
||||
-- skip
|
||||
end
|
||||
|
||||
if char() == "=" then
|
||||
step()
|
||||
skipWhitespace()
|
||||
|
||||
-- trim key name
|
||||
buffer = trim(buffer)
|
||||
|
||||
if buffer:match("^[0-9]*$") and not quotedKey then
|
||||
buffer = tonumber(buffer)
|
||||
end
|
||||
|
||||
if buffer == "" and not quotedKey then
|
||||
err("Empty key name")
|
||||
end
|
||||
|
||||
local v = getValue()
|
||||
if v then
|
||||
-- if the key already exists in the current object, throw an error
|
||||
if obj[buffer] then
|
||||
err('Cannot redefine key "' .. buffer .. '"', true)
|
||||
end
|
||||
obj[buffer] = v.value
|
||||
end
|
||||
|
||||
-- clear the buffer
|
||||
buffer = ""
|
||||
quotedKey = false
|
||||
|
||||
-- skip whitespace and comments
|
||||
skipWhitespace()
|
||||
if char() == "#" then
|
||||
while(bounds() and not char():match(nl)) do
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
-- if there is anything left on this line after parsing a key and its value,
|
||||
-- throw an error
|
||||
if not char():match(nl) and cursor < toml:len() then
|
||||
err("Invalid primitive")
|
||||
end
|
||||
elseif char() == "[" then
|
||||
buffer = ""
|
||||
step()
|
||||
local tableArray = false
|
||||
|
||||
-- if there are two brackets in a row, it's a table array!
|
||||
if char() == "[" then
|
||||
tableArray = true
|
||||
step()
|
||||
end
|
||||
|
||||
obj = out
|
||||
|
||||
local function processKey(isLast)
|
||||
isLast = isLast or false
|
||||
buffer = trim(buffer)
|
||||
|
||||
if not quotedKey and buffer == "" then
|
||||
err("Empty table name")
|
||||
end
|
||||
|
||||
if isLast and obj[buffer] and not tableArray and #obj[buffer] > 0 then
|
||||
err("Cannot redefine table", true)
|
||||
end
|
||||
|
||||
-- set obj to the appropriate table so we can start
|
||||
-- filling it with values!
|
||||
if tableArray then
|
||||
-- push onto cache
|
||||
if obj[buffer] then
|
||||
obj = obj[buffer]
|
||||
if isLast then
|
||||
table.insert(obj, {})
|
||||
end
|
||||
obj = obj[#obj]
|
||||
else
|
||||
obj[buffer] = {}
|
||||
obj = obj[buffer]
|
||||
if isLast then
|
||||
table.insert(obj, {})
|
||||
obj = obj[1]
|
||||
end
|
||||
end
|
||||
else
|
||||
obj[buffer] = obj[buffer] or {}
|
||||
obj = obj[buffer]
|
||||
end
|
||||
end
|
||||
|
||||
while(bounds()) do
|
||||
if char() == "]" then
|
||||
if tableArray then
|
||||
if char(1) ~= "]" then
|
||||
err("Mismatching brackets")
|
||||
else
|
||||
step() -- skip inside bracket
|
||||
end
|
||||
end
|
||||
step() -- skip outside bracket
|
||||
|
||||
processKey(true)
|
||||
buffer = ""
|
||||
break
|
||||
elseif char() == '"' or char() == "'" then
|
||||
buffer = parseString().value
|
||||
quotedKey = true
|
||||
elseif char() == "." then
|
||||
step() -- skip period
|
||||
processKey()
|
||||
buffer = ""
|
||||
else
|
||||
buffer = buffer .. char()
|
||||
step()
|
||||
end
|
||||
end
|
||||
|
||||
buffer = ""
|
||||
quotedKey = false
|
||||
elseif (char() == '"' or char() == "'") then
|
||||
-- quoted key
|
||||
buffer = parseString().value
|
||||
quotedKey = true
|
||||
end
|
||||
|
||||
buffer = buffer .. (char():match(nl) and "" or char())
|
||||
step()
|
||||
end
|
||||
|
||||
return out
|
||||
end
|
||||
|
||||
TOML.encode = function(tbl)
|
||||
local toml = ""
|
||||
|
||||
local cache = {}
|
||||
|
||||
local function parse(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
if type(v) == "boolean" then
|
||||
toml = toml .. k .. " = " .. tostring(v) .. "\n"
|
||||
elseif type(v) == "number" then
|
||||
toml = toml .. k .. " = " .. tostring(v) .. "\n"
|
||||
elseif type(v) == "string" then
|
||||
local quote = '"'
|
||||
v = v:gsub("\\", "\\\\")
|
||||
|
||||
-- if the string has any line breaks, make it multiline
|
||||
if v:match("^\n(.*)$") then
|
||||
quote = quote:rep(3)
|
||||
v = "\\n" .. v
|
||||
elseif v:match("\n") then
|
||||
quote = quote:rep(3)
|
||||
end
|
||||
|
||||
v = v:gsub("\b", "\\b")
|
||||
v = v:gsub("\t", "\\t")
|
||||
v = v:gsub("\f", "\\f")
|
||||
v = v:gsub("\r", "\\r")
|
||||
v = v:gsub('"', '\\"')
|
||||
v = v:gsub("/", "\\/")
|
||||
toml = toml .. k .. " = " .. quote .. v .. quote .. "\n"
|
||||
elseif type(v) == "table" then
|
||||
local array, arrayTable = true, true
|
||||
local first = {}
|
||||
for kk, vv in pairs(v) do
|
||||
if type(kk) ~= "number" then array = false end
|
||||
if type(vv) ~= "table" then
|
||||
v[kk] = nil
|
||||
first[kk] = vv
|
||||
arrayTable = false
|
||||
end
|
||||
end
|
||||
|
||||
if array then
|
||||
if arrayTable then
|
||||
-- double bracket syntax go!
|
||||
table.insert(cache, k)
|
||||
for kk, vv in pairs(v) do
|
||||
toml = toml .. "[[" .. table.concat(cache, ".") .. "]]\n"
|
||||
for k3, v3 in pairs(vv) do
|
||||
if type(v3) ~= "table" then
|
||||
vv[k3] = nil
|
||||
first[k3] = v3
|
||||
end
|
||||
end
|
||||
parse(first)
|
||||
parse(vv)
|
||||
end
|
||||
table.remove(cache)
|
||||
else
|
||||
-- plain ol boring array
|
||||
toml = toml .. k .. " = [\n"
|
||||
for kk, vv in pairs(first) do
|
||||
toml = toml .. tostring(vv) .. ",\n"
|
||||
end
|
||||
toml = toml .. "]\n"
|
||||
end
|
||||
else
|
||||
-- just a key/value table, folks
|
||||
table.insert(cache, k)
|
||||
toml = toml .. "[" .. table.concat(cache, ".") .. "]\n"
|
||||
parse(first)
|
||||
parse(v)
|
||||
table.remove(cache)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parse(tbl)
|
||||
|
||||
return toml:sub(1, -2)
|
||||
end
|
||||
|
||||
return TOML
|
|
@ -1,158 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local admin = {}
|
||||
|
||||
function admin.isVoiceMuted(clientId)
|
||||
if stats.get(clientId, "voiceMute") then
|
||||
if stats.get(clientId, "voiceMute") - os.time() > 0 then
|
||||
return true
|
||||
else
|
||||
admin.unmuteVoice(clientId)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function admin.isPlayerLocked(clientId)
|
||||
if stats.get(clientId, "playerLock") then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function admin.muteVoice(clientId, length)
|
||||
stats.set(clientId, "voiceMute", length)
|
||||
end
|
||||
|
||||
function admin.unmuteVoice(clientId)
|
||||
stats.set(clientId, "voiceMute", false)
|
||||
end
|
||||
|
||||
function admin.lockTeam(clientId, team)
|
||||
stats.set(clientId, "voiceMute", length)
|
||||
end
|
||||
|
||||
function admin.unlockTeam(clientId)
|
||||
stats.set(clientId, "voiceMute", length)
|
||||
end
|
||||
|
||||
function admin.updatePlayer(clientId)
|
||||
local player = db.getplayer(stats.get(clientId, "playerGUID"))
|
||||
|
||||
if player then
|
||||
local guid = stats.get(clientId, "playerGUID")
|
||||
local ip = stats.get(clientId, "playerIP")
|
||||
|
||||
db.updateplayer(guid, ip)
|
||||
else
|
||||
local guid = stats.get(clientId, "playerGUID")
|
||||
local ip = stats.get(clientId, "playerIP")
|
||||
|
||||
db.addplayer(guid, ip)
|
||||
admin.setPlayerLevel(clientId, et.G_shrubbot_level(clientId), 1)
|
||||
end
|
||||
end
|
||||
|
||||
function admin.updateAlias(clientId)
|
||||
local playerid = db.getplayer(stats.get(clientId, "playerGUID"))["id"]
|
||||
local name = stats.get(clientId, "playerName")
|
||||
local alias = db.getaliasbyname(playerid, name)
|
||||
|
||||
if alias then
|
||||
db.updatealias(alias["id"], os.time())
|
||||
if alias["cleanalias"] == "" then
|
||||
db.updatecleanalias(alias["id"], name)
|
||||
end
|
||||
else
|
||||
db.addalias(playerid, name, os.time())
|
||||
end
|
||||
end
|
||||
|
||||
function admin.setPlayerLevel(clientId, level, adminId)
|
||||
local playerid = db.getplayer(stats.get(clientId, "playerGUID"))["id"]
|
||||
local adminid = db.getplayer(stats.get(adminId, "playerGUID"))["id"]
|
||||
|
||||
db.addsetlevel(playerid, level, adminid, os.time())
|
||||
end
|
||||
|
||||
function admin.onconnect(clientId, firstTime, isBot)
|
||||
-- only increase the counter on first connection (fixes counter increase on
|
||||
-- clientbegin which is also triggered on warmup/maprestart/etc)
|
||||
stats.set(clientId, "namechangeStart", os.time())
|
||||
stats.set(clientId, "namechangePts", 0)
|
||||
|
||||
if firstTime then
|
||||
if stats.get(clientId, "playerGUID") == "NO_GUID" or stats.get(clientId, "playerGUID") == "unknown" then
|
||||
return "\n\nIt appears you do not have a ^7GUID^9/^7etkey^9. In order to play on this server, enable ^7PunkBuster ^9(use ^7\pb_cl_enable^9) ^9and/or create an ^7etkey^9.\n\nMore info: ^7www.etkey.org"
|
||||
end
|
||||
|
||||
if settings.get("db_type") ~= "cfg" then
|
||||
admin.updatePlayer(clientId)
|
||||
admin.updateAlias(clientId)
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onClientConnect", admin.onconnect)
|
||||
|
||||
function stats.oninfochange(clientId)
|
||||
local clientInfo = et.trap_GetUserinfo(clientId)
|
||||
local old = stats.get(clientId, "playerName")
|
||||
local new = et.Info_ValueForKey(clientInfo, "name")
|
||||
|
||||
if new ~= old then
|
||||
if (os.time() - stats.get(clientId, "namechangeStart")) < settings.get("g_renameInterval") and stats.get(clientId, "namechangePts") >= settings.get("g_renameLimit") and not stats.get(clientId, "namechangeForce") then
|
||||
stats.set(clientId, "namechangeForce", true)
|
||||
|
||||
clientInfo = et.Info_SetValueForKey(clientInfo, "name", old)
|
||||
et.trap_SetUserinfo(clientId, clientInfo)
|
||||
et.ClientUserinfoChanged(clientId)
|
||||
|
||||
stats.set(clientId, "namechangeForce", false)
|
||||
|
||||
et.trap_SendServerCommand(clientId, "cp \"Too many name changes in 1 minute.\";")
|
||||
else
|
||||
stats.set(clientId, "playerName", new)
|
||||
|
||||
if (os.time() - stats.get(clientId, "namechangeStart")) > settings.get("g_renameInterval") then
|
||||
stats.set(clientId, "namechangeStart", os.time())
|
||||
stats.get(clientId, "namechangePts", 0)
|
||||
end
|
||||
|
||||
stats.add(clientId, "namechangePts", 1)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay -1 \""..old.." ^7is now known as "..new.."\";")
|
||||
|
||||
if settings.get("db_type") ~= "cfg" then
|
||||
admin.updateAlias(clientId)
|
||||
end
|
||||
|
||||
events.trigger("onClientNameChange", clientId, old, new)
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onClientInfoChange", stats.oninfochange)
|
||||
|
||||
return admin
|
|
@ -1,107 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local timers = require "luascripts.wolfadmin.util.timers"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
local balancer = {}
|
||||
|
||||
local evenerCount = 0
|
||||
|
||||
function balancer.balance(byAdmin, forceBalance)
|
||||
local teams = {
|
||||
[1] = {},
|
||||
[2] = {},
|
||||
[3] = {}
|
||||
}
|
||||
|
||||
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if wolfa_isPlayer(playerId) then
|
||||
local team = tonumber(et.gentity_get(playerId, "sess.sessionTeam"))
|
||||
|
||||
table.insert(teams[team], playerId)
|
||||
end
|
||||
end
|
||||
|
||||
local teamGreater = constants.TEAM_SPECTATORS
|
||||
local teamSmaller = constants.TEAM_SPECTATORS
|
||||
|
||||
local teamsDifference = math.abs(#teams[constants.TEAM_AXIS] - #teams[constants.TEAM_ALLIES])
|
||||
|
||||
if #teams[constants.TEAM_AXIS] > #teams[constants.TEAM_ALLIES] then
|
||||
teamGreater = constants.TEAM_AXIS
|
||||
teamSmaller = constants.TEAM_ALLIES
|
||||
elseif #teams[constants.TEAM_ALLIES] > #teams[constants.TEAM_AXIS] then
|
||||
teamGreater = constants.TEAM_ALLIES
|
||||
teamSmaller = constants.TEAM_AXIS
|
||||
end
|
||||
|
||||
local teamGreaterName = util.getTeamName(teamGreater)
|
||||
local teamSmallerName = util.getTeamName(teamSmaller)
|
||||
|
||||
local teamGreaterColor = util.getTeamColor(teamGreater)
|
||||
local teamSmallerColor = util.getTeamColor(teamSmaller)
|
||||
|
||||
if settings.get("g_evenerMaxDifference") > 0 and teamsDifference >= settings.get("g_evenerMaxDifference") then
|
||||
evenerCount = evenerCount + 1
|
||||
|
||||
if forceBalance or evenerCount >= 2 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "!shuffle;")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cpm \"^devener: ^7THE TEAMS HAVE BEEN ^qSHUFFLED^7!\";")
|
||||
|
||||
evenerCount = 0
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cpm \"^devener: ^1EVEN THE TEAMS ^7OR ^1SHUFFLE\";")
|
||||
end
|
||||
elseif teamsDifference >= settings.get("g_evenerMinDifference") then
|
||||
evenerCount = evenerCount + 1
|
||||
|
||||
if forceBalance or evenerCount >= 3 then
|
||||
for i = 1, (teamsDifference / 2) do
|
||||
local rand = math.random(#teams[teamGreater])
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "!put "..teams[teamGreater][rand].." "..(teamGreater == constants.TEAM_AXIS and constants.TEAM_ALLIES_SC or constants.TEAM_AXIS_SC)..";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^devener: ^9thank you, ^7"..et.gentity_get(teams[teamGreater][rand], "pers.netname")..", ^9for helping to even the teams.\";")
|
||||
|
||||
teams[teamSmaller][rand] = teams[teamGreater][rand]
|
||||
teams[teamGreater][rand] = nil
|
||||
end
|
||||
|
||||
evenerCount = 0
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^devener: ^9teams seem unfair, would someone from "..teamGreaterColor..teamGreaterName.." ^9please switch to "..teamSmallerColor..teamSmallerName.."^9?\";")
|
||||
end
|
||||
else
|
||||
evenerCount = 0
|
||||
|
||||
if byAdmin then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^devener: ^9teams are even.\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function balancer.oninit()
|
||||
if settings.get("g_evenerInterval") > 0 then
|
||||
timers.add(balancer.balance, settings.get("g_evenerInterval") * 1000, 0, false, false)
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", balancer.oninit)
|
||||
|
||||
return balancer
|
|
@ -1,57 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
local rules = {}
|
||||
|
||||
local data = {}
|
||||
|
||||
function rules.get(shortcut)
|
||||
if shortcut then
|
||||
return data[shortcut]
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
function rules.load()
|
||||
local fileName = settings.get("g_fileRules")
|
||||
|
||||
if fileName == "" then
|
||||
return 0
|
||||
end
|
||||
|
||||
local amount, array = files.loadCFG(fileName, "[a-z]+", true)
|
||||
|
||||
if amount == 0 then return 0 end
|
||||
|
||||
for id, rule in ipairs(array["rule"]) do
|
||||
data[rule["shortcut"]] = rule["rule"]
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
function rules.oninit(levelTime, randomSeed, restartMap)
|
||||
rules.load()
|
||||
end
|
||||
events.handle("onGameInit", rules.oninit)
|
||||
|
||||
return rules
|
|
@ -1,52 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local warns = {}
|
||||
|
||||
local data = {}
|
||||
|
||||
function warns.get(clientId, warnId)
|
||||
if warnId then
|
||||
return db.getwarn(warnId)
|
||||
else
|
||||
local playerid = db.getplayer(stats.get(clientId, "playerGUID"))["id"]
|
||||
|
||||
return db.getwarns(playerid)
|
||||
end
|
||||
end
|
||||
|
||||
function warns.add(clientId, reason, adminId, datetime)
|
||||
local playerid = db.getplayer(stats.get(clientId, "playerGUID"))["id"]
|
||||
local adminid = db.getplayer(stats.get(adminId, "playerGUID"))["id"]
|
||||
|
||||
db.addwarn(playerid, reason, adminid, datetime)
|
||||
end
|
||||
|
||||
function warns.remove(clientId, warnId)
|
||||
if not warns.get(clientId, warnId) then
|
||||
return
|
||||
end
|
||||
|
||||
db.removewarn(warnId)
|
||||
end
|
||||
|
||||
return warns
|
|
@ -1,311 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local commands = {}
|
||||
|
||||
-- available shrubflags: lqyFHY
|
||||
local data = {}
|
||||
|
||||
function commands.get(command)
|
||||
if command then
|
||||
return data[command]
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
function commands.register(command, func, flag, help, syntax, hidden)
|
||||
data[command] = {
|
||||
["function"] = func,
|
||||
["flag"] = flag,
|
||||
["help"] = help or "N/A",
|
||||
["syntax"] = "^2!"..command..(syntax and " "..syntax or ""),
|
||||
["hidden"] = hidden
|
||||
}
|
||||
end
|
||||
|
||||
function commands.load()
|
||||
local functionStart = et.trap_Milliseconds()
|
||||
local files = files.ls("commands/")
|
||||
local amount = 0
|
||||
|
||||
for _, file in pairs(files) do
|
||||
if string.match(string.lower(file), "^[a-z]+%.lua$") then
|
||||
require("luascripts/wolfadmin/commands/"..string.sub(file, 1, string.len(file) - 4))
|
||||
|
||||
amount = amount + 1
|
||||
end
|
||||
end
|
||||
|
||||
outputDebug("commands.load(): "..amount.." entries loaded in "..et.trap_Milliseconds() - functionStart.." ms")
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
function commands.log(clientId, command, cmdArguments)
|
||||
local functionStart = et.trap_Milliseconds()
|
||||
local fileDescriptor = files.open(et.trap_Cvar_Get("g_logAdmin"), et.FS_APPEND)
|
||||
|
||||
local logLine
|
||||
local levelTime = wolfa_getLevelTime() / 1000
|
||||
|
||||
local clientGUID = clientId and stats.get(clientId, "playerGUID") or "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
local clientName = clientId and stats.get(clientId, "playerName") or "console"
|
||||
local clientFlags = ""
|
||||
|
||||
local victimId
|
||||
|
||||
-- funny, NoQuarter actually checks EACH command for a victim (so even
|
||||
-- !help [playername] will log a victimname). so why not do the same :D
|
||||
-- todo: do this more nicely, maybe change .register() function
|
||||
if cmdArguments[1] then
|
||||
local cmdClient
|
||||
|
||||
if tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient ~= -1 and et.gentity_get(cmdClient, "pers.netname") then
|
||||
victimId = cmdClient
|
||||
end
|
||||
end
|
||||
|
||||
if victimId then
|
||||
local victimName = stats.get(victimId, "playerName")
|
||||
logLine = string.format("%3i:%02i: %i: %s: %s: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, victimId, victimName, table.concat(cmdArguments, " ", 2))
|
||||
else
|
||||
logLine = string.format("%3i:%02i: %i: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, table.concat(cmdArguments, " "))
|
||||
end
|
||||
|
||||
et.trap_FS_Write(logLine, string.len(logLine), fileDescriptor)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
end
|
||||
|
||||
function commands.oninit()
|
||||
commands.load()
|
||||
end
|
||||
events.handle("onGameInit", commands.oninit)
|
||||
|
||||
function commands.onservercommand(cmdText)
|
||||
-- this if statement definitely sucks.
|
||||
if string.lower(et.trap_Argv(0)) == "csay" and et.trap_Argc() >= 3 then
|
||||
local clientId = tonumber(et.trap_Argv(1))
|
||||
|
||||
if clientId and clientId ~= -1337 then -- -1337 because -1 is a magic number/broadcasted to all clients
|
||||
et.trap_SendServerCommand(clientId, "print \""..et.trap_Argv(2).."\n\";")
|
||||
elseif clientId then
|
||||
et.G_Print(util.removeColors(et.trap_Argv(2)).."\n")
|
||||
end
|
||||
elseif string.lower(et.trap_Argv(0)) == "ccpm" and et.trap_Argc() >= 3 then
|
||||
local clientId = tonumber(et.trap_Argv(1))
|
||||
|
||||
if clientId and clientId ~= -1337 then -- -1337 because -1 is a magic number/broadcasted to all clients
|
||||
et.trap_SendServerCommand(clientId, "cpm \""..et.trap_Argv(2).."\";")
|
||||
elseif clientId then
|
||||
et.G_Print(util.removeColors(et.trap_Argv(2)).."\n")
|
||||
end
|
||||
elseif string.lower(et.trap_Argv(0)) == "cchat" and et.trap_Argc() >= 3 then
|
||||
local clientId = tonumber(et.trap_Argv(1))
|
||||
|
||||
if clientId and clientId ~= -1337 then -- -1337 because -1 is a magic number/broadcasted to all clients
|
||||
et.trap_SendServerCommand(clientId, "chat \""..et.trap_Argv(2).."\";")
|
||||
elseif clientId then
|
||||
et.G_Print(util.removeColors(et.trap_Argv(2)).."\n")
|
||||
end
|
||||
elseif string.lower(et.trap_Argv(0)) == "cannounce" and et.trap_Argc() >= 3 then
|
||||
local clientId = tonumber(et.trap_Argv(1))
|
||||
|
||||
if clientId and clientId ~= -1337 then -- -1337 because -1 is a magic number/broadcasted to all clients
|
||||
et.trap_SendServerCommand(clientId, "announce \""..et.trap_Argv(2).."\";")
|
||||
elseif clientId then
|
||||
et.G_Print(util.removeColors(et.trap_Argv(2)).."\n")
|
||||
end
|
||||
elseif string.lower(et.trap_Argv(0)) == "cmusic" and et.trap_Argc() >= 3 then
|
||||
local clientId = tonumber(et.trap_Argv(1))
|
||||
|
||||
if clientId and clientId ~= -1337 then -- -1337 because -1 is a magic number/broadcasted to all clients
|
||||
et.trap_SendServerCommand(clientId, "mu_play \""..et.trap_Argv(2).."\";")
|
||||
elseif clientId then
|
||||
et.G_Print(util.removeColors(et.trap_Argv(2)).."\n")
|
||||
end
|
||||
elseif et.trap_Argv(0) == "cmdclient" then
|
||||
local cmd = et.trap_Argv(1)
|
||||
local clientId = tonumber(et.trap_Argv(2))
|
||||
|
||||
et.trap_SendServerCommand(clientId, cmd.." \""..et.trap_Argv(3).."\n\";")
|
||||
else
|
||||
-- TODO: merge with commands.onclientcommand
|
||||
local shrubCmd = cmdText
|
||||
local shrubArgumentsOffset = 1
|
||||
local shrubArguments = {}
|
||||
|
||||
if string.find(cmdText, "!") == 1 then
|
||||
shrubCmd = string.lower(string.sub(cmdText, 2, string.len(cmdText)))
|
||||
end
|
||||
|
||||
if data[shrubCmd] and data[shrubCmd]["function"] and data[shrubCmd]["flag"] then
|
||||
for i = 1, et.trap_Argc() - shrubArgumentsOffset do
|
||||
shrubArguments[i] = et.trap_Argv(i + shrubArgumentsOffset - 1)
|
||||
end
|
||||
|
||||
data[shrubCmd]["function"](-1337, shrubArguments)
|
||||
|
||||
if not data[shrubCmd]["hidden"] then
|
||||
commands.log(-1, shrubCmd, shrubArguments)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onServerCommand", commands.onservercommand)
|
||||
|
||||
function commands.onclientcommand(clientId, cmdText)
|
||||
local wolfCmd = string.lower(et.trap_Argv(0))
|
||||
local shrubCmd = nil
|
||||
local shrubArguments = {}
|
||||
local shrubArgumentsOffset = 0
|
||||
|
||||
if wolfCmd == "adminchat" or wolfCmd == "ac" then
|
||||
if et.G_shrubbot_permission(clientId, "~") == 1 then
|
||||
if et.trap_Argc() == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9usage: ^7"..wolfCmd.." [^2message^7]\";")
|
||||
else
|
||||
local message = {}
|
||||
local recipients = {}
|
||||
|
||||
for i = 1, et.trap_Argc() - 1 do
|
||||
message[i] = et.trap_Argv(i)
|
||||
end
|
||||
|
||||
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if wolfa_isPlayer(playerId) and et.G_shrubbot_permission(playerId, "~") == 1 then
|
||||
table.insert(recipients, playerId)
|
||||
end
|
||||
end
|
||||
|
||||
for _, recipient in ipairs(recipients) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..recipient.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> adminchat ("..#recipients.." recipients): ^a"..table.concat(message, " ").."\";")
|
||||
et.trap_SendServerCommand(recipient, "cp \"^jadminchat message from ^7"..et.gentity_get(clientId, "pers.netname"))
|
||||
end
|
||||
|
||||
et.G_LogPrint("adminchat: "..et.gentity_get(clientId, "pers.netname")..": "..table.concat(message, " ").."\n")
|
||||
end
|
||||
end
|
||||
|
||||
return 1
|
||||
elseif wolfCmd == "wolfadmin" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^3This server is running ^7Wolf^1Admin ^7"..wolfa_getVersion().." ^3("..wolfa_getRelease().."^3)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^3Created by ^7Timo '^aTimo^qthy^7' ^7Smit^3. More info on\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \" ^7http://dev.timosmit.com/wolfadmin/\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^3Thanks for using!\";")
|
||||
|
||||
return 1
|
||||
elseif wolfCmd == "team" then
|
||||
if admin.isPlayerLocked(clientId) then
|
||||
local clientTeam = tonumber(et.gentity_get(clientId, "sess.sessionTeam"))
|
||||
local teamName = util.getTeamName(clientTeam)
|
||||
local teamColor = util.getTeamColor(clientTeam)
|
||||
|
||||
et.trap_SendServerCommand(clientId, "cp \"^7You are locked to the "..teamColor..teamName.." ^7team")
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
stats.set(clientId, "currentKillSpree", 0)
|
||||
stats.set(clientId, "currentDeathSpree", 0)
|
||||
stats.set(clientId, "currentReviveSpree", 0)
|
||||
elseif wolfCmd == "callvote" then
|
||||
local voteArguments = {}
|
||||
for i = 2, et.trap_Argc() - 1 do
|
||||
voteArguments[(i - 1)] = et.trap_Argv(i)
|
||||
end
|
||||
|
||||
return events.trigger("onCallvote", clientId, et.trap_Argv(1), voteArguments)
|
||||
elseif wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_teamnl" or wolfCmd == "say_buddy" then
|
||||
if et.gentity_get(clientId, "sess.muted") == 1 then
|
||||
et.trap_SendServerCommand(clientId, "cp \"^1You are muted\"")
|
||||
|
||||
return 1
|
||||
end
|
||||
elseif wolfCmd == "vsay" or wolfCmd == "vsay_team" then
|
||||
if admin.isVoiceMuted(clientId) then
|
||||
et.trap_SendServerCommand(clientId, "cp \"^1You are voicemuted\"")
|
||||
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "!") == 1 then
|
||||
shrubArguments = util.split(et.trap_Argv(1), " ")
|
||||
if #shrubArguments > 1 then
|
||||
shrubCmd = string.sub(shrubArguments[1], 2, string.len(shrubArguments[1]))
|
||||
table.remove(shrubArguments, 1)
|
||||
else
|
||||
shrubCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1)))
|
||||
shrubArgumentsOffset = 2
|
||||
|
||||
for i = 1, et.trap_Argc() - shrubArgumentsOffset do
|
||||
shrubArguments[i] = et.trap_Argv(i + shrubArgumentsOffset - 1)
|
||||
end
|
||||
if shrubArguments[1] == et.trap_Argv(1) then table.remove(shrubArguments, 1) end
|
||||
end
|
||||
elseif string.find(wolfCmd, "!") == 1 then
|
||||
shrubCmd = string.sub(wolfCmd, 2, string.len(wolfCmd))
|
||||
shrubArgumentsOffset = 1
|
||||
|
||||
for i = 1, et.trap_Argc() - shrubArgumentsOffset do
|
||||
shrubArguments[i] = et.trap_Argv(i + shrubArgumentsOffset - 1)
|
||||
end
|
||||
end
|
||||
|
||||
if shrubCmd then
|
||||
shrubCmd = string.lower(shrubCmd)
|
||||
|
||||
if data[shrubCmd] and data[shrubCmd]["function"] and data[shrubCmd]["flag"] then
|
||||
if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and et.G_shrubbot_permission(clientId, "9") == 1) or (wolfCmd == "!"..shrubCmd and et.G_shrubbot_permission(clientId, "3") == 1) then
|
||||
if data[shrubCmd]["flag"] ~= "" and et.G_shrubbot_permission(clientId, data[shrubCmd]["flag"]) == 1 then
|
||||
local isFinished = data[shrubCmd]["function"](clientId, shrubArguments)
|
||||
|
||||
if not data[shrubCmd]["hidden"] then
|
||||
commands.log(clientId, shrubCmd, shrubArguments)
|
||||
end
|
||||
|
||||
if isFinished and "!"..shrubCmd == wolfCmd then -- silent command via console, removes "unknown command" message
|
||||
return 1
|
||||
end
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \""..shrubCmd..": permission denied\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
events.handle("onClientCommand", commands.onclientcommand)
|
||||
|
||||
return commands
|
|
@ -1,59 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local warns = require "luascripts.wolfadmin.admin.warns"
|
||||
|
||||
function commandRemoveWarn(clientId, cmdArguments)
|
||||
if settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9warn history is disabled.\";")
|
||||
|
||||
return true
|
||||
elseif #cmdArguments < 2 or tonumber(cmdArguments[2]) == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn usage: "..commands.get("dewarn")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local playerWarn = warns.get(cmdClient, tonumber(cmdArguments[2]))
|
||||
|
||||
if not playerWarn then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9warn #"..cmdArguments[2].." does not exist for ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9warn #"..cmdArguments[2].." removed for ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
|
||||
warns.remove(cmdClient, tonumber(cmdArguments[2]))
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("dewarn", commandRemoveWarn, "R", "remove a warning for a certain player", "^9[^3name|slot#^9] ^9[^3warn#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end)
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
function commandIncognito(clientId, cmdArguments)
|
||||
local fileName = et.trap_Cvar_Get("g_shrubbot")
|
||||
local functionStart = et.trap_Milliseconds()
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dincognito: ^9an error happened (shrubbot file could not be opened)\";")
|
||||
|
||||
error("failed to open "..fileName.."\n")
|
||||
end
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
for entry, adminName, adminGUID, adminLevel, adminFlags in string.gmatch(fileString, "(%[admin%]\nname%s+=%s+([%a%d%p]+)\nguid%s+=%s+([%u%d]+)\nlevel%s+=%s+([%d]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do
|
||||
-- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags))
|
||||
|
||||
if stats.get(clientId, "playerGUID") == adminGUID then
|
||||
if et.G_shrubbot_permission(clientId, "@") ~= 1 then
|
||||
adminFlags = adminFlags.."+@"
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dincognito: ^9you are now playing incognito.\";")
|
||||
else
|
||||
if string.find(adminFlags, "+@") then
|
||||
adminFlags = string.gsub(adminFlags, "+@", "")
|
||||
elseif string.find(adminFlags, "@") then
|
||||
adminFlags = string.gsub(adminFlags, "@", "")
|
||||
else
|
||||
adminFlags = adminFlags.."-@"
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dincognito: ^9you stopped playing incognito.\";")
|
||||
end
|
||||
|
||||
local adminNameEscaped = string.gsub(adminName, "([%*%+%-%?%^%$%%%[%]%(%)%.])", "%%%1") -- fix for special captures
|
||||
fileString = string.gsub(fileString, "%[admin%]\nname%s+=%s+"..adminNameEscaped.."\nguid%s+=%s+"..adminGUID.."\nlevel%s+=%s+"..adminLevel.."\nflags%s+=%s+([%a%d%p]*)\n\n", "[admin]\nname = "..adminName.."\nguid = "..adminGUID.."\nlevel = "..adminLevel.."\nflags = "..adminFlags.."\n\n")
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_WRITE)
|
||||
|
||||
local writeCount = et.trap_FS_Write(fileString, string.len(fileString), fileDescriptor)
|
||||
|
||||
if not writeCount or writeCount < 1 then
|
||||
error("failed to write "..fileName.."\n")
|
||||
end
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "readconfig;")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("incognito", commandIncognito, "s", "fakes your level to guest (no aka)")
|
|
@ -1,91 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
function commandListLevels(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
local fileName = et.trap_Cvar_Get("g_shrubbot")
|
||||
local functionStart = et.trap_Milliseconds()
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
local levelsCount = 0
|
||||
|
||||
if fileLength == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9an error happened (shrubbot file could not be opened)\";")
|
||||
|
||||
error("failed to open "..fileName.."\n")
|
||||
end
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
for entry, levelNr, levelName, levelFlags in string.gmatch(fileString, "(%[level%]\nlevel%s+=%s+(-?[0-9]+)\nname%s+=%s+([%a%d%p ]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do
|
||||
-- et.G_Print(string.format("%d %s %s\n", levelNr, levelName, levelFlags))
|
||||
|
||||
local numberOfSpaces = 24 - string.len(util.removeColors(levelName))
|
||||
local spaces = string.rep(" ", numberOfSpaces)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^7"..string.format("%5s", levelNr).." ^7"..spaces..levelName.." ^7"..levelFlags.."\";")
|
||||
|
||||
levelsCount = levelsCount + 1
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistlevels: ^9"..levelsCount.." available levels (open console for the full list)\";")
|
||||
|
||||
return true
|
||||
elseif settings.get("db_type") == "cfg" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9level history is disabled.\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local player = db.getplayer(stats.get(cmdClient, "playerGUID"))["id"]
|
||||
local levels = db.getlevels(player)
|
||||
|
||||
if not (levels and #levels > 0) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9there are no recorded levels for player ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dLevels for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for id, level in pairs(levels) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", level["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(level["admin"])["alias"])).." ^f"..os.date("%d/%m/%Y", level["datetime"]).." ^7"..level["level"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistlevels: ^9recorded levels for ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9were printed to the console.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("listlevels", commandListLevels, "s", "display all levels on the server")
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local bots = require "luascripts.wolfadmin.game.bots"
|
||||
|
||||
function commandPutBots(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil and cmdArguments[1] ~= constants.TEAM_AXIS_SC and cmdArguments[1] ~= constants.TEAM_ALLIES_SC and cmdArguments[1] ~= constants.TEAM_SPECTATORS_SC then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dputbots usage: "..commands.get("vmute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local team
|
||||
if cmdArguments[1] == constants.TEAM_AXIS_SC then
|
||||
team = constants.TEAM_AXIS
|
||||
elseif cmdArguments[1] == constants.TEAM_ALLIES_SC then
|
||||
team = constants.TEAM_ALLIES
|
||||
elseif cmdArguments[1] == constants.TEAM_SPECTATORS_SC then
|
||||
team = constants.TEAM_SPECTATORS
|
||||
end
|
||||
|
||||
local teamname = util.getTeamColor(team)..util.getTeamName(team)
|
||||
|
||||
bots.put(team)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dputbots: ^9all bots were set to ^7"..teamname.." ^9team.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("putbots", commandPutBots, "p", "puts all bots into a specific team", "^9[r|b|s]")
|
|
@ -1,32 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local rules = require "luascripts.wolfadmin.admin.rules"
|
||||
local greetings = require "luascripts.wolfadmin.players.greetings"
|
||||
|
||||
function commandReadconfig(clientId, cmdArguments)
|
||||
settings.load()
|
||||
local rulesCount = rules.load()
|
||||
local greetingsCount = greetings.load()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"readconfig: loaded "..greetingsCount.." greetings, "..rulesCount.." rules\";")
|
||||
|
||||
return false
|
||||
end
|
||||
commands.register("readconfig", commandReadconfig, "G", "reloads the shrubbot config file and refreshes user flags", nil, true)
|
|
@ -1,48 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
|
||||
function commandSetLevel(clientId, cmdArguments)
|
||||
if #cmdArguments < 2 then
|
||||
return false
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
return false
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
return false
|
||||
end
|
||||
|
||||
-- plays a promotion sound
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"/sound/vo/general/axis/hq_promogen.wav\";")
|
||||
|
||||
if settings.get("db_type") ~= "cfg" then
|
||||
cmdArguments[2] = tonumber(cmdArguments[2]) or 0
|
||||
|
||||
admin.setPlayerLevel(cmdClient, tonumber(cmdArguments[2]), clientId)
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
commands.register("setlevel", commandSetLevel, "s", "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true)
|
|
@ -1,65 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local warns = require "luascripts.wolfadmin.admin.warns"
|
||||
|
||||
function commandShowWarns(clientId, cmdArguments)
|
||||
if settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns: ^9warn history is disabled.\";")
|
||||
|
||||
return true
|
||||
elseif cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns usage: "..commands.get("showwarns")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local playerWarns = warns.get(cmdClient)
|
||||
|
||||
if not (playerWarns and #playerWarns > 0) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns: ^9there are no warnings for player ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dWarns for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, warn in pairs(playerWarns) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", warn["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getlastalias(warn["admin"])["alias"])).." ^f"..os.date("%d/%m/%Y", warn["datetime"]).." ^7"..warn["reason"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dshowwarns: ^9warnings for ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9were printed to the console.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("showwarns", commandShowWarns, "R", "display warnings for a specific player", "^9[^3name|slot#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end)
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local sprees = require "luascripts.wolfadmin.game.sprees"
|
||||
|
||||
function commandShowSprees(clientId, cmdArguments)
|
||||
local records = sprees.get()
|
||||
|
||||
if not (records["ksrecord"] or records["dsrecord"] or records["rsrecord"]) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsprees: ^9there are no records for this map yet.\"")
|
||||
else
|
||||
if records["ksrecord"] and records["ksrecord"] > 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest kill spree (^7"..records["ksrecord"].."^9) by ^7"..records["ksname"].."^9.\";")
|
||||
end
|
||||
if records["dsrecord"] and records["dsrecord"] > 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest death spree (^7"..records["dsrecord"].."^9) by ^7"..records["dsname"].."^9.\";")
|
||||
end
|
||||
if records["rsrecord"] and records["rsrecord"] > 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest revive spree (^7"..records["rsrecord"].."^9) by ^7"..records["rsname"].."^9.\";")
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("sprees", commandShowSprees, "I", "display the current spree records")
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
|
||||
function commandShowStats(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.get("stats")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local stats = {
|
||||
["name"] = et.gentity_get(cmdClient, "pers.netname"),
|
||||
["cleanname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^[^^]", ""),
|
||||
["codedsname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"),
|
||||
["slot"] = cmdClient,
|
||||
["team"] = et.gentity_get(cmdClient, "sess.sessionTeam"),
|
||||
["class"] = et.gentity_get(cmdClient, "sess.playerType"),
|
||||
["health"] = et.gentity_get(cmdClient, "ps.stats"), -- -10 = ungibbed, -30 = gibbed
|
||||
["kills"] = et.gentity_get(cmdClient, "sess.kills"),
|
||||
["teamkills"] = et.gentity_get(cmdClient, "sess.team_kills"),
|
||||
["totalkills"] = et.gentity_get(cmdClient, "sess.kills") + et.gentity_get(cmdClient, "sess.team_kills"),
|
||||
["damage"] = et.gentity_get(cmdClient, "sess.damage_given"),
|
||||
["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"),
|
||||
["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage"),
|
||||
-- ["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_received"), -- ETPro only
|
||||
["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage"),
|
||||
["deaths"] = et.gentity_get(cmdClient, "sess.deaths"),
|
||||
["suicides"] = et.gentity_get(cmdClient, "sess.suicides")
|
||||
}
|
||||
|
||||
if stats["totalkills"] == 0 then stats["totalkills"] = 1 end
|
||||
if stats["totaldamage"] == 0 then stats["totaldamage"] = 1 end
|
||||
|
||||
--[[ for key, value in pairs(stats) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..string.format("%-15s", key..":").." ^7"..value.."\";")
|
||||
end ]]
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dStatistics for ^7"..stats["name"].."^d:\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..stats["cleanname"].." ("..stats["codedsname"]..")\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..stats["slot"]..(stats["slot"] < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dTeam: ^2"..util.getTeamName(stats["team"]).."\";")
|
||||
|
||||
if stats["team"] ~= et.TEAM_SPECTATORS then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dClass: ^2"..util.getClassName(stats["class"]).."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHealth: ^2"..(stats["health"] < 0 and "dead" or stats["health"]).."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dKills: ^2"..string.format("%-8s", stats["kills"]).." ^dTeam kills: ^2"..stats["teamkills"].." ^9("..string.format("%0.2f", (stats["teamkills"] / (stats["totalkills"] or 1) * 100)).." percent)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam damage: ^2"..stats["teamdamage"].." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSuicides: ^2"..stats["suicides"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dK/D: ^2"..string.format("%0.2f", (stats["kills"] / ((stats["deaths"] > 0) and stats["deaths"] or 1))).."\";")
|
||||
|
||||
-- NQ 1.3.0 and higher
|
||||
--[[ for key, value in ipairs(stats["weapstats"]) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..stats["weapstats"].."\";")
|
||||
end ]]
|
||||
|
||||
-- NQ 1.3.0 and higher
|
||||
--[[ local weapstats = et.gentity_get(cmdClient, "sess.aWeaponStats", WP_THOMPSON)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..weapstats.."\";") ]]
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dstats: ^9stats for ^7"..stats["name"].." ^9were printed to the console.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("stats", commandShowStats, "I", "display the statistics for a specific player", "^9[^3name|slot#^9]")
|
|
@ -1,78 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
|
||||
function commandVoiceMute(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.get("vmute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local vmuteTime, vmuteReason = 600, "muted by admin"
|
||||
|
||||
if cmdArguments[2] and util.getTimeFromString(cmdArguments[2]) and cmdArguments[3] then
|
||||
vmuteTime = util.getTimeFromString(cmdArguments[2])
|
||||
vmuteReason = table.concat(cmdArguments, " ", 3)
|
||||
elseif cmdArguments[2] and util.getTimeFromString(cmdArguments[2]) then
|
||||
vmuteTime = util.getTimeFromString(cmdArguments[2])
|
||||
elseif cmdArguments[2] then
|
||||
vmuteReason = table.concat(cmdArguments, " ", 2)
|
||||
elseif et.G_shrubbot_permission(clientId, "8") ~= 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.get("vmute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if admin.isVoiceMuted(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is already muted.\";")
|
||||
|
||||
return true
|
||||
elseif et.G_shrubbot_permission(cmdClient, "!") == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif et.G_shrubbot_level(cmdClient) > et.G_shrubbot_level(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dvmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been voicemuted for "..vmuteTime.." seconds\";")
|
||||
|
||||
admin.muteVoice(cmdClient, os.time() + vmuteTime)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("vmute", commandVoiceMute, "m", "voicemutes a player", "^9[^3name|slot#^9]")
|
|
@ -1,43 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local warns = require "luascripts.wolfadmin.admin.warns"
|
||||
|
||||
function commandAddWarn(clientId, cmdArguments)
|
||||
if settings.get("g_warnHistory") == 0 then
|
||||
return false
|
||||
elseif #cmdArguments < 2 then
|
||||
return false
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
return false
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
return false
|
||||
end
|
||||
|
||||
warns.add(cmdClient, table.concat(cmdArguments, " ", 2), clientId, os.time())
|
||||
|
||||
return false
|
||||
end
|
||||
commands.register("warn", commandAddWarn, "R", "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true)
|
|
@ -1,201 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local cfg = {}
|
||||
|
||||
local maps = {}
|
||||
local records = {}
|
||||
|
||||
function cfg.addmap(mapname, lastplayed)
|
||||
table.insert(records, {
|
||||
["map"] = mapname,
|
||||
})
|
||||
end
|
||||
|
||||
function cfg.updatemap(mapid, lastplayed)
|
||||
end
|
||||
|
||||
function cfg.getmap(mapname)
|
||||
for id, record in ipairs(records) do
|
||||
if record["map"] == mapname then
|
||||
return {["id"] = id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cfg.addrecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cfg.updaterecord(mapid, recorddate, recordtype, record, playerid)
|
||||
end
|
||||
|
||||
function cfg.updaterecord(mapid, recorddate, recordtype, record, playerid)
|
||||
local typestr = ""
|
||||
if recordtype == constants.RECORD_KILL then
|
||||
typestr = "ks"
|
||||
elseif recordtype == constants.RECORD_DEATH then
|
||||
typestr = "ds"
|
||||
elseif recordtype == constants.RECORD_REVIVE then
|
||||
typestr = "rs"
|
||||
end
|
||||
|
||||
records[mapid][typestr.."record"] = record
|
||||
records[mapid][typestr.."name"] = playerid
|
||||
end
|
||||
|
||||
function cfg.removerecords(mapid)
|
||||
records[mapid] = {
|
||||
["map"] = records[mapid]["map"],
|
||||
}
|
||||
end
|
||||
|
||||
function cfg.getrecords(mapid)
|
||||
return records[mapid]
|
||||
end
|
||||
|
||||
function cfg.getrecordscount(mapid)
|
||||
return #records
|
||||
end
|
||||
|
||||
function cfg.getrecord(mapid, recordtype)
|
||||
local row = records[mapid]
|
||||
|
||||
if row then
|
||||
local record, typestr = {}, ""
|
||||
|
||||
if recordtype == constants.RECORD_KILL then
|
||||
typestr = "ks"
|
||||
elseif recordtype == constants.RECORD_DEATH then
|
||||
typestr = "ds"
|
||||
elseif recordtype == constants.RECORD_REVIVE then
|
||||
typestr = "rs"
|
||||
end
|
||||
|
||||
if not record[typestr.."player"] then return end
|
||||
|
||||
record[typestr.."player"] = tonumber(row["player"])
|
||||
record[typestr.."record"] = tonumber(row["record"])
|
||||
|
||||
return record
|
||||
end
|
||||
end
|
||||
|
||||
function cfg.addplayer(guid, ip)
|
||||
end
|
||||
|
||||
function cfg.updateplayer(guid, ip)
|
||||
end
|
||||
|
||||
function cfg.getplayerid(clientid)
|
||||
if type(clientid) == "number" then
|
||||
return stats.get(clientid, "playerName")
|
||||
end
|
||||
|
||||
return clientid
|
||||
end
|
||||
|
||||
function mysql.isplayerbot(clientid)
|
||||
return string.match(stats.get(clientid, "playerGUID"), 'OMNIBOT%d%d%d+')
|
||||
end
|
||||
|
||||
function cfg.getplayer(guid)
|
||||
end
|
||||
|
||||
function cfg.addalias(playerid, alias, lastused)
|
||||
end
|
||||
|
||||
function cfg.updatealias(aliasid, lastused)
|
||||
end
|
||||
|
||||
function cfg.getaliases(playerid)
|
||||
end
|
||||
|
||||
function cfg.getaliasbyid(aliasid)
|
||||
end
|
||||
|
||||
function cfg.getaliasbyname(playerid, aliasname)
|
||||
end
|
||||
|
||||
function cfg.getlastalias(playerid)
|
||||
return {["alias"] = playerid}
|
||||
end
|
||||
|
||||
function cfg.addsetlevel(playerid, level, adminid, datetime)
|
||||
end
|
||||
|
||||
function cfg.getlevels(playerid)
|
||||
end
|
||||
|
||||
function cfg.addwarn(playerid, reason, adminid, datetime)
|
||||
end
|
||||
|
||||
function cfg.removewarn(warnid)
|
||||
end
|
||||
|
||||
function cfg.getwarns(playerid)
|
||||
end
|
||||
|
||||
function cfg.getwarn(warnid)
|
||||
end
|
||||
|
||||
function cfg.isconnected()
|
||||
end
|
||||
|
||||
function cfg.start()
|
||||
local fileName = settings.get("g_fileSprees")
|
||||
|
||||
if fileName == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local amount, array = files.loadCFG(fileName, "record", true)
|
||||
records = array["record"] or {}
|
||||
|
||||
for id, record in ipairs(records) do
|
||||
record["ksrecord"] = tonumber(record["ksrecord"])
|
||||
record["dsrecord"] = tonumber(record["dsrecord"])
|
||||
record["rsrecord"] = tonumber(record["rsrecord"])
|
||||
end
|
||||
end
|
||||
|
||||
function cfg.close(doSave)
|
||||
-- in case of a map restart for example
|
||||
if not doSave then return end
|
||||
|
||||
local fileName = settings.get("g_fileSprees")
|
||||
|
||||
if fileName == "" then
|
||||
return true
|
||||
end
|
||||
|
||||
local array = {["record"] = {}}
|
||||
|
||||
-- add back the indices we removed
|
||||
for _, record in ipairs(records) do
|
||||
table.insert(array["record"], record)
|
||||
end
|
||||
|
||||
files.save(fileName, array)
|
||||
end
|
||||
|
||||
return cfg
|
|
@ -1,259 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
require "luasql.mysql"
|
||||
|
||||
local mysql = {}
|
||||
|
||||
local env = assert(luasql.mysql())
|
||||
local con = nil
|
||||
local cur = nil
|
||||
|
||||
function mysql.addmap(mapname, lastplayed)
|
||||
cur = assert(con:execute("INSERT INTO `maps` (`name`, `lastplayed`) VALUES ('"..util.escape(mapname).."', "..tonumber(lastplayed)..")"))
|
||||
end
|
||||
|
||||
function mysql.updatemap(mapid, lastplayed)
|
||||
cur = assert(con:execute("UPDATE `maps` SET `lastplayed`="..tonumber(lastplayed).." WHERE `id`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function mysql.getmap(mapname)
|
||||
cur = assert(con:execute("SELECT * FROM `maps` WHERE `name`='"..util.escape(mapname).."'"))
|
||||
|
||||
local map = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return map
|
||||
end
|
||||
|
||||
function mysql.addrecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("INSERT INTO `records` (`mapid`, `date`, `type`, `record`, `player`) VALUES ("..tonumber(mapid)..", "..tonumber(recorddate)..", "..tonumber(recordtype)..", "..tonumber(record)..", "..tonumber(playerid)..")"))
|
||||
end
|
||||
|
||||
function mysql.updaterecord(mapid, recorddate, recordtype, record, playerid)
|
||||
cur = assert(con:execute("UPDATE `records` SET `date`="..tonumber(recorddate)..", `record`="..tonumber(record)..", `player`="..tonumber(playerid).." WHERE `mapid`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
end
|
||||
|
||||
function mysql.removerecords(mapid)
|
||||
cur = assert(con:execute("DELETE FROM `records` WHERE `mapid`="..tonumber(mapid)..""))
|
||||
end
|
||||
|
||||
function mysql.getrecords(mapid)
|
||||
cur = assert(con:execute("SELECT * FROM `records` WHERE `mapid`="..tonumber(mapid)..""))
|
||||
local numrows = cur:numrows()
|
||||
local records = {}
|
||||
|
||||
for i = 1, numrows do
|
||||
local record = cur:fetch({}, "a")
|
||||
local typestr = ""
|
||||
|
||||
if tonumber(record["type"]) == constants.RECORD_KILL then
|
||||
typestr = "ks"
|
||||
elseif tonumber(record["type"]) == constants.RECORD_DEATH then
|
||||
typestr = "ds"
|
||||
elseif tonumber(record["type"]) == constants.RECORD_REVIVE then
|
||||
typestr = "rs"
|
||||
end
|
||||
|
||||
records[typestr.."player"] = tonumber(record["player"])
|
||||
records[typestr.."record"] = tonumber(record["record"])
|
||||
end
|
||||
|
||||
cur:close()
|
||||
|
||||
return records
|
||||
end
|
||||
|
||||
function mysql.getrecordscount(mapid)
|
||||
cur = assert(con:execute("SELECT COUNT(*) AS `count` FROM `records` WHERE `mapid`="..tonumber(mapid)..""))
|
||||
|
||||
local count = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return count["count"]
|
||||
end
|
||||
|
||||
function mysql.getrecord(mapid, recordtype)
|
||||
cur = assert(con:execute("SELECT * FROM `records` WHERE `mapid`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
|
||||
|
||||
local row = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
if row then
|
||||
local record, typestr = {}, ""
|
||||
|
||||
if tonumber(row["type"]) == constants.RECORD_KILL then
|
||||
typestr = "ks"
|
||||
elseif tonumber(row["type"]) == constants.RECORD_DEATH then
|
||||
typestr = "ds"
|
||||
elseif tonumber(row["type"]) == constants.RECORD_REVIVE then
|
||||
typestr = "rs"
|
||||
end
|
||||
|
||||
record[typestr.."player"] = tonumber(row["player"])
|
||||
record[typestr.."record"] = tonumber(row["record"])
|
||||
|
||||
return record
|
||||
end
|
||||
end
|
||||
|
||||
function mysql.addplayer(guid, ip)
|
||||
cur = assert(con:execute("INSERT INTO `players` (`guid`, `ip`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."')"))
|
||||
end
|
||||
|
||||
function mysql.updateplayer(guid, ip)
|
||||
cur = assert(con:execute("UPDATE `players` SET `ip`='"..util.escape(ip).."' WHERE `guid`='"..util.escape(guid).."'"))
|
||||
end
|
||||
|
||||
function mysql.getplayerid(clientid)
|
||||
return mysql.getplayer(stats.get(clientid, "playerGUID"))["id"]
|
||||
end
|
||||
|
||||
function mysql.isplayerbot(clientid)
|
||||
return mysql.getplayer(stats.get(clientid, "playerGUID"))["bot"] == 1
|
||||
end
|
||||
|
||||
function mysql.getplayer(guid)
|
||||
cur = assert(con:execute("SELECT * FROM `players` WHERE `guid`='"..util.escape(guid).."'"))
|
||||
|
||||
local player = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return player
|
||||
end
|
||||
|
||||
function mysql.addalias(playerid, alias, lastused)
|
||||
cur = assert(con:execute("INSERT INTO `aliases` (`player`, `alias`, `cleanalias`, `lastused`, `used`) VALUES ("..tonumber(playerid)..", '"..util.escape(alias).."', '"..util.escape(util.removeColors(alias)).."', "..tonumber(lastused)..", 1)"))
|
||||
end
|
||||
|
||||
function mysql.updatecleanalias(aliasid, alias)
|
||||
cur = assert(con:execute("UPDATE `aliases` SET `cleanalias`='"..util.escape(util.removeColors(alias)).."' WHERE `id`='"..util.escape(aliasid).."'"))
|
||||
end
|
||||
|
||||
function mysql.updatealias(aliasid, lastused)
|
||||
cur = assert(con:execute("UPDATE `aliases` SET `lastused`="..tonumber(lastused)..", `used`=`used`+1 WHERE `id`='"..util.escape(aliasid).."'"))
|
||||
end
|
||||
|
||||
function mysql.getaliases(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `aliases` WHERE `player`="..tonumber(playerid).." ORDER BY `used` DESC"))
|
||||
local numrows = cur:numrows()
|
||||
local aliases = {}
|
||||
|
||||
for i = 1, numrows do
|
||||
aliases[i] = cur:fetch({}, "a")
|
||||
end
|
||||
|
||||
cur:close()
|
||||
|
||||
return aliases
|
||||
end
|
||||
|
||||
function mysql.getaliasbyid(aliasid)
|
||||
cur = assert(con:execute("SELECT * FROM `aliases` WHERE `id`="..tonumber(aliasid)..""))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return alias
|
||||
end
|
||||
|
||||
function mysql.getaliasbyname(playerid, aliasname)
|
||||
cur = assert(con:execute("SELECT * FROM `aliases` WHERE `player`="..tonumber(playerid).." AND `alias`='"..util.escape(aliasname).."'"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return alias
|
||||
end
|
||||
|
||||
function mysql.getlastalias(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `aliases` WHERE `player`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
||||
|
||||
local alias = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return alias
|
||||
end
|
||||
|
||||
function mysql.addsetlevel(playerid, level, adminid, datetime)
|
||||
cur = assert(con:execute("INSERT INTO `levels` (`player`, `level`, `admin`, `datetime`) VALUES ("..tonumber(playerid)..", "..tonumber(level)..", "..tonumber(adminid)..", "..tonumber(datetime)..")"))
|
||||
end
|
||||
|
||||
function mysql.getlevels(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `levels` WHERE `player`="..tonumber(playerid)..""))
|
||||
local numrows = cur:numrows()
|
||||
local levels = {}
|
||||
|
||||
for i = 1, numrows do
|
||||
levels[i] = cur:fetch({}, "a")
|
||||
end
|
||||
|
||||
cur:close()
|
||||
|
||||
return levels
|
||||
end
|
||||
|
||||
function mysql.addwarn(playerid, reason, adminid, datetime)
|
||||
cur = assert(con:execute("INSERT INTO `warns` (`player`, `reason`, `admin`, `datetime`) VALUES ("..tonumber(playerid)..", '"..util.escape(reason).."', "..tonumber(adminid)..", "..tonumber(datetime)..")"))
|
||||
end
|
||||
|
||||
function mysql.removewarn(warnid)
|
||||
cur = assert(con:execute("DELETE FROM `warns` WHERE `id`="..tonumber(warnid)..""))
|
||||
end
|
||||
|
||||
function mysql.getwarns(playerid)
|
||||
cur = assert(con:execute("SELECT * FROM `warns` WHERE `player`="..tonumber(playerid)..""))
|
||||
local numrows = cur:numrows()
|
||||
local warns = {}
|
||||
|
||||
for i = 1, numrows do
|
||||
warns[i] = cur:fetch({}, "a")
|
||||
end
|
||||
|
||||
cur:close()
|
||||
|
||||
return warns
|
||||
end
|
||||
|
||||
function mysql.getwarn(warnid)
|
||||
cur = assert(con:execute("SELECT * FROM `warns` WHERE `id`="..tonumber(warnid)..""))
|
||||
|
||||
local warn = cur:fetch({}, "a")
|
||||
cur:close()
|
||||
|
||||
return warn
|
||||
end
|
||||
|
||||
function mysql.isconnected()
|
||||
return (con ~= nil)
|
||||
end
|
||||
|
||||
function mysql.start()
|
||||
con = assert(env:connect(settings.get("db_database"), settings.get("db_username"), settings.get("db_password"), settings.get("db_hostname"), settings.get("db_port")))
|
||||
end
|
||||
|
||||
function mysql.close(doSave)
|
||||
end
|
||||
|
||||
return mysql
|
|
@ -1,209 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local sprees = {}
|
||||
|
||||
local revivespreeMessages = {
|
||||
[3] = {
|
||||
["msg"] = "^dis on a ^2revive spree^d!",
|
||||
["sound"] = "",
|
||||
},
|
||||
[5] = {
|
||||
["msg"] = "^dis a ^2revive magnet^d!",
|
||||
["sound"] = "",
|
||||
},
|
||||
[10] = {
|
||||
["msg"] = "^dis a ^2syringe maniac^d!",
|
||||
["sound"] = "",
|
||||
},
|
||||
[15] = {
|
||||
["msg"] = "^dis the new ^2Dr. Frankenstein^d!",
|
||||
["sound"] = "",
|
||||
},
|
||||
}
|
||||
|
||||
local currentRecords -- cached version
|
||||
local currentMapId
|
||||
|
||||
function sprees.get()
|
||||
local records = currentRecords
|
||||
|
||||
if records["ksrecord"] and records["ksrecord"] > 0 then
|
||||
records["ksname"] = db.getlastalias(records["ksplayer"])["alias"]
|
||||
end
|
||||
if records["dsrecord"] and records["dsrecord"] > 0 then
|
||||
records["dsname"] = db.getlastalias(records["dsplayer"])["alias"]
|
||||
end
|
||||
if records["rsrecord"] and records["rsrecord"] > 0 then
|
||||
records["rsname"] = db.getlastalias(records["rsplayer"])["alias"]
|
||||
end
|
||||
|
||||
return records
|
||||
end
|
||||
|
||||
function sprees.reset()
|
||||
db.removerecords(currentMapId)
|
||||
|
||||
currentRecords = db.getrecords(currentMapId)
|
||||
end
|
||||
|
||||
function sprees.load()
|
||||
local map = db.getmap(game.getMap())
|
||||
|
||||
if map then
|
||||
currentMapId = map["id"]
|
||||
db.updatemap(currentMapId, os.time())
|
||||
else
|
||||
db.addmap(game.getMap(), os.time())
|
||||
currentMapId = db.getmap(game.getMap())["id"]
|
||||
end
|
||||
|
||||
currentRecords = db.getrecords(currentMapId)
|
||||
|
||||
return db.getrecordscount(currentMapId)
|
||||
end
|
||||
|
||||
function sprees.oninit(levelTime, randomSeed, restartMap)
|
||||
if (settings.get("db_type") == "cfg" and settings.get("g_fileSprees") ~= "") or (settings.get("db_type") ~= "cfg" and settings.get("g_spreeRecords") ~= 0) then
|
||||
sprees.load()
|
||||
|
||||
events.handle("onGameStateChange", sprees.ongamestatechange)
|
||||
events.handle("onPlayerDeath", sprees.ondeath)
|
||||
events.handle("onPlayerRevive", sprees.onrevive)
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", sprees.oninit)
|
||||
|
||||
function sprees.onconnect(clientId, firstTime, isBot)
|
||||
stats.set(clientId, "currentKillSpree", 0)
|
||||
stats.set(clientId, "longestKillSpree", 0)
|
||||
stats.set(clientId, "currentDeathSpree", 0)
|
||||
stats.set(clientId, "longestDeathSpree", 0)
|
||||
stats.set(clientId, "currentReviveSpree", 0)
|
||||
stats.set(clientId, "longestReviveSpree", 0)
|
||||
end
|
||||
events.handle("onClientConnect", sprees.onconnect)
|
||||
|
||||
function sprees.ongamestatechange(gameState)
|
||||
if gameState == 3 then
|
||||
if currentRecords["ksrecord"] and currentRecords["ksrecord"] > 0 then
|
||||
if db.getrecord(currentMapId, constants.RECORD_KILL) then
|
||||
db.updaterecord(currentMapId, os.time(), constants.RECORD_KILL, currentRecords["ksrecord"], currentRecords["ksplayer"])
|
||||
else
|
||||
db.addrecord(currentMapId, os.time(), constants.RECORD_KILL, currentRecords["ksrecord"], currentRecords["ksplayer"])
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest kill spree (^7"..currentRecords["ksrecord"].."^9) by ^7"..db.getlastalias(currentRecords["ksplayer"])["alias"].."^9.\";")
|
||||
end
|
||||
if currentRecords["dsrecord"] and currentRecords["dsrecord"] > 0 then
|
||||
if db.getrecord(currentMapId, constants.RECORD_DEATH) then
|
||||
db.updaterecord(currentMapId, os.time(), constants.RECORD_DEATH, currentRecords["dsrecord"], currentRecords["dsplayer"])
|
||||
else
|
||||
db.addrecord(currentMapId, os.time(), constants.RECORD_DEATH, currentRecords["dsrecord"], currentRecords["dsplayer"])
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest death spree (^7"..currentRecords["dsrecord"].."^9) by ^7"..db.getlastalias(currentRecords["dsplayer"])["alias"].."^9.\";")
|
||||
end
|
||||
if currentRecords["rsrecord"] and currentRecords["rsrecord"] > 0 then
|
||||
if db.getrecord(currentMapId, constants.RECORD_REVIVE) then
|
||||
db.updaterecord(currentMapId, os.time(), constants.RECORD_REVIVE, currentRecords["rsrecord"], currentRecords["rsplayer"])
|
||||
else
|
||||
db.addrecord(currentMapId, os.time(), constants.RECORD_REVIVE, currentRecords["rsrecord"], currentRecords["rsplayer"])
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dsprees: ^9longest revive spree (^7"..currentRecords["rsrecord"].."^9) by ^7"..db.getlastalias(currentRecords["rsplayer"])["alias"].."^9.\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sprees.ondeath(victimId, killerId, mod)
|
||||
if killerId == 1022 then -- killed by map
|
||||
stats.set(victimId, "currentKillSpree", 0)
|
||||
stats.add(victimId, "currentDeathSpree", 1)
|
||||
stats.set(victimId, "currentReviveSpree", 0)
|
||||
|
||||
stats.set(victimId, "longestDeathSpree", stats.get(victimId, "currentDeathSpree") > stats.get(victimId, "longestDeathSpree") and stats.get(victimId, "currentDeathSpree") or stats.get(victimId, "longestDeathSpree"))
|
||||
elseif victimId == killerId then -- suicides
|
||||
-- happens when a bot disconnects, it selfkills before leaving, thus emptying the
|
||||
-- player data table, resulting in errors. I'm sorry for your spree records, bots.
|
||||
if not wolfa_isPlayer(victimId) then return end
|
||||
|
||||
stats.set(victimId, "currentKillSpree", 0)
|
||||
stats.add(victimId, "currentDeathSpree", 1)
|
||||
stats.set(victimId, "currentReviveSpree", 0)
|
||||
|
||||
stats.set(victimId, "longestDeathSpree", stats.get(victimId, "currentDeathSpree") > stats.get(victimId, "longestDeathSpree") and stats.get(victimId, "currentDeathSpree") or stats.get(victimId, "longestDeathSpree"))
|
||||
|
||||
if (settings.get("g_botRecords") == 1 or not db.isplayerbot(victimId)) and (not currentRecords["dsrecord"] or stats.get(victimId, "longestDeathSpree") > currentRecords["dsrecord"]) then
|
||||
currentRecords["dsplayer"] = db.getplayerid(victimId)
|
||||
currentRecords["dsrecord"] = stats.get(victimId, "longestDeathSpree")
|
||||
end
|
||||
else -- regular kills
|
||||
if et.gentity_get(victimId, "sess.sessionTeam") == et.gentity_get(killerId, "sess.sessionTeam") then
|
||||
-- teamkill handling
|
||||
else
|
||||
stats.add(killerId, "currentKillSpree", 1)
|
||||
stats.set(killerId, "currentDeathSpree", 0)
|
||||
|
||||
stats.set(killerId, "longestKillSpree", stats.get(killerId, "currentKillSpree") > stats.get(killerId, "longestKillSpree") and stats.get(killerId, "currentKillSpree") or stats.get(killerId, "longestKillSpree"))
|
||||
|
||||
if (settings.get("g_botRecords") == 1 or not db.isplayerbot(killerId)) and (not currentRecords["ksrecord"] or stats.get(killerId, "longestKillSpree") > currentRecords["ksrecord"]) then
|
||||
currentRecords["ksplayer"] = db.getplayerid(killerId)
|
||||
currentRecords["ksrecord"] = stats.get(killerId, "longestKillSpree")
|
||||
end
|
||||
|
||||
-- happens when a bot disconnects, it selfkills before leaving, thus emptying the
|
||||
-- player data table, resulting in errors. I'm sorry for your spree records, bots.
|
||||
if not wolfa_isPlayer(victimId) then return end
|
||||
|
||||
stats.set(victimId, "currentKillSpree", 0)
|
||||
stats.add(victimId, "currentDeathSpree", 1)
|
||||
stats.set(victimId, "currentReviveSpree", 0)
|
||||
|
||||
stats.set(victimId, "longestDeathSpree", stats.get(victimId, "currentDeathSpree") > stats.get(victimId, "longestDeathSpree") and stats.get(victimId, "currentDeathSpree") or stats.get(victimId, "longestDeathSpree"))
|
||||
|
||||
if (settings.get("g_botRecords") == 1 or not db.isplayerbot(victimId)) and (not currentRecords["dsrecord"] or stats.get(victimId, "longestDeathSpree") > currentRecords["dsrecord"]) then
|
||||
currentRecords["dsplayer"] = db.getplayerid(victimId)
|
||||
currentRecords["dsrecord"] = stats.get(victimId, "longestDeathSpree")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sprees.onrevive(clientMedic, clientVictim)
|
||||
stats.add(clientMedic, "currentReviveSpree", 1)
|
||||
stats.set(clientMedic, "longestReviveSpree", stats.get(clientMedic, "currentReviveSpree") > stats.get(clientMedic, "longestReviveSpree") and stats.get(clientMedic, "currentReviveSpree") or stats.get(clientMedic, "longestReviveSpree"))
|
||||
|
||||
if revivespreeMessages[stats.get(clientMedic, "currentReviveSpree")] then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^1REVIVE SPREE! ^*"..stats.get(clientMedic, "playerName").." ^*"..revivespreeMessages[stats.get(clientMedic, "currentReviveSpree")]["msg"].." ^d(^3"..stats.get(clientMedic, "currentReviveSpree").." ^drevives in a row!)\";")
|
||||
end
|
||||
|
||||
if (settings.get("g_botRecords") == 1 or not db.isplayerbot(clientMedic)) and (not currentRecords["rsrecord"] or stats.get(clientMedic, "longestReviveSpree") > currentRecords["rsrecord"]) then
|
||||
currentRecords["rsplayer"] = db.getplayerid(clientMedic)
|
||||
currentRecords["rsrecord"] = stats.get(clientMedic, "longestReviveSpree")
|
||||
end
|
||||
end
|
||||
|
||||
return sprees
|
|
@ -1,159 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require "luascripts.wolfadmin.util.debug"
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local timers = require "luascripts.wolfadmin.util.timers"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
local balancer = require "luascripts.wolfadmin.admin.balancer"
|
||||
local rules = require "luascripts.wolfadmin.admin.rules"
|
||||
local warns = require "luascripts.wolfadmin.admin.warns"
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local bots = require "luascripts.wolfadmin.game.bots"
|
||||
local sprees = require "luascripts.wolfadmin.game.sprees"
|
||||
local voting = require "luascripts.wolfadmin.game.voting"
|
||||
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local greetings = require "luascripts.wolfadmin.players.greetings"
|
||||
|
||||
local version = "1.0.0"
|
||||
local release = "25 January 2016"
|
||||
|
||||
local basepath = nil
|
||||
|
||||
-- game related data
|
||||
local currentLevelTime = nil
|
||||
|
||||
-- need to do this somewhere else
|
||||
function wolfa_getLevelTime()
|
||||
return currentLevelTime
|
||||
end
|
||||
|
||||
function wolfa_getVersion()
|
||||
return version
|
||||
end
|
||||
|
||||
function wolfa_getRelease()
|
||||
return release
|
||||
end
|
||||
|
||||
function wolfa_getBasePath()
|
||||
return basepath
|
||||
end
|
||||
|
||||
function et_InitGame(levelTime, randomSeed, restartMap)
|
||||
et.RegisterModname("WolfAdmin "..wolfa_getVersion())
|
||||
|
||||
outputDebug("Module "..wolfa_getVersion().." ("..wolfa_getRelease()..") loaded successfully. Created by Timo 'Timothy' Smit.")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "sets mod_wolfadmin "..wolfa_getVersion()..";")
|
||||
|
||||
basepath = string.gsub(et.trap_Cvar_Get("fs_basepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/luascripts/wolfadmin/"
|
||||
|
||||
if not (et.trap_Cvar_Get("fs_game") == "noquarter" or et.trap_Cvar_Get("fs_game") == "nq") then
|
||||
outputDebug("Warning! Not running NoQuarter, this may cause bugs. Use at your own risk.")
|
||||
end
|
||||
|
||||
currentLevelTime = levelTime
|
||||
|
||||
events.trigger("onGameInit", levelTime, randomSeed, (restartMap == 1))
|
||||
end
|
||||
|
||||
function et_ShutdownGame(restartMap)
|
||||
events.trigger("onGameShutdown", (restartMap == 1))
|
||||
end
|
||||
|
||||
function et_ConsoleCommand(cmdText)
|
||||
return events.trigger("onServerCommand", cmdText)
|
||||
end
|
||||
|
||||
function et_ClientConnect(clientId, firstTime, isBot)
|
||||
if firstTime == 1 then
|
||||
stats.set(clientId, "newConnection", true)
|
||||
end
|
||||
|
||||
return events.trigger("onClientConnect", clientId, (firstTime == 1), (isBot == 1))
|
||||
end
|
||||
|
||||
function et_ClientBegin(clientId)
|
||||
events.trigger("onClientBegin", clientId, stats.get(clientId, "newConnection"))
|
||||
|
||||
stats.set(clientId, "newConnection", false)
|
||||
end
|
||||
|
||||
function et_ClientDisconnect(clientId)
|
||||
events.trigger("onClientDisconnect", clientId)
|
||||
end
|
||||
|
||||
function et_ClientUserinfoChanged(clientId)
|
||||
events.trigger("onClientInfoChange", clientId)
|
||||
end
|
||||
|
||||
function et_ClientCommand(clientId, cmdText)
|
||||
return events.trigger("onClientCommand", clientId, cmdText)
|
||||
end
|
||||
|
||||
-- gameState
|
||||
-- 0 - game (also when paused)
|
||||
-- 1 - warmup
|
||||
-- 2 - unknown
|
||||
-- 3 - intermission
|
||||
function et_RunFrame(levelTime)
|
||||
local gameState = tonumber(et.trap_Cvar_Get("gamestate"))
|
||||
|
||||
if game.getState() ~= gameState then
|
||||
events.trigger("onGameStateChange", gameState)
|
||||
end
|
||||
|
||||
events.trigger("onGameFrame", levelTime)
|
||||
end
|
||||
|
||||
-- no callbacks defined for these things, so had to invent some special regexes
|
||||
-- note for etlegacy team: please take a look at this, might come in handy :-)
|
||||
function et_Print(consoleText)
|
||||
local result, poll = string.match(consoleText, "^Vote (%w+): %[poll%] ([%w%s]+)\n$")
|
||||
if result then
|
||||
events.trigger("onPollFinish", (result == "Passed"), poll)
|
||||
end
|
||||
|
||||
local clientMedic, clientVictim = string.match(consoleText, "^Medic_Revive:%s+(%d+)%s+(%d+)\n$")
|
||||
clientMedic = tonumber(clientMedic)
|
||||
clientVictim = tonumber(clientVictim)
|
||||
if clientMedic and clientVictim then
|
||||
events.trigger("onPlayerRevive", clientMedic, clientVictim)
|
||||
end
|
||||
end
|
||||
|
||||
function et_Obituary(victimId, killerId, mod)
|
||||
events.trigger("onPlayerDeath", victimId, killerId, mod)
|
||||
end
|
||||
|
||||
function et_ClientSpawn(clientId, revived)
|
||||
if revived == 0 then
|
||||
events.trigger("onPlayerSpawn", clientId)
|
||||
end
|
||||
end
|
|
@ -1,109 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local greetings = {}
|
||||
|
||||
local userGreetings = {}
|
||||
local levelGreetings = {}
|
||||
|
||||
function greetings.get(clientId)
|
||||
local lvl = et.G_shrubbot_level(clientId)
|
||||
|
||||
if et.G_shrubbot_permission(clientId, "@") ~= 1 then
|
||||
if userGreetings[stats.get(clientId, "playerGUID")] ~= nil then
|
||||
return userGreetings[stats.get(clientId, "playerGUID")]
|
||||
elseif levelGreetings[lvl] ~= nil then
|
||||
return levelGreetings[lvl]
|
||||
end
|
||||
else
|
||||
if levelGreetings[0] then
|
||||
return levelGreetings[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function greetings.show(clientId)
|
||||
local greetingText = greetings.get(clientId)
|
||||
|
||||
if greetingText then
|
||||
local prefix = (util.getAreaName(settings.get("g_greetingArea")) ~= "cp") and "^dgreeting: ^9" or "^7"
|
||||
local greeting = prefix..greetingText:gsub("%[N%]", et.gentity_get(clientId, "pers.netname"))
|
||||
local out = ""
|
||||
|
||||
while util.getAreaName(settings.get("g_greetingArea")) == "cp" and string.len(greeting) > constants.MAX_LENGTH_CP do
|
||||
local sub = greeting:sub(1, constants.MAX_LENGTH_CP)
|
||||
local rev = sub:reverse()
|
||||
|
||||
local pos = rev:find(" [^^]") -- some epic smiley exclusion here
|
||||
|
||||
if pos then
|
||||
pos = constants.MAX_LENGTH_CP - pos
|
||||
out = out..greeting:sub(1, pos).."\\n"
|
||||
greeting = greeting:sub(pos + 2)
|
||||
else
|
||||
pos = sub:len()
|
||||
out = out..greeting:sub(1, pos).."\\n"
|
||||
greeting = greeting:sub(pos + 1)
|
||||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, util.getAreaName(settings.get("g_greetingArea")).." \""..out..greeting.."\";")
|
||||
end
|
||||
end
|
||||
|
||||
function greetings.load()
|
||||
local fileName = settings.get("g_fileGreetings")
|
||||
|
||||
local amount, array = files.loadCFG(fileName, "[a-z]+", true)
|
||||
|
||||
if amount == 0 then return 0 end
|
||||
|
||||
for id, greeting in ipairs(array["level"]) do
|
||||
levelGreetings[tonumber(greeting["level"])] = greeting["greeting"]
|
||||
end
|
||||
|
||||
for id, greeting in ipairs(array["user"]) do
|
||||
userGreetings[greeting["guid"]] = greeting["greeting"]
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
function greetings.oninit(levelTime, randomSeed, restartMap)
|
||||
if settings.get("g_fileGreetings") ~= "" then
|
||||
greetings.load()
|
||||
|
||||
events.handle("onClientBegin", greetings.onbegin)
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", greetings.oninit)
|
||||
|
||||
function greetings.onbegin(clientId, firstTime)
|
||||
if firstTime and (not stats.get(clientId, "isBot") or settings.get("g_botGreetings") == 1) then
|
||||
greetings.show(clientId)
|
||||
end
|
||||
end
|
||||
|
||||
return greetings
|
|
@ -1,107 +0,0 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
|
||||
local settings = {}
|
||||
|
||||
local data = {
|
||||
["g_fileGreetings"] = "greetings.cfg",
|
||||
["g_fileRules"] = "rules.cfg",
|
||||
["g_fileSprees"] = "sprees.cfg",
|
||||
["g_jukeboxEnabled"] = 0,
|
||||
["g_spreeRecords"] = 1,
|
||||
["g_warnHistory"] = 1,
|
||||
["g_announceRevives"] = 1,
|
||||
["g_greetingArea"] = 3,
|
||||
["g_botGreetings"] = 1,
|
||||
["g_botRecords"] = 1,
|
||||
["g_welcomeMessage"] = "^dwolfadmin: ^9This server is running WolfAdmin, type ^7/wolfadmin ^9for more information.",
|
||||
["g_welcomeArea"] = 3,
|
||||
["g_evenerMinDifference"] = 2,
|
||||
["g_evenerMaxDifference"] = 5,
|
||||
["g_evenerInterval"] = 30,
|
||||
["g_voteNextMapTimeout"] = 0,
|
||||
["g_restrictedVotes"] = "",
|
||||
["g_renameLimit"] = 3,
|
||||
["g_renameInterval"] = 60,
|
||||
["g_debugWolfAdmin"] = 0,
|
||||
["omnibot_maxbots"] = 10,
|
||||
["db_type"] = "cfg",
|
||||
["db_hostname"] = "localhost",
|
||||
["db_port"] = 3306,
|
||||
["db_database"] = "wolfadmin",
|
||||
["db_username"] = "",
|
||||
["db_password"] = "",
|
||||
["sv_os"] = "unix"
|
||||
}
|
||||
|
||||
function settings.get(name)
|
||||
return data[name]
|
||||
end
|
||||
|
||||
function settings.set(name, value)
|
||||
data[name] = value
|
||||
end
|
||||
|
||||
function settings.load()
|
||||
for setting, default in pairs(data) do
|
||||
local cvar = et.trap_Cvar_Get(setting)
|
||||
|
||||
if type(default) == "string" then
|
||||
data[setting] = (cvar ~= "" and tostring(cvar) or default)
|
||||
elseif type(default) == "number" then
|
||||
data[setting] = (cvar ~= "" and tonumber(cvar) or default)
|
||||
end
|
||||
end
|
||||
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local amount, array = files.loadCFG("wolfadmin.cfg", "[a-z]+", true)
|
||||
|
||||
for blocksname, settings in pairs(array) do
|
||||
for k, v in pairs(settings[1]) do
|
||||
data[blocksname.."_"..k] = v
|
||||
end
|
||||
end
|
||||
|
||||
local platform = string.lower(et.trap_Cvar_Get("sv_os"))
|
||||
if not (platform == "unix" or platform == "windows") then
|
||||
settings.set("sv_os", settings.determineOS())
|
||||
end
|
||||
end
|
||||
|
||||
function settings.determineOS()
|
||||
local system = io.popen("uname -s"):read("*l")
|
||||
|
||||
if system == "Linux" or system == "unix" or system == "FreeBSD" or system == "OpenBSD" or system == "NetBSD" or system == "Darwin" or system == "SunOS" or (system and system:match("^CYGWIN")) then
|
||||
platform = "unix"
|
||||
elseif system and (system:match("^Windows") or system:match("^MINGW")) then
|
||||
platform = "windows"
|
||||
else -- likely it's unix now
|
||||
platform = "unix"
|
||||
end
|
||||
|
||||
return platform
|
||||
end
|
||||
|
||||
function settings.oninit(levelTime, randomSeed, restartMap)
|
||||
settings.load()
|
||||
end
|
||||
events.handle("onGameInit", settings.oninit)
|
||||
|
||||
return settings
|
134
luascripts/wolfadmin/admin/admin.lua
Normal file
134
luascripts/wolfadmin/admin/admin.lua
Normal file
|
@ -0,0 +1,134 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
local admin = {}
|
||||
|
||||
local playerRenames = {}
|
||||
|
||||
function admin.putPlayer(clientId, teamId)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "forceteam "..clientId.." "..util.getTeamCode(teamId)..";")
|
||||
end
|
||||
|
||||
function admin.kickPlayer(victimId, invokerId, reason)
|
||||
et.trap_DropClient(victimId, "You have been kicked, Reason: "..reason, 0)
|
||||
end
|
||||
|
||||
function admin.setPlayerLevel(clientId, level)
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
|
||||
db.updatePlayerLevel(playerId, level)
|
||||
end
|
||||
|
||||
function admin.onClientConnectAttempt(clientId, firstTime, isBot)
|
||||
if firstTime and db.isConnected() then
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
|
||||
if string.len(guid) < 32 then
|
||||
return "\n\nIt appears you do not have a ^7GUID^9/^7etkey^9. In order to play on this server, create an ^7etkey^9.\n\nMore info: ^7www.etkey.org"
|
||||
end
|
||||
|
||||
if settings.get("g_standalone") ~= 0 then
|
||||
local player = db.getPlayer(guid)
|
||||
if player then
|
||||
local playerId = player["id"]
|
||||
local ban = db.getBanByPlayer(playerId)
|
||||
if ban then
|
||||
return "\n\nYou have been banned for "..ban["duration"].." seconds, Reason: "..ban["reason"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
events.trigger("onClientConnect", clientId, firstTime, isBot)
|
||||
end
|
||||
events.handle("onClientConnectAttempt", admin.onClientConnectAttempt)
|
||||
|
||||
function admin.onClientConnect(clientId, firstTime, isBot)
|
||||
if settings.get("g_standalone") ~= 0 and db.isConnected() then
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
local player = db.getPlayer(guid)
|
||||
|
||||
if player then
|
||||
local playerId = player["id"]
|
||||
local mute = db.getMuteByPlayer(playerId)
|
||||
|
||||
if mute then
|
||||
players.setMuted(clientId, true, mute["type"], mute["issued"], mute["expires"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onClientConnect", admin.onClientConnect)
|
||||
|
||||
function admin.onClientDisconnect(clientId)
|
||||
if playerRenames[clientId] then
|
||||
playerRenames[clientId] = nil
|
||||
end
|
||||
end
|
||||
events.handle("onClientDisconnect", admin.onClientDisconnect)
|
||||
|
||||
function admin.onClientNameChange(clientId, oldName, newName)
|
||||
-- rename filter
|
||||
if not playerRenames[clientId] or playerRenames[clientId]["last"] < os.time() - 60 then
|
||||
playerRenames[clientId] = {
|
||||
["first"] = os.time(),
|
||||
["last"] = os.time(),
|
||||
["count"] = 1
|
||||
}
|
||||
else
|
||||
playerRenames[clientId]["count"] = playerRenames[clientId]["count"] + 1
|
||||
playerRenames[clientId]["last"] = os.time()
|
||||
|
||||
-- give them some time
|
||||
if (playerRenames[clientId]["last"] - playerRenames[clientId]["first"]) > 3 then
|
||||
local renamesPerMinute = playerRenames[clientId]["count"] / (playerRenames[clientId]["last"] - playerRenames[clientId]["first"]) * 60
|
||||
|
||||
if renamesPerMinute > settings.get("g_renameLimit") then
|
||||
admin.kickPlayer(clientId, -1337, "Too many name changes.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- on some mods, this message is already printed
|
||||
-- known: old NQ versions, Legacy
|
||||
if et.trap_Cvar_Get("fs_game") ~= "legacy" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay -1 \""..oldName.." ^7is now known as "..newName.."\";")
|
||||
end
|
||||
|
||||
-- update database
|
||||
if db.isConnected() then
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
local alias = db.getAliasByName(playerId, newName)
|
||||
|
||||
if alias then
|
||||
db.updateAlias(alias["id"], os.time())
|
||||
else
|
||||
db.addAlias(playerId, newName, os.time())
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onClientNameChange", admin.onClientNameChange)
|
||||
|
||||
return admin
|
180
luascripts/wolfadmin/admin/balancer.lua
Normal file
180
luascripts/wolfadmin/admin/balancer.lua
Normal file
|
@ -0,0 +1,180 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local teams = wolfa_requireModule("game.teams")
|
||||
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local bits = wolfa_requireModule("util.bits")
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local tables = wolfa_requireModule("util.tables")
|
||||
local timers = wolfa_requireModule("util.timers")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
local balancer = {}
|
||||
|
||||
balancer.BALANCE_RANDOM = 0
|
||||
balancer.BALANCE_LAST_JOINED = 1
|
||||
balancer.BALANCE_ONLY_DEAD = 2
|
||||
balancer.BALANCE_NOT_OBJECTIVE = 4
|
||||
|
||||
local balancerTimer
|
||||
|
||||
local lastJoined = {[constants.TEAM_AXIS] = {}, [constants.TEAM_ALLIES] = {}, [constants.TEAM_SPECTATORS] = {}}
|
||||
local evenerCount = 0
|
||||
|
||||
function balancer.balance(byAdmin, forceBalance)
|
||||
local teamsDifference = teams.difference()
|
||||
|
||||
if teamsDifference <= 1 then
|
||||
evenerCount = 0
|
||||
|
||||
if byAdmin then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9teams are even.\";")
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local teamGreater, teamSmaller
|
||||
|
||||
if teams.count(constants.TEAM_AXIS) > teams.count(constants.TEAM_ALLIES) then
|
||||
teamGreater = constants.TEAM_AXIS
|
||||
teamSmaller = constants.TEAM_ALLIES
|
||||
elseif teams.count(constants.TEAM_ALLIES) > teams.count(constants.TEAM_AXIS) then
|
||||
teamGreater = constants.TEAM_ALLIES
|
||||
teamSmaller = constants.TEAM_AXIS
|
||||
end
|
||||
|
||||
if settings.get("g_evenerMaxDifference") > 0 and teamsDifference >= settings.get("g_evenerMaxDifference") then
|
||||
evenerCount = evenerCount + 1
|
||||
|
||||
if forceBalance or evenerCount >= 2 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "!shuffle;")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cpm \"^dbalancer: ^7THE TEAMS HAVE BEEN ^qSHUFFLED^7!\";")
|
||||
|
||||
evenerCount = 0
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cpm \"^dbalancer: ^1EVEN THE TEAMS ^7OR ^1SHUFFLE\";")
|
||||
end
|
||||
elseif teamsDifference >= settings.get("g_evenerMinDifference") then
|
||||
evenerCount = evenerCount + 1
|
||||
|
||||
if forceBalance or evenerCount >= 3 then
|
||||
local teamsData = teams.get()
|
||||
|
||||
for i = 1, math.floor(teamsDifference / 2) do
|
||||
local player = balancer.findPlayer(teamsData[teamGreater], teamGreater, teamSmaller)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "!put "..player.." "..(teamGreater == constants.TEAM_AXIS and constants.TEAM_ALLIES_SC or constants.TEAM_AXIS_SC)..";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9thank you, ^7"..et.gentity_get(player, "pers.netname").."^9, for helping to even the teams.\";")
|
||||
|
||||
teamsData = teams.get()
|
||||
end
|
||||
|
||||
evenerCount = 0
|
||||
else
|
||||
local teamGreaterName, teamSmallerName = util.getTeamName(teamGreater), util.getTeamName(teamSmaller)
|
||||
local teamGreaterColor, teamSmallerColor = util.getTeamColor(teamGreater), util.getTeamColor(teamSmaller)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9teams seem unfair, would someone from "..teamGreaterColor..teamGreaterName.." ^9please switch to "..teamSmallerColor..teamSmallerName.."^9?\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function balancer.findPlayer(team, teamGreater, teamSmaller)
|
||||
local playerSelection = settings.get("g_evenerPlayerSelection")
|
||||
|
||||
if bits.hasbit(playerSelection, balancer.BALANCE_LAST_JOINED) then
|
||||
if #lastJoined[teamGreater] > 0 then
|
||||
return lastJoined[teamGreater][#lastJoined[teamGreater]]
|
||||
end
|
||||
end
|
||||
|
||||
local players = {}
|
||||
|
||||
for _, playerId in ipairs(team) do
|
||||
local health = tonumber(et.gentity_get(playerId, "health"))
|
||||
|
||||
local blueflag = et.gentity_get(playerId, "ps.powerups", 5) -- bg_public.h enum powerup_t PW_REDFLAG 6 and PW_BLUEFLAG 7
|
||||
local redflag = et.gentity_get(playerId, "ps.powerups", 6)
|
||||
|
||||
if
|
||||
(not bits.hasbit(playerSelection, balancer.BALANCE_ONLY_DEAD) or health <= 0)
|
||||
and
|
||||
(not bits.hasbit(playerSelection, balancer.BALANCE_NOT_OBJECTIVE) or (blueflag ~= 0 and redflag ~= 0))
|
||||
then
|
||||
table.insert(players, playerId)
|
||||
end
|
||||
end
|
||||
|
||||
if #players == 0 then
|
||||
players = team
|
||||
end
|
||||
|
||||
local rand = math.random(#players)
|
||||
|
||||
return players[rand]
|
||||
end
|
||||
|
||||
function balancer.onclientteamchange(clientId, old, new)
|
||||
local idx = tables.find(lastJoined[old], clientId)
|
||||
|
||||
if idx then
|
||||
table.remove(lastJoined[old], idx)
|
||||
end
|
||||
|
||||
if #lastJoined[new] == 10 then
|
||||
table.remove(lastJoined[new], 1)
|
||||
end
|
||||
|
||||
lastJoined[new][#lastJoined[new] + 1] = clientId
|
||||
end
|
||||
events.handle("onClientTeamChange", balancer.onclientteamchange)
|
||||
|
||||
function balancer.onclientdisconnect(clientId)
|
||||
local team = tonumber(et.gentity_get(clientId, "sess.sessionTeam"))
|
||||
local idx = tables.find(lastJoined[team], clientId)
|
||||
|
||||
if idx then
|
||||
table.remove(lastJoined[team], idx)
|
||||
end
|
||||
end
|
||||
events.handle("onClientDisconnect", balancer.onclientdisconnect)
|
||||
|
||||
function balancer.enable()
|
||||
balancerTimer = timers.add(balancer.balance, settings.get("g_evenerInterval") * 1000, 0, false, false)
|
||||
end
|
||||
|
||||
function balancer.disable()
|
||||
timers.remove(balancerTimer)
|
||||
|
||||
balancerTimer = nil
|
||||
end
|
||||
|
||||
function balancer.isRunning()
|
||||
return (balancerTimer ~= nil)
|
||||
end
|
||||
|
||||
function balancer.oninit()
|
||||
if settings.get("g_balancedteams") ~= 0 and settings.get("g_evenerInterval") > 0 then
|
||||
balancer.enable()
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", balancer.oninit)
|
||||
|
||||
return balancer
|
125
luascripts/wolfadmin/admin/banners.lua
Normal file
125
luascripts/wolfadmin/admin/banners.lua
Normal file
|
@ -0,0 +1,125 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local bits = wolfa_requireModule("util.bits")
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local timers = wolfa_requireModule("util.timers")
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
local toml = wolfa_requireLib("toml")
|
||||
|
||||
local banners = {}
|
||||
|
||||
banners.RANDOM_START = 1
|
||||
banners.RANDOM_ALL = 2
|
||||
|
||||
local nextBannerId = 0
|
||||
local bannerTimer
|
||||
|
||||
local welcomeBanners = {}
|
||||
local infoBanners = {}
|
||||
|
||||
function banners.print(clientId, banner)
|
||||
local prefix = (settings.get("g_bannerArea") ~= constants.AREA_CHAT) and "^7" or "^dbanner: ^9"
|
||||
local target = clientId and clientId or -1
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND,
|
||||
string.format("%s %i \"%s%s\";", util.getCommandForArea(settings.get("g_bannerArea")), target, prefix, banner["text"]))
|
||||
end
|
||||
|
||||
function banners.nextBanner(random)
|
||||
if #infoBanners == 0 then
|
||||
nextBannerId = 0
|
||||
elseif random then
|
||||
nextBannerId = math.random(#infoBanners)
|
||||
elseif nextBannerId ~= #infoBanners then
|
||||
nextBannerId = nextBannerId + 1
|
||||
else
|
||||
nextBannerId = 1
|
||||
end
|
||||
end
|
||||
|
||||
function banners.autoprint()
|
||||
if nextBannerId ~= 0 and infoBanners[nextBannerId] then
|
||||
banners.print(nil, infoBanners[nextBannerId])
|
||||
end
|
||||
|
||||
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_ALL))
|
||||
end
|
||||
|
||||
function banners.load()
|
||||
local fileName = settings.get("g_fileBanners")
|
||||
|
||||
if fileName == "" then
|
||||
return 0
|
||||
end
|
||||
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
return 0
|
||||
end
|
||||
|
||||
-- in case someone issued a !readconfig, make sure the old data is removed
|
||||
banners.clear()
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
local fileTable = toml.parse(fileString)
|
||||
|
||||
if fileTable["banner"] then
|
||||
for _, banner in ipairs(fileTable["banner"]) do
|
||||
if banner["welcome"] and banner["welcome"] == true then
|
||||
table.insert(welcomeBanners, banner)
|
||||
end
|
||||
|
||||
if banner["info"] and banner["info"] == true then
|
||||
table.insert(infoBanners, banner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return #welcomeBanners + #infoBanners
|
||||
end
|
||||
|
||||
function banners.clear()
|
||||
welcomeBanners = {}
|
||||
infoBanners = {}
|
||||
end
|
||||
|
||||
function banners.onPlayerReady(clientId, firstTime)
|
||||
if firstTime then
|
||||
for _, banner in ipairs(welcomeBanners) do
|
||||
banners.print(clientId, banner)
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onPlayerReady", banners.onPlayerReady)
|
||||
|
||||
function banners.onGameInit(levelTime, randomSeed, restartMap)
|
||||
banners.load()
|
||||
|
||||
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START))
|
||||
|
||||
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
|
||||
end
|
||||
events.handle("onGameInit", banners.onGameInit)
|
||||
|
||||
return banners
|
67
luascripts/wolfadmin/admin/bans.lua
Normal file
67
luascripts/wolfadmin/admin/bans.lua
Normal file
|
@ -0,0 +1,67 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local timers = wolfa_requireModule("util.timers")
|
||||
|
||||
local bans = {}
|
||||
|
||||
local storedBanTimer
|
||||
|
||||
function bans.get(banId)
|
||||
return db.getBan(banId)
|
||||
end
|
||||
|
||||
function bans.getCount()
|
||||
return db.getBansCount()
|
||||
end
|
||||
|
||||
function bans.getList(start, limit)
|
||||
return db.getBans(start, limit)
|
||||
end
|
||||
|
||||
function bans.add(victimId, invokerId, duration, reason)
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
local reason = reason and reason or "banned by admin"
|
||||
|
||||
db.addBan(victimPlayerId, invokerPlayerId, os.time(), duration, reason)
|
||||
|
||||
et.trap_DropClient(victimId, "You have been banned for "..duration.." seconds, Reason: "..reason, 0)
|
||||
end
|
||||
|
||||
function bans.remove(banId)
|
||||
db.removeBan(banId)
|
||||
end
|
||||
|
||||
function bans.checkStoredBans()
|
||||
db.removeExpiredBans()
|
||||
end
|
||||
|
||||
function bans.onInit()
|
||||
if db.isConnected() then
|
||||
storedBanTimer = timers.add(bans.checkStoredBans, 60000, 0, false, false)
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", bans.onInit)
|
||||
|
||||
return bans
|
51
luascripts/wolfadmin/admin/history.lua
Normal file
51
luascripts/wolfadmin/admin/history.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local history = {}
|
||||
|
||||
function history.get(clientId, historyId)
|
||||
return db.getHistoryItem(historyId)
|
||||
end
|
||||
|
||||
function history.getCount(clientId)
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
|
||||
return db.getHistoryCount(playerId)
|
||||
end
|
||||
|
||||
function history.getList(clientId, start, limit)
|
||||
local playerId = db.getPlayer(players.getGUID(clientId))["id"]
|
||||
|
||||
return db.getHistory(playerId, start, limit)
|
||||
end
|
||||
|
||||
function history.add(victimId, invokerId, type, reason)
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
db.addHistory(victimPlayerId, invokerPlayerId, type, os.time(), reason)
|
||||
end
|
||||
|
||||
function history.remove(clientId, historyId)
|
||||
db.removeHistory(historyId)
|
||||
end
|
||||
|
||||
return history
|
90
luascripts/wolfadmin/admin/mutes.lua
Normal file
90
luascripts/wolfadmin/admin/mutes.lua
Normal file
|
@ -0,0 +1,90 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local timers = wolfa_requireModule("util.timers")
|
||||
|
||||
local mutes = {}
|
||||
|
||||
local storedMuteTimer
|
||||
local liveMuteTimer
|
||||
|
||||
function mutes.get(muteId)
|
||||
return db.getMute(muteId)
|
||||
end
|
||||
|
||||
function mutes.getCount()
|
||||
return db.getMutesCount()
|
||||
end
|
||||
|
||||
function mutes.getList(start, limit)
|
||||
return db.getMutes(start, limit)
|
||||
end
|
||||
|
||||
function mutes.add(victimId, invokerId, type, duration, reason)
|
||||
local victimPlayerId = db.getPlayer(players.getGUID(victimId))["id"]
|
||||
local invokerPlayerId = db.getPlayer(players.getGUID(invokerId))["id"]
|
||||
|
||||
local reason = reason and reason or "muted by admin"
|
||||
|
||||
players.setMuted(victimId, true, type, os.time(), os.time() + duration)
|
||||
db.addMute(victimPlayerId, invokerPlayerId, type, os.time(), duration, reason)
|
||||
end
|
||||
|
||||
function mutes.remove(muteId)
|
||||
db.removeMute(muteId)
|
||||
end
|
||||
|
||||
function mutes.removeByClient(clientId)
|
||||
players.setMuted(clientId, false)
|
||||
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
local playerId = db.getPlayer(guid)["id"]
|
||||
local mute = db.getMuteByPlayer(playerId)
|
||||
|
||||
if mute then
|
||||
return mutes.remove(mute["id"])
|
||||
end
|
||||
end
|
||||
|
||||
function mutes.checkStoredMutes()
|
||||
db.removeExpiredMutes()
|
||||
end
|
||||
|
||||
function mutes.checkLiveMutes()
|
||||
for clientId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if players.isMuted(clientId) and players.getMuteExpiresAt(clientId) < os.time() then
|
||||
mutes.removeByClient(clientId)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dunmute: ^7"..et.gentity_get(clientId, "pers.netname").." ^9has been automatically unmuted\";")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mutes.onInit()
|
||||
if db.isConnected() then
|
||||
storedMuteTimer = timers.add(mutes.checkStoredMutes, 60000, 0, false, false)
|
||||
liveMuteTimer = timers.add(mutes.checkLiveMutes, 1000, 0, false, false)
|
||||
end
|
||||
end
|
||||
events.handle("onGameInit", mutes.onInit)
|
||||
|
||||
return mutes
|
92
luascripts/wolfadmin/admin/rules.lua
Normal file
92
luascripts/wolfadmin/admin/rules.lua
Normal file
|
@ -0,0 +1,92 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local files = wolfa_requireModule("util.files")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
local toml = wolfa_requireLib("toml")
|
||||
|
||||
local rules = {}
|
||||
|
||||
local data = {}
|
||||
|
||||
function rules.get(shortcut)
|
||||
if shortcut then
|
||||
return data[shortcut]
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
function rules.load()
|
||||
local fileName = settings.get("g_fileRules")
|
||||
|
||||
if fileName == "" then
|
||||
return 0
|
||||
end
|
||||
|
||||
if string.find(fileName, ".toml") == string.len(fileName) - 4 then
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
return 0
|
||||
end
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
local fileTable = toml.parse(fileString)
|
||||
|
||||
local amount = 0
|
||||
|
||||
for _, rule in ipairs(fileTable["rule"]) do
|
||||
if rule["shortcut"] and rule["rule"] then
|
||||
data[rule["shortcut"]] = rule["rule"]
|
||||
|
||||
amount = amount + 1
|
||||
end
|
||||
end
|
||||
|
||||
return amount
|
||||
else
|
||||
-- compatibility for 1.1.* and lower
|
||||
outputDebug("Using .cfg files is deprecated as of 1.2.0. Please consider updating to .toml files.", 3)
|
||||
|
||||
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
|
||||
|
||||
if amount == 0 then return 0 end
|
||||
|
||||
for _, rule in ipairs(array["rule"]) do
|
||||
if rule["shortcut"] and rule["rule"] then
|
||||
data[rule["shortcut"]] = rule["rule"]
|
||||
end
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function rules.oninit(levelTime, randomSeed, restartMap)
|
||||
rules.load()
|
||||
end
|
||||
events.handle("onGameInit", rules.oninit)
|
||||
|
||||
return rules
|
180
luascripts/wolfadmin/auth/acl.lua
Normal file
180
luascripts/wolfadmin/auth/acl.lua
Normal file
|
@ -0,0 +1,180 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local tables = wolfa_requireModule("util.tables")
|
||||
|
||||
local acl = {}
|
||||
|
||||
local cachedLevels = {}
|
||||
local cachedClients = {}
|
||||
|
||||
function acl.onClientConnect(clientId, firstTime, isBot)
|
||||
if settings.get("g_standalone") ~= 0 and db.isConnected() then
|
||||
local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientId), "cl_guid")
|
||||
local player = db.getPlayer(guid)
|
||||
|
||||
if player then
|
||||
cachedClients[clientId] = {}
|
||||
|
||||
local permissions = db.getPlayerPermissions(player["id"])
|
||||
|
||||
for _, permission in ipairs(permissions) do
|
||||
table.insert(cachedClients[clientId], permission["permission"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
events.handle("onClientConnect", acl.onClientConnect)
|
||||
|
||||
function acl.readPermissions()
|
||||
-- read level permissions into a cache file (can be loaded at mod start)
|
||||
-- should probably cache current players' permissions as well, then
|
||||
-- read in new players' permissions as they join the server
|
||||
|
||||
local levels = db.getLevelsWithIds()
|
||||
for _, level in ipairs(levels) do
|
||||
cachedLevels[level["id"]] = {}
|
||||
end
|
||||
|
||||
local permissions = db.getLevelPermissions()
|
||||
|
||||
for _, permission in ipairs(permissions) do
|
||||
table.insert(cachedLevels[permission["level_id"]], permission["permission"])
|
||||
end
|
||||
end
|
||||
|
||||
function acl.clearCache()
|
||||
cachedLevels = {}
|
||||
end
|
||||
|
||||
function acl.isPlayerAllowed(clientId, permission, playerOnly)
|
||||
local level = acl.getPlayerLevel(clientId)
|
||||
|
||||
return (not playerOnly and acl.isLevelAllowed(level, permission)) or (cachedClients[clientId] ~= nil and tables.contains(cachedClients[clientId], permission))
|
||||
end
|
||||
|
||||
function acl.getLevels()
|
||||
return db.getLevels()
|
||||
end
|
||||
|
||||
function acl.isLevel(levelId)
|
||||
return (db.getLevel(levelId) ~= nil)
|
||||
end
|
||||
|
||||
function acl.addLevel(levelId, name)
|
||||
db.addLevel(levelId, name)
|
||||
|
||||
cachedLevels[levelId] = {}
|
||||
end
|
||||
|
||||
function acl.removeLevel(levelId)
|
||||
db.removeLevel(levelId)
|
||||
|
||||
cachedLevels[levelId] = nil
|
||||
end
|
||||
|
||||
function acl.reLevel(levelId, newLevelId)
|
||||
db.reLevel(levelId, newLevelId)
|
||||
end
|
||||
|
||||
function acl.getLevelName(levelId)
|
||||
local level = db.getLevel(levelId)
|
||||
|
||||
return level["name"]
|
||||
end
|
||||
|
||||
function acl.getLevelPermissions(levelId)
|
||||
return cachedLevels[levelId]
|
||||
end
|
||||
|
||||
function acl.addLevelPermission(levelId, permission)
|
||||
db.addLevelPermission(levelId, permission)
|
||||
|
||||
table.insert(cachedLevels[levelId], permission)
|
||||
end
|
||||
|
||||
function acl.removeLevelPermission(levelId, permission)
|
||||
db.removeLevelPermission(levelId, permission)
|
||||
|
||||
for i, levelPermission in ipairs(cachedLevels[levelId]) do
|
||||
if levelPermission == permission then
|
||||
table.remove(cachedLevels[levelId], i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function acl.copyLevelPermissions(levelId, newLevelId)
|
||||
db.copyLevelPermissions(levelId, newLevelId)
|
||||
|
||||
cachedLevels[newLevelId] = tables.merge(cachedLevels[newLevelId], cachedLevels[levelId])
|
||||
end
|
||||
|
||||
function acl.removeLevelPermissions(levelId)
|
||||
db.removeLevelPermissions(levelId)
|
||||
|
||||
cachedLevels[levelId] = {}
|
||||
end
|
||||
|
||||
function acl.isLevelAllowed(levelId, permission)
|
||||
return cachedLevels[levelId] ~= nil and tables.contains(cachedLevels[levelId], permission)
|
||||
end
|
||||
|
||||
function acl.getPlayerPermissions(clientId)
|
||||
return cachedClients[clientId]
|
||||
end
|
||||
|
||||
function acl.addPlayerPermission(clientId, permission)
|
||||
db.addPlayerPermission(db.getPlayerId(clientId), permission)
|
||||
|
||||
table.insert(cachedClients[clientId], permission)
|
||||
end
|
||||
|
||||
function acl.removePlayerPermission(clientId, permission)
|
||||
db.removePlayerPermission(db.getPlayerId(clientId), permission)
|
||||
|
||||
for i, levelPermission in ipairs(cachedClients[clientId]) do
|
||||
if levelPermission == permission then
|
||||
table.remove(cachedClients[clientId], i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function acl.copyPlayerPermissions(clientId, newClientId)
|
||||
db.copyPlayerPermissions(db.getPlayerId(clientId), db.getPlayerId(newClientId))
|
||||
|
||||
cachedClients[newClientId] = tables.copy(cachedClients[clientId])
|
||||
end
|
||||
|
||||
function acl.removePlayerPermissions(clientId)
|
||||
db.removePlayerPermissions(db.getPlayerId(clientId))
|
||||
|
||||
cachedClients[clientId] = {}
|
||||
end
|
||||
|
||||
function acl.getPlayerLevel(clientId)
|
||||
local player = db.getPlayer(players.getGUID(clientId))
|
||||
|
||||
return player["level_id"]
|
||||
end
|
||||
|
||||
return acl
|
146
luascripts/wolfadmin/auth/auth.lua
Normal file
146
luascripts/wolfadmin/auth/auth.lua
Normal file
|
@ -0,0 +1,146 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local events = wolfa_requireModule("util.events")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
local auth = {}
|
||||
|
||||
local srv
|
||||
|
||||
auth.PERM_ADMINTEST = "admintest"
|
||||
auth.PERM_HELP = "help"
|
||||
auth.PERM_TIME = "time"
|
||||
auth.PERM_GREETING = "greeting"
|
||||
|
||||
auth.PERM_LISTPLAYERS = "listplayers"
|
||||
auth.PERM_LISTTEAMS = "listteams"
|
||||
auth.PERM_LISTMAPS = "listmaps"
|
||||
auth.PERM_LISTSPREES = "listsprees"
|
||||
auth.PERM_LISTRULES = "listrules"
|
||||
auth.PERM_LISTHISTORY = "listhistory"
|
||||
auth.PERM_LISTBANS = "listbans"
|
||||
auth.PERM_LISTALIASES = "listaliases"
|
||||
auth.PERM_LISTSTATS = "liststats"
|
||||
auth.PERM_FINGER = "finger"
|
||||
|
||||
auth.PERM_RESETXP = "resetxp"
|
||||
auth.PERM_RESETXP_SELF = "resetxp_self"
|
||||
|
||||
auth.PERM_ADMINCHAT = "adminchat"
|
||||
|
||||
auth.PERM_PUT = "put"
|
||||
auth.PERM_DROPWEAPONS = "dropweapons"
|
||||
auth.PERM_RENAME = "rename"
|
||||
auth.PERM_FREEZE = "freeze"
|
||||
auth.PERM_DISORIENT = "disorient"
|
||||
auth.PERM_BURN = "burn"
|
||||
auth.PERM_SLAP = "slap"
|
||||
auth.PERM_GIB = "gib"
|
||||
auth.PERM_THROW = "throw"
|
||||
auth.PERM_GLOW = "glow"
|
||||
auth.PERM_PANTS = "pants"
|
||||
auth.PERM_POP = "pop"
|
||||
auth.PERM_NADE = "nade"
|
||||
|
||||
auth.PERM_WARN = "warn"
|
||||
auth.PERM_MUTE = "mute"
|
||||
auth.PERM_VOICEMUTE = "voicemute"
|
||||
auth.PERM_KICK = "kick"
|
||||
auth.PERM_BAN = "ban"
|
||||
|
||||
auth.PERM_SPEC999 = "spec999"
|
||||
auth.PERM_BALANCE = "balance"
|
||||
auth.PERM_LOCKPLAYER = "lockplayer"
|
||||
auth.PERM_LOCKTEAM = "lockteam"
|
||||
auth.PERM_SHUFFLE = "shuffle"
|
||||
auth.PERM_SWAP = "swap"
|
||||
|
||||
auth.PERM_PAUSE = "pause"
|
||||
auth.PERM_NEXTMAP = "nextmap"
|
||||
auth.PERM_RESTART = "restart"
|
||||
|
||||
auth.PERM_BOTADMIN = "botadmin"
|
||||
|
||||
auth.PERM_ENABLEVOTE = "enablevote"
|
||||
auth.PERM_CANCELVOTE = "cancelvote"
|
||||
auth.PERM_PASSVOTE = "passvote"
|
||||
|
||||
auth.PERM_COINTOSS = "cointoss"
|
||||
auth.PERM_NEWS = "news"
|
||||
|
||||
auth.PERM_UPTIME = "uptime"
|
||||
auth.PERM_SETLEVEL = "setlevel"
|
||||
auth.PERM_INCOGNITO = "incognito"
|
||||
auth.PERM_READCONFIG = "readconfig"
|
||||
|
||||
auth.PERM_CRAZYSETTINGS = "crazysettings"
|
||||
auth.PERM_WARSETTINGS = "warsettings"
|
||||
|
||||
auth.PERM_CHEATS = "cheats"
|
||||
auth.PERM_DISGUISE = "disguise" -- legacy
|
||||
auth.PERM_AMMOPACK = "ammopack" -- legacy
|
||||
auth.PERM_MEDPACK = "medpack" -- legacy
|
||||
auth.PERM_REVIVE = "revive" -- legacy
|
||||
|
||||
auth.PERM_NOINACTIVITY = "noinactivity"
|
||||
auth.PERM_NOVOTE = "novote"
|
||||
auth.PERM_NOCENSOR = "nocensor"
|
||||
auth.PERM_NOBALANCE = "nobalance"
|
||||
auth.PERM_NOVOTELIMIT = "novotelimit"
|
||||
auth.PERM_NOREASON = "noreason"
|
||||
auth.PERM_NOAKA = "noaka"
|
||||
auth.PERM_PERMA = "perma"
|
||||
|
||||
auth.PERM_TEAMCMDS = "teamcmds"
|
||||
auth.PERM_SILENTCMDS = "silentcmds"
|
||||
|
||||
auth.PERM_SPY = "spy"
|
||||
auth.PERM_IMMUNE = "immune"
|
||||
|
||||
-- as this module serves as a wrapper/super class, we load the selected database
|
||||
-- system in this function. might have to think of a better way to implement
|
||||
-- this, but it will suffice.
|
||||
function auth.onGameInit()
|
||||
if settings.get("g_standalone") ~= 0 then
|
||||
if et.trap_Cvar_Get("g_shrubbot") ~= "" then
|
||||
outputDebug("Running in standalone mode while g_shrubbot is set", 3)
|
||||
end
|
||||
|
||||
if not db.isConnected() then
|
||||
-- FIXME simple workaround to deny any commands
|
||||
function auth.isPlayerAllowed() return false end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
srv = wolfa_requireModule("auth.acl")
|
||||
|
||||
srv.readPermissions()
|
||||
else
|
||||
srv = wolfa_requireModule("auth.shrubbot")
|
||||
|
||||
srv.loadFlags(et.trap_Cvar_Get("fs_game"))
|
||||
end
|
||||
|
||||
setmetatable(auth, {__index = srv})
|
||||
end
|
||||
events.handle("onGameInit", auth.onGameInit)
|
||||
|
||||
return auth
|
126
luascripts/wolfadmin/auth/shrubbot.lua
Normal file
126
luascripts/wolfadmin/auth/shrubbot.lua
Normal file
|
@ -0,0 +1,126 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local shrubbot = {}
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local flags
|
||||
|
||||
function shrubbot.loadFlags(mod)
|
||||
flags = wolfa_requireModule("auth.shrubbot."..mod)
|
||||
end
|
||||
|
||||
function shrubbot.isPlayerAllowed(clientId, permission)
|
||||
if not flags[permission] then
|
||||
outputDebug("shrubbot.isPlayerAllowed requested for unknown permission ("..tostring(permission)..")", 3)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return et.G_shrubbot_permission(clientId, flags[permission]) == 1
|
||||
end
|
||||
|
||||
function shrubbot.getPlayerLevel(clientId)
|
||||
return et.G_shrubbot_level(clientId)
|
||||
end
|
||||
|
||||
function shrubbot.addPlayerPermission(clientId, permission)
|
||||
local fileName = et.trap_Cvar_Get("g_shrubbot")
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
error("failed to open "..fileName.."\n")
|
||||
end
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
for _, adminName, adminGUID, adminLevel, adminFlags in string.gmatch(fileString, "(%[admin%]\nname%s+=%s+([%a%d%p]+)\nguid%s+=%s+([%u%d]+)\nlevel%s+=%s+([%d]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do
|
||||
-- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags))
|
||||
|
||||
if players.getGUID(clientId) == adminGUID then
|
||||
if not auth.isPlayerAllowed(clientId, flags[permission]) then
|
||||
adminFlags = adminFlags.."+"..flags[permission]
|
||||
end
|
||||
|
||||
local adminNameEscaped = string.gsub(adminName, "([%*%+%-%?%^%$%%%[%]%(%)%.])", "%%%1") -- fix for special captures
|
||||
fileString = string.gsub(fileString, "%[admin%]\nname%s+=%s+"..adminNameEscaped.."\nguid%s+=%s+"..adminGUID.."\nlevel%s+=%s+"..adminLevel.."\nflags%s+=%s+([%a%d%p]*)\n\n", "[admin]\nname = "..adminName.."\nguid = "..adminGUID.."\nlevel = "..adminLevel.."\nflags = "..adminFlags.."\n\n")
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local fileDescriptor, _ = et.trap_FS_FOpenFile(fileName, et.FS_WRITE)
|
||||
|
||||
local writeCount = et.trap_FS_Write(fileString, string.len(fileString), fileDescriptor)
|
||||
|
||||
if not writeCount or writeCount < 1 then
|
||||
error("failed to write "..fileName.."\n")
|
||||
end
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "readconfig;")
|
||||
end
|
||||
|
||||
function shrubbot.removePlayerPermission(clientId, permission)
|
||||
local fileName = et.trap_Cvar_Get("g_shrubbot")
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
error("failed to open "..fileName.."\n")
|
||||
end
|
||||
|
||||
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
for _, adminName, adminGUID, adminLevel, adminFlags in string.gmatch(fileString, "(%[admin%]\nname%s+=%s+([%a%d%p]+)\nguid%s+=%s+([%u%d]+)\nlevel%s+=%s+([%d]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do
|
||||
-- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags))
|
||||
|
||||
if players.getGUID(clientId) == adminGUID then
|
||||
if string.find(adminFlags, "+"..flags[permission]) then
|
||||
adminFlags = string.gsub(adminFlags, "+"..flags[permission], "")
|
||||
elseif string.find(adminFlags, flags[permission]) then
|
||||
adminFlags = string.gsub(adminFlags, flags[permission], "")
|
||||
else
|
||||
adminFlags = adminFlags.."-"..flags[permission]
|
||||
end
|
||||
|
||||
local adminNameEscaped = string.gsub(adminName, "([%*%+%-%?%^%$%%%[%]%(%)%.])", "%%%1") -- fix for special captures
|
||||
fileString = string.gsub(fileString, "%[admin%]\nname%s+=%s+"..adminNameEscaped.."\nguid%s+=%s+"..adminGUID.."\nlevel%s+=%s+"..adminLevel.."\nflags%s+=%s+([%a%d%p]*)\n\n", "[admin]\nname = "..adminName.."\nguid = "..adminGUID.."\nlevel = "..adminLevel.."\nflags = "..adminFlags.."\n\n")
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local fileDescriptor, _ = et.trap_FS_FOpenFile(fileName, et.FS_WRITE)
|
||||
|
||||
local writeCount = et.trap_FS_Write(fileString, string.len(fileString), fileDescriptor)
|
||||
|
||||
if not writeCount or writeCount < 1 then
|
||||
error("failed to write "..fileName.."\n")
|
||||
end
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "readconfig;")
|
||||
end
|
||||
|
||||
return shrubbot
|
105
luascripts/wolfadmin/auth/shrubbot/etpub.lua
Normal file
105
luascripts/wolfadmin/auth/shrubbot/etpub.lua
Normal file
|
@ -0,0 +1,105 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
-- ETPub shrubbot flags
|
||||
-- left by mod: fjlovyDHJOTY
|
||||
-- left by WA: flovyDHJTY
|
||||
local flags = {
|
||||
[auth.PERM_ADMINTEST] = "a",
|
||||
[auth.PERM_HELP] = "h",
|
||||
[auth.PERM_TIME] = "C",
|
||||
[auth.PERM_GREETING] = "j",
|
||||
|
||||
[auth.PERM_LISTPLAYERS] = "i",
|
||||
[auth.PERM_LISTTEAMS] = "I",
|
||||
[auth.PERM_LISTMAPS] = "C",
|
||||
[auth.PERM_LISTSPREES] = "E",
|
||||
[auth.PERM_LISTRULES] = "C",
|
||||
[auth.PERM_LISTHISTORY] = "e",
|
||||
[auth.PERM_LISTBANS] = "B",
|
||||
[auth.PERM_LISTALIASES] = "e",
|
||||
[auth.PERM_LISTSTATS] = "t",
|
||||
[auth.PERM_FINGER] = "e",
|
||||
|
||||
[auth.PERM_RESETXP] = "X",
|
||||
[auth.PERM_RESETXP_SELF] = "M",
|
||||
|
||||
[auth.PERM_ADMINCHAT] = "~",
|
||||
|
||||
[auth.PERM_PUT] = "p",
|
||||
[auth.PERM_RENAME] = "N",
|
||||
[auth.PERM_FREEZE] = "F",
|
||||
[auth.PERM_DISORIENT] = "d",
|
||||
[auth.PERM_BURN] = "U",
|
||||
[auth.PERM_SLAP] = "A",
|
||||
[auth.PERM_GIB] = "Q", -- g: individual, Q: all players
|
||||
[auth.PERM_THROW] = "L", -- l: individual, L: all players
|
||||
[auth.PERM_POP] = "z",
|
||||
[auth.PERM_NADE] = "x",
|
||||
|
||||
[auth.PERM_WARN] = "R",
|
||||
[auth.PERM_MUTE] = "m",
|
||||
[auth.PERM_VOICEMUTE] = "m",
|
||||
[auth.PERM_KICK] = "k",
|
||||
[auth.PERM_BAN] = "b",
|
||||
|
||||
[auth.PERM_SPEC999] = "P",
|
||||
[auth.PERM_BALANCE] = "S",
|
||||
[auth.PERM_LOCKPLAYER] = "K",
|
||||
[auth.PERM_LOCKTEAM] = "K",
|
||||
[auth.PERM_SHUFFLE] = "S",
|
||||
[auth.PERM_SWAP] = "w",
|
||||
|
||||
[auth.PERM_COINTOSS] = "Z",
|
||||
[auth.PERM_PAUSE] = "Z",
|
||||
[auth.PERM_NEXTMAP] = "n",
|
||||
[auth.PERM_RESTART] = "r",
|
||||
|
||||
[auth.PERM_BOTADMIN] = "O",
|
||||
|
||||
[auth.PERM_ENABLEVOTE] = "c",
|
||||
[auth.PERM_CANCELVOTE] = "c",
|
||||
[auth.PERM_PASSVOTE] = "V",
|
||||
|
||||
[auth.PERM_NEWS] = "W",
|
||||
|
||||
[auth.PERM_UPTIME] = "u",
|
||||
[auth.PERM_SETLEVEL] = "s",
|
||||
[auth.PERM_INCOGNITO] = "s",
|
||||
[auth.PERM_READCONFIG] = "G",
|
||||
|
||||
[auth.PERM_WARSETTINGS] = "q",
|
||||
|
||||
[auth.PERM_NOINACTIVITY] = "0",
|
||||
[auth.PERM_NOVOTE] = "1",
|
||||
[auth.PERM_NOCENSOR] = "2",
|
||||
[auth.PERM_NOBALANCE] = "5",
|
||||
[auth.PERM_NOVOTELIMIT] = "7",
|
||||
[auth.PERM_NOREASON] = "6",
|
||||
[auth.PERM_NOAKA] = "@",
|
||||
[auth.PERM_PERMA] = "8",
|
||||
|
||||
[auth.PERM_TEAMCMDS] = "9",
|
||||
[auth.PERM_SILENTCMDS] = "3",
|
||||
|
||||
[auth.PERM_SPY] = "4",
|
||||
[auth.PERM_IMMUNE] = "!",
|
||||
}
|
||||
|
||||
return flags
|
111
luascripts/wolfadmin/auth/shrubbot/nq.lua
Normal file
111
luascripts/wolfadmin/auth/shrubbot/nq.lua
Normal file
|
@ -0,0 +1,111 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
-- NoQuarter shrubbot flags
|
||||
-- left by mod: jlqyFHOQY
|
||||
-- left by WA: lyFHQY
|
||||
local flags = {
|
||||
[auth.PERM_ADMINTEST] = "a",
|
||||
[auth.PERM_HELP] = "h",
|
||||
[auth.PERM_TIME] = "C",
|
||||
[auth.PERM_GREETING] = "j",
|
||||
|
||||
[auth.PERM_LISTPLAYERS] = "i",
|
||||
[auth.PERM_LISTTEAMS] = "I",
|
||||
[auth.PERM_LISTMAPS] = "C",
|
||||
[auth.PERM_LISTSPREES] = "I",
|
||||
[auth.PERM_LISTRULES] = "C",
|
||||
[auth.PERM_LISTHISTORY] = "f",
|
||||
[auth.PERM_LISTBANS] = "B",
|
||||
[auth.PERM_LISTALIASES] = "f",
|
||||
[auth.PERM_LISTSTATS] = "I",
|
||||
[auth.PERM_FINGER] = "f",
|
||||
|
||||
[auth.PERM_RESETXP] = "X",
|
||||
[auth.PERM_RESETXP_SELF] = "M",
|
||||
|
||||
[auth.PERM_ADMINCHAT] = "~",
|
||||
|
||||
[auth.PERM_PUT] = "p",
|
||||
[auth.PERM_DROPWEAPONS] = "D",
|
||||
[auth.PERM_RENAME] = "N",
|
||||
[auth.PERM_FREEZE] = "E",
|
||||
[auth.PERM_DISORIENT] = "d",
|
||||
[auth.PERM_BURN] = "U",
|
||||
[auth.PERM_SLAP] = "A",
|
||||
[auth.PERM_GIB] = "g",
|
||||
[auth.PERM_THROW] = "L",
|
||||
[auth.PERM_GLOW] = "o",
|
||||
[auth.PERM_PANTS] = "t",
|
||||
[auth.PERM_POP] = "z",
|
||||
|
||||
[auth.PERM_WARN] = "R",
|
||||
[auth.PERM_MUTE] = "m",
|
||||
[auth.PERM_VOICEMUTE] = "m",
|
||||
[auth.PERM_KICK] = "k",
|
||||
[auth.PERM_BAN] = "b",
|
||||
|
||||
[auth.PERM_SPEC999] = "P",
|
||||
[auth.PERM_BALANCE] = "p",
|
||||
[auth.PERM_LOCKPLAYER] = "L",
|
||||
[auth.PERM_LOCKTEAM] = "L",
|
||||
[auth.PERM_SHUFFLE] = "S",
|
||||
[auth.PERM_SWAP] = "w",
|
||||
|
||||
[auth.PERM_COINTOSS] = "Z",
|
||||
[auth.PERM_PAUSE] = "Z",
|
||||
[auth.PERM_NEXTMAP] = "n",
|
||||
[auth.PERM_RESTART] = "r",
|
||||
|
||||
[auth.PERM_BOTADMIN] = "O",
|
||||
|
||||
[auth.PERM_ENABLEVOTE] = "c",
|
||||
[auth.PERM_CANCELVOTE] = "c",
|
||||
[auth.PERM_PASSVOTE] = "V",
|
||||
|
||||
[auth.PERM_NEWS] = "W",
|
||||
|
||||
[auth.PERM_UPTIME] = "u",
|
||||
[auth.PERM_SETLEVEL] = "s",
|
||||
[auth.PERM_INCOGNITO] = "s",
|
||||
[auth.PERM_READCONFIG] = "G",
|
||||
|
||||
[auth.PERM_CHEATS] = "e",
|
||||
[auth.PERM_DISGUISE] = "T",
|
||||
[auth.PERM_AMMOPACK] = "J",
|
||||
[auth.PERM_MEDPACK] = "J",
|
||||
[auth.PERM_REVIVE] = "v",
|
||||
|
||||
[auth.PERM_NOINACTIVITY] = "0",
|
||||
[auth.PERM_NOVOTE] = "1",
|
||||
[auth.PERM_NOCENSOR] = "2",
|
||||
[auth.PERM_NOBALANCE] = "5",
|
||||
[auth.PERM_NOVOTELIMIT] = "7",
|
||||
[auth.PERM_NOREASON] = "6",
|
||||
[auth.PERM_NOAKA] = "@",
|
||||
[auth.PERM_PERMA] = "8",
|
||||
|
||||
[auth.PERM_TEAMCMDS] = "9",
|
||||
[auth.PERM_SILENTCMDS] = "3",
|
||||
|
||||
[auth.PERM_SPY] = "4",
|
||||
[auth.PERM_IMMUNE] = "!",
|
||||
}
|
||||
|
||||
return flags
|
106
luascripts/wolfadmin/auth/shrubbot/silent.lua
Normal file
106
luascripts/wolfadmin/auth/shrubbot/silent.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
-- silEnT shrubbot flags
|
||||
-- left by mod: fhjovyDHJOTY
|
||||
-- left by WA: fhovyDHJTY
|
||||
local flags = {
|
||||
[auth.PERM_ADMINTEST] = "a",
|
||||
[auth.PERM_HELP] = "", -- left blank intentionally
|
||||
[auth.PERM_TIME] = "", -- left blank intentionally
|
||||
[auth.PERM_GREETING] = "j",
|
||||
|
||||
[auth.PERM_LISTPLAYERS] = "i",
|
||||
[auth.PERM_LISTTEAMS] = "I",
|
||||
[auth.PERM_LISTMAPS] = "h",
|
||||
[auth.PERM_LISTSPREES] = "E",
|
||||
[auth.PERM_LISTRULES] = "h",
|
||||
[auth.PERM_LISTHISTORY] = "e",
|
||||
[auth.PERM_LISTBANS] = "B",
|
||||
[auth.PERM_LISTALIASES] = "e",
|
||||
[auth.PERM_LISTSTATS] = "t",
|
||||
[auth.PERM_FINGER] = "e",
|
||||
|
||||
[auth.PERM_RESETXP] = "X",
|
||||
[auth.PERM_RESETXP_SELF] = "M",
|
||||
|
||||
[auth.PERM_ADMINCHAT] = "~",
|
||||
|
||||
[auth.PERM_PUT] = "p",
|
||||
[auth.PERM_RENAME] = "N",
|
||||
[auth.PERM_FREEZE] = "F",
|
||||
[auth.PERM_DISORIENT] = "d",
|
||||
[auth.PERM_BURN] = "U",
|
||||
[auth.PERM_SLAP] = "A",
|
||||
[auth.PERM_GIB] = "Q", -- g: individual, Q: all players
|
||||
[auth.PERM_THROW] = "L", -- l: individual, L: all players
|
||||
[auth.PERM_POP] = "z",
|
||||
[auth.PERM_NADE] = "x",
|
||||
|
||||
[auth.PERM_WARN] = "R",
|
||||
[auth.PERM_MUTE] = "m",
|
||||
[auth.PERM_VOICEMUTE] = "m",
|
||||
[auth.PERM_KICK] = "k",
|
||||
[auth.PERM_BAN] = "b", -- TODO: subnet ban, flag . (dot)
|
||||
|
||||
[auth.PERM_SPEC999] = "P",
|
||||
[auth.PERM_BALANCE] = "I",
|
||||
[auth.PERM_LOCKPLAYER] = "K",
|
||||
[auth.PERM_LOCKTEAM] = "K",
|
||||
[auth.PERM_SHUFFLE] = "S",
|
||||
[auth.PERM_SWAP] = "w",
|
||||
|
||||
[auth.PERM_COINTOSS] = "Z",
|
||||
[auth.PERM_PAUSE] = "Z",
|
||||
[auth.PERM_NEXTMAP] = "n",
|
||||
[auth.PERM_RESTART] = "r",
|
||||
|
||||
[auth.PERM_BOTADMIN] = "O",
|
||||
|
||||
[auth.PERM_ENABLEVOTE] = "c",
|
||||
[auth.PERM_CANCELVOTE] = "c",
|
||||
[auth.PERM_PASSVOTE] = "V",
|
||||
|
||||
[auth.PERM_NEWS] = "W",
|
||||
|
||||
[auth.PERM_UPTIME] = "u",
|
||||
[auth.PERM_SETLEVEL] = "s",
|
||||
[auth.PERM_INCOGNITO] = "s",
|
||||
[auth.PERM_READCONFIG] = "G",
|
||||
|
||||
[auth.PERM_CRAZYSETTINGS] = "C",
|
||||
[auth.PERM_WARSETTINGS] = "q",
|
||||
|
||||
[auth.PERM_NOINACTIVITY] = "0",
|
||||
[auth.PERM_NOVOTE] = "1",
|
||||
[auth.PERM_NOCENSOR] = "2",
|
||||
[auth.PERM_NOBALANCE] = "5",
|
||||
[auth.PERM_NOVOTELIMIT] = "7",
|
||||
[auth.PERM_NOREASON] = "6",
|
||||
[auth.PERM_NOAKA] = "@",
|
||||
[auth.PERM_PERMA] = "8",
|
||||
|
||||
[auth.PERM_TEAMCMDS] = "9",
|
||||
[auth.PERM_SILENTCMDS] = "3",
|
||||
|
||||
[auth.PERM_SPY] = "4",
|
||||
[auth.PERM_IMMUNE] = "!",
|
||||
}
|
||||
|
||||
return flags
|
34
luascripts/wolfadmin/commands/admin/admintest.lua
Normal file
34
luascripts/wolfadmin/commands/admin/admintest.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandAdminTest(clientId, command)
|
||||
local level = auth.getPlayerLevel(clientId)
|
||||
local levelName = auth.getLevelName(level)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dadmintest: ^7"..players.getName(clientId).." ^9is a level "..level.." user (^7"..levelName.."^9).\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("admintest", commandAdminTest, auth.PERM_ADMINTEST, "display your current admin level", nil, nil, (settings.get("g_standalone") == 0))
|
53
luascripts/wolfadmin/commands/admin/balance.lua
Normal file
53
luascripts/wolfadmin/commands/admin/balance.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local balancer = wolfa_requireModule("admin.balancer")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandBalance(clientId, command, action)
|
||||
if action == "enable" then
|
||||
if not balancer.isRunning() then
|
||||
balancer.enable()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9balancer enabled.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dbalancer: ^9balancer is already running.\";")
|
||||
end
|
||||
elseif action == "disable" then
|
||||
if balancer.isRunning() then
|
||||
balancer.disable()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9balancer disabled.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dbalancer: ^9balancer was not running.\";")
|
||||
end
|
||||
elseif action == "force" then
|
||||
balancer.balance(true, true)
|
||||
elseif not action then
|
||||
balancer.balance(true, false)
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dbalance usage: "..commands.getadmin("balance")["syntax"].."\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("balance", commandBalance, auth.PERM_BALANCE, "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^henable|disable|force^9)", nil, (settings.get("fs_game") == "etpub"))
|
97
luascripts/wolfadmin/commands/admin/ban.lua
Normal file
97
luascripts/wolfadmin/commands/admin/ban.lua
Normal file
|
@ -0,0 +1,97 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local bans = wolfa_requireModule("admin.bans")
|
||||
local history = wolfa_requireModule("admin.history")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandBan(clientId, command, victim, ...)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban usage: "..commands.getadmin("ban")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local args = {...}
|
||||
local duration, reason
|
||||
|
||||
if args[1] and util.getTimeFromString(args[1]) and args[2] then
|
||||
duration = util.getTimeFromString(args[1])
|
||||
reason = table.concat(args, " ", 2)
|
||||
elseif args[1] and util.getTimeFromString(args[1]) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
|
||||
duration = util.getTimeFromString(args[1])
|
||||
reason = "banned by admin"
|
||||
elseif args[1] and not util.getTimeFromString(args[1]) then
|
||||
duration = 600
|
||||
reason = table.concat(args, " ")
|
||||
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
|
||||
reason = "banned by admin"
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban usage: "..commands.getadmin("ban")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isPlayerAllowed(cmdClient, auth.PERM_IMMUNE) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if settings.get("g_playerHistory") ~= 0 then
|
||||
history.add(cmdClient, clientId, "ban", reason)
|
||||
end
|
||||
|
||||
local durationText = "permanently"
|
||||
|
||||
if duration then
|
||||
durationText = "for "..duration.." seconds"
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned "..durationText.."\";")
|
||||
|
||||
bans.add(cmdClient, clientId, duration, reason)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("ban", commandBan, auth.PERM_BAN, "ban a player with an optional duration and reason", "^9[^3name|slot#^9] ^9(^3duration^9) ^9(^3reason^9)", nil, (settings.get("g_standalone") == 0))
|
44
luascripts/wolfadmin/commands/admin/cointoss.lua
Normal file
44
luascripts/wolfadmin/commands/admin/cointoss.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
function commandCoinToss(clientId, command)
|
||||
math.randomseed(et.trap_Milliseconds())
|
||||
|
||||
local number = math.random(0, 99)
|
||||
local result
|
||||
|
||||
if number < 49 then
|
||||
result = "heads."
|
||||
elseif number > 50 then
|
||||
result = "tails."
|
||||
elseif number == 49 then
|
||||
result = "the coin falls on its side!"
|
||||
elseif number == 50 then
|
||||
result = "the coin got lost."
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dcointoss: ^7"..players.getName(clientId).." ^9tossed a coin..."..result.."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("cointoss", commandCoinToss, auth.PERM_COINTOSS, "flips a coin")
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,14 +15,15 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local voting = require "luascripts.wolfadmin.game.voting"
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local voting = wolfa_requireModule("game.voting")
|
||||
|
||||
function commandEnableVote(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^denablevote: ^9next map voting has been enabled.\";")
|
||||
|
||||
function commandEnableVote(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^denablevote: ^9next map voting has been enabled.\";")
|
||||
|
||||
voting.force("nextmap")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("enablevote", commandEnableVote, "c", "enables next map voting")
|
||||
commands.addadmin("enablevote", commandEnableVote, auth.PERM_ENABLEVOTE, "enables next map voting")
|
68
luascripts/wolfadmin/commands/admin/finger.lua
Normal file
68
luascripts/wolfadmin/commands/admin/finger.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
function commandFinger(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger usage: "..commands.getadmin("finger")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local name = players.getName(cmdClient)
|
||||
local cleanname = util.removeColors(players.getName(cmdClient))
|
||||
local codedname = players.getName(cmdClient):gsub("%^([^^])", "^^2%1")
|
||||
local slot = cmdClient
|
||||
local level = auth.getPlayerLevel(cmdClient)
|
||||
local levelName = util.removeColors(auth.getLevelName(level))
|
||||
local guid = players.getGUID(cmdClient)
|
||||
local ip = players.getIP(cmdClient)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dInformation about ^7"..name.."^d:\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..cleanname.." ("..codedname..")\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..slot..(slot < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dLevel: ^2"..level.." ("..levelName..")\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dGUID: ^2"..guid.."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dIP: ^2"..ip.."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("finger", commandFinger, auth.PERM_FINGER, "gives specific information about a player", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
|
77
luascripts/wolfadmin/commands/admin/gib.lua
Normal file
77
luascripts/wolfadmin/commands/admin/gib.lua
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandGib(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib usage: "..commands.getadmin("gib")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isPlayerAllowed(cmdClient, "!") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
elseif et.gentity_get(cmdClient, "sess.sessionTeam") ~= constants.TEAM_AXIS and et.gentity_get(cmdClient, "sess.sessionTeam") ~= constants.TEAM_ALLIES then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is not playing.\";")
|
||||
|
||||
return true
|
||||
elseif et.gentity_get(cmdClient, "health") <= 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is not alive.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- GENTITYNUM_BITS 10 10
|
||||
-- MAX_GENTITIES 1 << GENTITYNUM_BITS 1024
|
||||
-- ENTITYNUM_WORLD MAX_GENTITIES - 2 18
|
||||
et.G_Damage(cmdClient, 0, 1024, 500, 0, 0) -- MOD_UNKNOWN = 0
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dgib: ^7"..players.getName(cmdClient).." ^9was gibbed.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("gib", commandGib, auth.PERM_GIB, "insantly gibs a player", "^9(^3name|slot#^9) (^hreason^9)", nil, (settings.get("g_standalone") == 0))
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,18 +15,19 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local greetings = require "luascripts.wolfadmin.players.greetings"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
function commandGreeting(clientId, cmdArguments)
|
||||
local greetingText = greetings.get(clientId)
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local greetings = wolfa_requireModule("players.greetings")
|
||||
|
||||
function commandGreeting(clientId, command)
|
||||
local greeting = greetings.get(clientId)
|
||||
|
||||
if greetingText then
|
||||
if greeting then
|
||||
greetings.show(clientId)
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgreeting: ^9you do not have a personal greeting.\";")
|
||||
end
|
||||
end
|
||||
commands.register("greeting", commandGreeting, "Q", "display your personal greeting, if you have one")
|
||||
commands.addadmin("greeting", commandGreeting, auth.PERM_GREETING, "display your personal greeting, if you have one")
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,21 +15,23 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandHelp(clientId, cmdArguments)
|
||||
local cmds = commands.get()
|
||||
function commandHelp(clientId, command, cmd)
|
||||
local cmds = commands.getadmin()
|
||||
|
||||
if #cmdArguments == 0 then
|
||||
if not cmd then
|
||||
local availableCommands = {}
|
||||
|
||||
for command, data in pairs(cmds) do
|
||||
if data["function"] and data["flag"] and et.G_shrubbot_permission(clientId, data["flag"]) == 1 and (not data["hidden"] or (type(data["hidden"]) == "function" and not data["hidden"]())) then
|
||||
if data["function"] and data["flag"] and auth.isPlayerAllowed(clientId, data["flag"]) and not data["hidden"] then
|
||||
table.insert(availableCommands, command)
|
||||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." additional commands (open console for the full list)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." "..((settings.get("g_standalone") ~= 0) and "available" or "additional").." commands (open console for the full list)\";")
|
||||
|
||||
local cmdsOnLine, cmdsBuffer = 0, ""
|
||||
|
||||
|
@ -51,14 +53,14 @@ function commandHelp(clientId, cmdArguments)
|
|||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Type ^2!help ^d[command] ^9for help with a specific command.\";")
|
||||
|
||||
return false
|
||||
elseif #cmdArguments > 0 then
|
||||
local helpCmd = string.lower(cmdArguments[1])
|
||||
else
|
||||
cmd = string.lower(cmd)
|
||||
|
||||
if cmds[helpCmd] ~= nil and (not cmds[helpCmd]["hidden"] or (type(cmds[helpCmd]["hidden"]) == "function" and not cmds[helpCmd]["hidden"]())) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dhelp: ^9help for '^2"..helpCmd.."^9':\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfunction: ^9"..cmds[helpCmd]["help"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsyntax: ^9"..cmds[helpCmd]["syntax"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dflag: ^9'^2"..cmds[helpCmd]["flag"].."^9'\";")
|
||||
if cmds[cmd] ~= nil and (not cmds[cmd]["hidden"] or (type(cmds[cmd]["hidden"]) == "function" and not cmds[cmd]["hidden"]())) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dhelp: ^9help for '^2".. cmd .."^9':\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfunction: ^9"..cmds[cmd]["help"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsyntax: ^9"..cmds[cmd]["syntax"].."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dflag: ^9'^2"..cmds[cmd]["flag"].."^9'\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -66,4 +68,4 @@ function commandHelp(clientId, cmdArguments)
|
|||
|
||||
return false
|
||||
end
|
||||
commands.register("help", commandHelp, "h", "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)
|
||||
commands.addadmin("help", commandHelp, auth.PERM_HELP, "display commands available to you or help on a specific command", "^9(^hcommand^9)", (settings.get("g_standalone") == 0))
|
37
luascripts/wolfadmin/commands/admin/incognito.lua
Normal file
37
luascripts/wolfadmin/commands/admin/incognito.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
function commandIncognito(clientId, command)
|
||||
local isIncognito = auth.isPlayerAllowed(clientId, auth.PERM_NOAKA, true)
|
||||
|
||||
if not isIncognito then
|
||||
auth.addPlayerPermission(clientId, auth.PERM_NOAKA)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dincognito: ^9you are now playing incognito.\";")
|
||||
else
|
||||
auth.removePlayerPermission(clientId, auth.PERM_NOAKA)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dincognito: ^9you stopped playing incognito.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("incognito", commandIncognito, auth.PERM_INCOGNITO, "fakes your level to guest (no aka)")
|
83
luascripts/wolfadmin/commands/admin/kick.lua
Normal file
83
luascripts/wolfadmin/commands/admin/kick.lua
Normal file
|
@ -0,0 +1,83 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local admin = wolfa_requireModule("admin.admin")
|
||||
local history = wolfa_requireModule("admin.history")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandKick(clientId, command, victim, ...)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick usage: "..commands.getadmin("kick")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isPlayerAllowed(cmdClient, auth.PERM_IMMUNE) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local args = {...}
|
||||
local reason
|
||||
|
||||
if args[1] then
|
||||
reason = table.concat(args, " ")
|
||||
elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
|
||||
reason = "kicked by admin"
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick usage: "..commands.getadmin("kick")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if settings.get("g_playerHistory") ~= 0 then
|
||||
history.add(cmdClient, clientId, "kick", reason)
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dkick: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been kicked\";")
|
||||
|
||||
admin.kickPlayer(cmdClient, clientId, reason)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("kick", commandKick, auth.PERM_KICK, "kick a player with an optional reason", "^9[^3name|slot#^9] ^9(^3reason^9)", nil, (settings.get("g_standalone") == 0))
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,14 +15,15 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local bots = require "luascripts.wolfadmin.game.bots"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local bots = wolfa_requireModule("game.bots")
|
||||
|
||||
function commandBotsOff(clientId, cmdArguments)
|
||||
function commandBotsOff(clientId, command)
|
||||
bots.enable(false)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dkickbots: ^9bots were toggled off.\";")
|
||||
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dkickbots: ^9bots were toggled off.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("kickbots", commandBotsOff, "O", "kicks all bots from the game")
|
||||
commands.addadmin("kickbots", commandBotsOff, auth.PERM_BOTADMIN, "kicks all bots from the game")
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,29 +15,36 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
function commandListAliases(clientId, cmdArguments)
|
||||
if settings.get("db_type") == "cfg" then
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local pagination = wolfa_requireModule("util.pagination")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
function commandListAliases(clientId, command, victim, offset)
|
||||
local cmdClient
|
||||
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^9alias history is disabled.\";")
|
||||
|
||||
return true
|
||||
elseif cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases usage: "..commands.get("listaliases")["syntax"].."\";")
|
||||
elseif victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases usage: "..commands.getadmin("listaliases")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
|
@ -46,18 +53,21 @@ function commandListAliases(clientId, cmdArguments)
|
|||
return true
|
||||
end
|
||||
|
||||
if et.G_shrubbot_permission(cmdClient, "!") == 1 then
|
||||
if auth.isPlayerAllowed(cmdClient, "!") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif et.G_shrubbot_level(cmdClient) > et.G_shrubbot_level(clientId) then
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local player = db.getplayer(stats.get(cmdClient, "playerGUID"))["id"]
|
||||
local aliases = db.getaliases(player)
|
||||
local player = db.getPlayer(players.getGUID(cmdClient))["id"]
|
||||
|
||||
local count = db.getAliasesCount(player)
|
||||
local limit, offset = pagination.calculate(count, 30, tonumber(offset))
|
||||
local aliases = db.getAliases(player, limit, offset)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dAliases for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, alias in pairs(aliases) do
|
||||
|
@ -67,8 +77,9 @@ function commandListAliases(clientId, cmdArguments)
|
|||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^7"..spaces..alias["alias"].." ^7"..string.format("%8s", alias["used"]).." times\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistaliases: ^9"..#aliases.." known aliases for ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9 (open console for the full list).\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistaliases: ^9aliases for ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9were printed to the console.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("listaliases", commandListAliases, "f", "display all known aliases for a player", "^9[^3name|slot#^9]", function() return (settings.get("db_type") == "cfg") end)
|
||||
commands.addadmin("listaliases", commandListAliases, auth.PERM_LISTALIASES, "display all known aliases for a player", "^9[^3name|slot#^9] ^9(^hoffset^9)")
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,24 +15,32 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
function commandListMaps(clientId, cmdArguments)
|
||||
local output = ""
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local game = wolfa_requireModule("game.game")
|
||||
|
||||
function commandListMaps(clientId, command)
|
||||
local maps = game.getMaps()
|
||||
|
||||
|
||||
if #maps == 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistmaps: ^9no map information available.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local output = ""
|
||||
|
||||
for _, map in ipairs(maps) do
|
||||
local prefix = "^9"
|
||||
if map == game.getMap() then prefix = "^7" end
|
||||
|
||||
output = (output ~= "") and output.." "..prefix..map or map
|
||||
|
||||
output = (output ~= "") and output.." "..prefix..map or prefix..map
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dlistmaps: ^9"..output.. "\";")
|
||||
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dlistmaps: ^9"..output.. "\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("listmaps", commandListMaps, "C", "display the maps in the rotation")
|
||||
commands.addadmin("listmaps", commandListMaps, auth.PERM_LISTMAPS, "display the maps in the rotation")
|
95
luascripts/wolfadmin/commands/admin/listplayers.lua
Normal file
95
luascripts/wolfadmin/commands/admin/listplayers.lua
Normal file
|
@ -0,0 +1,95 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local fireteams = wolfa_requireModule("game.fireteams")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
function commandListPlayers(clientId, command)
|
||||
local playersOnline = {}
|
||||
|
||||
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if players.isConnected(playerId) then
|
||||
table.insert(playersOnline, playerId)
|
||||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dCurrently ^7"..(#playersOnline).." ^dplayers online^d:\";")
|
||||
for _, player in pairs(playersOnline) do
|
||||
local teamColor, teamCode
|
||||
|
||||
if et.gentity_get(player, "pers.connected") == constants.CON_CONNECTED then
|
||||
teamColor = util.getTeamColor(tonumber(et.gentity_get(player, "sess.sessionTeam")))
|
||||
teamCode = util.getTeamCode(tonumber(et.gentity_get(player, "sess.sessionTeam"))):upper():sub(1,1)
|
||||
else
|
||||
teamColor = "^8"
|
||||
teamCode = "C"
|
||||
end
|
||||
|
||||
local level = auth.isPlayerAllowed(player, auth.PERM_INCOGNITO) and 0 or auth.getPlayerLevel(player)
|
||||
local levelName = auth.getLevelName(level)
|
||||
|
||||
local guidStub
|
||||
|
||||
if players.isBot(player) then
|
||||
guidStub = "OMNIBOT-"
|
||||
else
|
||||
guidStub = players.getGUID(player):sub(-8)
|
||||
end
|
||||
|
||||
local fireteamId, fireteamName = fireteams.getPlayerFireteamId(player), ""
|
||||
|
||||
if fireteamId then
|
||||
fireteamName = fireteams.getName(fireteamId):sub(1, 1)
|
||||
end
|
||||
|
||||
local aka = ""
|
||||
|
||||
local mostUsedAlias = db.getMostUsedAlias(db.getPlayerId(player))["alias"]
|
||||
if not players.isBot(player) and not auth.isPlayerAllowed(player, auth.PERM_INCOGNITO) and players.getName(player) ~= mostUsedAlias then
|
||||
aka = "(a.k.a. "..mostUsedAlias.."^7)"
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%2i %s%s ^7%-2i %20s ^7(*%s) ^1%1s ^3%1s ^7%s ^7%s",
|
||||
player, -- slot
|
||||
teamColor, -- team
|
||||
teamCode, -- team
|
||||
level, -- level
|
||||
levelName, -- levelname
|
||||
guidStub, -- guid stub
|
||||
(players.isMuted(player) and "M" or ""), -- muted
|
||||
fireteamName, -- fireteam
|
||||
players.getName(player), -- name
|
||||
aka -- alias
|
||||
).."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistplayers: ^9current player info was printed to the console.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("listplayers", commandListPlayers, auth.PERM_LISTPLAYERS, "display a list of connected players, their slot numbers as well as their admin levels", nil, nil, (settings.get("g_standalone") == 0))
|
71
luascripts/wolfadmin/commands/admin/lock.lua
Normal file
71
luascripts/wolfadmin/commands/admin/lock.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local teams = wolfa_requireModule("game.teams")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandLock(clientId, command, team)
|
||||
if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then
|
||||
return false
|
||||
end
|
||||
|
||||
if team == "all" then
|
||||
teams.lock(constants.TEAM_AXIS)
|
||||
teams.lock(constants.TEAM_ALLIES)
|
||||
teams.lock(constants.TEAM_SPECTATORS)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
teams.lock(util.getTeamFromCode(team))
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") ~= 0))
|
||||
|
||||
function commandLock(clientId, command, team)
|
||||
if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlock usage: "..commands.getadmin("lock")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if team == "all" then
|
||||
teams.lock(constants.TEAM_AXIS)
|
||||
teams.lock(constants.TEAM_ALLIES)
|
||||
teams.lock(constants.TEAM_SPECTATORS)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dlock: ^9all teams have been locked.\";")
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local team = util.getTeamFromCode(team)
|
||||
teams.lock(team)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dlock: "..util.getTeamColor(team)..util.getTeamName(team).." ^9team has been locked.\";")
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", nil, (settings.get("g_standalone") == 0))
|
98
luascripts/wolfadmin/commands/admin/mute.lua
Normal file
98
luascripts/wolfadmin/commands/admin/mute.lua
Normal file
|
@ -0,0 +1,98 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local history = wolfa_requireModule("admin.history")
|
||||
local mutes = wolfa_requireModule("admin.mutes")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandMute(clientId, command, victim, ...)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute usage: "..commands.getadmin("mute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local args = {...}
|
||||
local duration, reason
|
||||
|
||||
if args[1] and util.getTimeFromString(args[1]) and args[2] then
|
||||
duration = util.getTimeFromString(args[1])
|
||||
reason = table.concat(args, " ", 2)
|
||||
elseif args[1] and util.getTimeFromString(args[1]) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
|
||||
duration = util.getTimeFromString(args[1])
|
||||
reason = "muted by admin"
|
||||
elseif args[1] and not util.getTimeFromString(args[1]) then
|
||||
duration = 600
|
||||
reason = table.concat(args, " ")
|
||||
elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
|
||||
duration = 600
|
||||
reason = "muted by admin"
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute usage: "..commands.getadmin("mute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if players.isMuted(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is already muted.\";")
|
||||
|
||||
return true
|
||||
elseif auth.isPlayerAllowed(cmdClient, auth.PERM_IMMUNE) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
mutes.add(cmdClient, clientId, players.MUTE_CHAT + players.MUTE_VOICE, duration, reason)
|
||||
|
||||
if settings.get("g_playerHistory") ~= 0 then
|
||||
history.add(cmdClient, clientId, "mute", reason)
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been muted for "..duration.." seconds\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("mute", commandMute, auth.PERM_MUTE, "mutes a player (text and voice chat)", "^9[^3name|slot#^9] ^9(^3duration^9) ^9(^3reason^9)", nil, (settings.get("g_standalone") == 0))
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,12 +15,15 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local balancer = require "luascripts.wolfadmin.admin.balancer"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local bots = wolfa_requireModule("game.bots")
|
||||
|
||||
function commandBotsOn(clientId, command)
|
||||
bots.enable(true)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dneedbots: ^9bots were toggled on.\";")
|
||||
|
||||
function commandBalance(clientId, cmdArguments)
|
||||
balancer.balance(true, (cmdArguments[1] and cmdArguments[1] == "force"))
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("balance", commandBalance, "p", "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^hforce^9)")
|
||||
commands.addadmin("needbots", commandBotsOn, auth.PERM_BOTADMIN, "adds bots to the game")
|
41
luascripts/wolfadmin/commands/admin/news.lua
Normal file
41
luascripts/wolfadmin/commands/admin/news.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2017 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local game = wolfa_requireModule("game.game")
|
||||
|
||||
function commandNews(clientId, command, map)
|
||||
map = map and map or game.getMap()
|
||||
|
||||
local fileDescriptor, fileLength = et.trap_FS_FOpenFile("sound/vo/"..map.."/news_"..map..".wav", et.FS_READ)
|
||||
|
||||
if fileLength == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dnews: ^9file news_"..map.." does not exist.\";")
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
et.trap_FS_FCloseFile(fileDescriptor)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"sound/vo/"..map.."/news_"..map..".wav\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("news", commandNews, auth.PERM_NEWS, "play the map's news reel or another map's news reel if specified", "^9(^hmapname^9)")
|
29
luascripts/wolfadmin/commands/admin/nextmap.lua
Normal file
29
luascripts/wolfadmin/commands/admin/nextmap.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandNextMap(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dnextmap: ^9next map was loaded.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "vstr nextmap")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("nextmap", commandNextMap, auth.PERM_NEXTMAP, "loads the next map", nil, nil, (settings.get("g_standalone") == 0))
|
31
luascripts/wolfadmin/commands/admin/pause.lua
Normal file
31
luascripts/wolfadmin/commands/admin/pause.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandPause(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dpause: ^9map paused.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ref pause")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("pause", commandPause, auth.PERM_RESTART, "pauses the game for all players", nil, nil, (settings.get("g_standalone") == 0))
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,24 +15,27 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
function commandPlayerLock(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock usage: "..commands.get("vmute")["syntax"].."\";")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
function commandPlayerLock(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock usage: "..commands.getadmin("plock")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
|
@ -41,24 +44,24 @@ function commandPlayerLock(clientId, cmdArguments)
|
|||
return true
|
||||
end
|
||||
|
||||
if admin.isPlayerLocked(cmdClient) then
|
||||
if players.isTeamLocked(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is already locked to a team.\";")
|
||||
|
||||
return true
|
||||
elseif et.G_shrubbot_permission(cmdClient, "!") == 1 then
|
||||
elseif auth.isPlayerAllowed(cmdClient, "!") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif et.G_shrubbot_level(cmdClient) > et.G_shrubbot_level(clientId) then
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been locked to his team\";")
|
||||
|
||||
stats.set(cmdClient, "playerLock", true)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been locked to his team\";")
|
||||
|
||||
players.setTeamLocked(cmdClient, true)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("plock", commandPlayerLock, "K", "locks a player to a specific team", "^9[^3name|slot#^9]")
|
||||
commands.addadmin("plock", commandPlayerLock, auth.PERM_LOCKPLAYER, "locks a player to a specific team", "^9[^3name|slot#^9]")
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,24 +15,27 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
function commandPlayerUnlock(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock usage: "..commands.get("vmute")["syntax"].."\";")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
function commandPlayerUnlock(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock usage: "..commands.getadmin("punlock")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
|
@ -41,16 +44,16 @@ function commandPlayerUnlock(clientId, cmdArguments)
|
|||
return true
|
||||
end
|
||||
|
||||
if not admin.isPlayerLocked(cmdClient) then
|
||||
if not players.isTeamLocked(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock: ^9no player by that name or slot # is locked to a team\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dpunlock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been unlocked from his team\";")
|
||||
|
||||
stats.set(cmdClient, "playerLock", false)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dpunlock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been unlocked from his team\";")
|
||||
|
||||
players.setTeamLocked(cmdClient, false)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("punlock", commandPlayerUnlock, "K", "unlocks a player", "^9[^3name|slot#^9]")
|
||||
commands.addadmin("punlock", commandPlayerUnlock, auth.PERM_LOCKPLAYER, "unlocks a player", "^9[^3name|slot#^9]")
|
71
luascripts/wolfadmin/commands/admin/put.lua
Normal file
71
luascripts/wolfadmin/commands/admin/put.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local admin = wolfa_requireModule("admin.admin")
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandPlayerPut(clientId, command, victim, team)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil or team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput usage: "..commands.getadmin("put")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isPlayerAllowed(cmdClient, "!") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local team = util.getTeamFromCode(team)
|
||||
|
||||
-- cannot unbalance teams in certain mods (see g_svcmds.c:SetTeam)
|
||||
-- fixed in legacymod
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dput: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been put to "..util.getTeamColor(team)..util.getTeamName(team).."\";")
|
||||
|
||||
admin.putPlayer(cmdClient, team)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("put", commandPlayerPut, auth.PERM_PUT, "move a player to a specified team", "^9[^3name|slot#^9] [^3r|b|s^9]", nil, (settings.get("g_standalone") == 0))
|
46
luascripts/wolfadmin/commands/admin/putbots.lua
Normal file
46
luascripts/wolfadmin/commands/admin/putbots.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local balancer = wolfa_requireModule("admin.balancer")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local bots = wolfa_requireModule("game.bots")
|
||||
|
||||
function commandPutBots(clientId, command, team)
|
||||
if team == nil and team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dputbots usage: "..commands.getadmin("putbots")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
team = util.getTeamFromCode(team)
|
||||
|
||||
bots.put(team)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dputbots: ^9all bots were set to ^7"..util.getTeamColor(team)..util.getTeamName(team).." ^9team.\";")
|
||||
|
||||
if (team == constants.TEAM_AXIS or team == constants.TEAM_ALLIES) and balancer.isRunning() then
|
||||
balancer.disable()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dbalancer: ^9balancer disabled.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("putbots", commandPutBots, auth.PERM_PUT, "puts all bots into a specific team", "^9[r|b|s]")
|
51
luascripts/wolfadmin/commands/admin/readconfig.lua
Normal file
51
luascripts/wolfadmin/commands/admin/readconfig.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local banners = wolfa_requireModule("admin.banners")
|
||||
local rules = wolfa_requireModule("admin.rules")
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local greetings = wolfa_requireModule("players.greetings")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandReadconfig(clientId, command)
|
||||
settings.load()
|
||||
local bannersCount = banners.load()
|
||||
local rulesCount = rules.load()
|
||||
local greetingsCount = greetings.load()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"readconfig: loaded "..bannersCount.." banners, "..rulesCount.." rules, "..greetingsCount.." greetings\";")
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true, (settings.get("g_standalone") ~= 0))
|
||||
|
||||
function commandReadconfig(clientId, command)
|
||||
settings.load()
|
||||
local bannersCount = banners.load()
|
||||
local rulesCount = rules.load()
|
||||
local greetingsCount = greetings.load()
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"readconfig: loaded "..bannersCount.." banners, "..rulesCount.." rules, "..greetingsCount.." greetings\";")
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the config file", nil, nil, (settings.get("g_standalone") == 0))
|
60
luascripts/wolfadmin/commands/admin/rename.lua
Normal file
60
luascripts/wolfadmin/commands/admin/rename.lua
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2017 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandRename(clientId, command, victim, newName)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil or newName == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^drename usage: "..commands.getadmin("rename")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^drename: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^drename: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local oldName = players.getName(cmdClient)
|
||||
|
||||
local clientInfo = et.trap_GetUserinfo(cmdClient)
|
||||
clientInfo = et.Info_SetValueForKey(clientInfo, "name", newName)
|
||||
et.trap_SetUserinfo(cmdClient, clientInfo)
|
||||
et.ClientUserinfoChanged(cmdClient)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^drename: ^7"..oldName.." ^9has been renamed to ^7"..newName.."^9.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("rename", commandRename, auth.PERM_RENAME, "renames a player", "^9[^3name|slot#^9] [^3new name^9]", nil, (settings.get("g_standalone") == 0))
|
29
luascripts/wolfadmin/commands/admin/reset.lua
Normal file
29
luascripts/wolfadmin/commands/admin/reset.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandReset(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dreset: ^9match reset.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "reset_match")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("reset", commandReset, auth.PERM_RESTART, "resets the current match", nil, nil, (settings.get("g_standalone") == 0))
|
37
luascripts/wolfadmin/commands/admin/restart.lua
Normal file
37
luascripts/wolfadmin/commands/admin/restart.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local game = wolfa_requireModule("game.game")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandRestart(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^drestart: ^9map restarted.\";")
|
||||
|
||||
local currentState = game.getState()
|
||||
local newState = 5 -- GS_RESET
|
||||
|
||||
if currentState == 0 or currentState == 3 then -- GS_PLAYING or GS_INTERMISSION
|
||||
newState = 2 -- GS_WARMUP
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "map_restart 0 "..newState)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("restart", commandRestart, auth.PERM_RESTART, "restarts the current map", nil, nil, (settings.get("g_standalone") == 0))
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015 Timo 'Timothy' Smit
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,11 +15,12 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands"
|
||||
local rules = require "luascripts.wolfadmin.admin.rules"
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local rules = wolfa_requireModule("admin.rules")
|
||||
|
||||
function commandRules(clientId, cmdArguments)
|
||||
if #cmdArguments == 0 then
|
||||
function commandRules(clientId, command, rule)
|
||||
if not rule then
|
||||
local amountOfRules = 0
|
||||
|
||||
local list = rules.get()
|
||||
|
@ -32,14 +33,14 @@ function commandRules(clientId, cmdArguments)
|
|||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^drules: ^9"..amountOfRules.." rules (open console for the full list)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Type ^2!rules ^d[rule] ^9to announce a specific rule.\";")
|
||||
elseif #cmdArguments > 0 then
|
||||
local rule = rules.get(string.lower(cmdArguments[1]))
|
||||
else
|
||||
local ruleText = rules.get(string.lower(rule))
|
||||
|
||||
if rule then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^drules: "..rules.get(string.lower(cmdArguments[1])).."\";")
|
||||
if ruleText then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^drules: "..ruleText.."\";")
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.register("rules", commandRules, "C", "display the rules on the server", "^9(^hrule^9)")
|
||||
commands.addadmin("rules", commandRules, auth.PERM_LISTRULES, "display the rules on the server", "^9(^hrule^9)")
|
106
luascripts/wolfadmin/commands/admin/setlevel.lua
Normal file
106
luascripts/wolfadmin/commands/admin/setlevel.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local admin = wolfa_requireModule("admin.admin")
|
||||
local history = wolfa_requireModule("admin.history")
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandSetLevel(clientId, command, victim, level)
|
||||
local cmdClient
|
||||
|
||||
if not victim or not level then
|
||||
return false
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
return false
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
return false
|
||||
end
|
||||
|
||||
level = tonumber(level) or 0
|
||||
|
||||
if auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
return false
|
||||
elseif level > auth.getPlayerLevel(clientId) then
|
||||
return false
|
||||
end
|
||||
|
||||
history.add(cmdClient, clientId, "level", tostring(level))
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true, (settings.get("g_standalone") ~= 0))
|
||||
|
||||
function commandSetLevel(clientId, command, victim, level)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel usage: "..commands.getadmin("setlevel")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
level = tonumber(level) or 0
|
||||
|
||||
if auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
elseif not db.getLevel(level) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9this admin level does not exist.\";")
|
||||
|
||||
return true
|
||||
elseif level > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9you may not setlevel higher than your current level.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
admin.setPlayerLevel(cmdClient, level, clientId)
|
||||
history.add(cmdClient, clientId, "level", tostring(level))
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsetlevel: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is now a level ^7"..level.." ^9player.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", nil, (settings.get("g_standalone") == 0))
|
55
luascripts/wolfadmin/commands/admin/showbans.lua
Normal file
55
luascripts/wolfadmin/commands/admin/showbans.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local bans = wolfa_requireModule("admin.bans")
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local pagination = wolfa_requireModule("util.pagination")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
function commandShowBans(clientId, offset)
|
||||
if not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowbans: ^9bans are disabled.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local count = bans.getCount()
|
||||
local limit, offset = pagination.calculate(count, 30, tonumber(offset))
|
||||
local bans = bans.getList(limit, offset)
|
||||
|
||||
if not (bans and #bans > 0) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowbans: ^9there are no bans.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^d"..count.." bans:\";")
|
||||
for _, ban in pairs(bans) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", ban["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(ban["victim_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["issued"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(ban["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", ban["expires"]).." ^7"..ban["reason"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dshowbans: ^9bans were printed to the console.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("showbans", commandShowBans, auth.PERM_LISTBANS, "display a (partial) list of active bans", "(^hstart at ban#^9) ((^hbanner^9) (^3banner's name^9)) ((^3find^9) (^hbanned player^9)) ((^3reason^9) (^hreason for ban^9))", nil, (settings.get("g_standalone") == 0))
|
75
luascripts/wolfadmin/commands/admin/showhistory.lua
Normal file
75
luascripts/wolfadmin/commands/admin/showhistory.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local history = wolfa_requireModule("admin.history")
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local pagination = wolfa_requireModule("util.pagination")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandListHistory(clientId, command, victim, offset)
|
||||
local cmdClient
|
||||
|
||||
if not db.isConnected() or settings.get("g_playerHistory") == 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory: ^9player history is disabled.\";")
|
||||
|
||||
return true
|
||||
elseif victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory usage: "..commands.getadmin("showhistory")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local count = history.getCount(cmdClient)
|
||||
local limit, offset = pagination.calculate(count, 30, tonumber(offset))
|
||||
local playerHistory = history.getList(cmdClient, limit, offset)
|
||||
|
||||
if not (playerHistory and #playerHistory > 0) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowhistory: ^9there is no history for player ^7"..et.gentity_get(cmdClient, "pers.netname").."^9.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHistory for ^7"..et.gentity_get(cmdClient, "pers.netname").."^d:\";")
|
||||
for _, history in pairs(playerHistory) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%4s", history["id"]).." ^7"..string.format("%-20s", util.removeColors(db.getLastAlias(history["invoker_id"])["alias"])).." ^f"..os.date("%d/%m/%Y", history["datetime"]).." ^7"..string.format("%-8s", history["type"]..":").." "..history["reason"].."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9Showing results ^7"..(offset + 1).." ^9- ^7"..(offset + limit).." ^9of ^7"..count.."^9.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dshowhistory: ^9history for ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9was printed to the console.\";")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("showhistory", commandListHistory, auth.PERM_LISTHISTORY, "display history for a specific player", "^9[^3name|slot#^9] ^9(^hoffset^9)", (settings.get("g_playerHistory") == 0))
|
32
luascripts/wolfadmin/commands/admin/shuffle.lua
Normal file
32
luascripts/wolfadmin/commands/admin/shuffle.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandShuffle(clientId, command)
|
||||
if settings.get("fs_game") == "legacy" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by XP.\";")
|
||||
end
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("shuffle", commandShuffle, auth.PERM_SHUFFLE, "shuffle the teams to try and even them", "^2!shuffle ^9", nil, (settings.get("g_standalone") == 0))
|
81
luascripts/wolfadmin/commands/admin/slap.lua
Normal file
81
luascripts/wolfadmin/commands/admin/slap.lua
Normal file
|
@ -0,0 +1,81 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandSlap(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap usage: "..commands.getadmin("slap")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isPlayerAllowed(cmdClient, "!") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
elseif et.gentity_get(cmdClient, "sess.sessionTeam") ~= constants.TEAM_AXIS and et.gentity_get(cmdClient, "sess.sessionTeam") ~= constants.TEAM_ALLIES then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is not playing.\";")
|
||||
|
||||
return true
|
||||
elseif et.gentity_get(cmdClient, "health") <= 0 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is not alive.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local newHealth = et.gentity_get(cmdClient, "health") - 20
|
||||
|
||||
if newHealth < 1 then
|
||||
newHealth = 1
|
||||
end
|
||||
|
||||
et.gentity_set(cmdClient, "health", newHealth)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dslap: ^7"..players.getName(cmdClient).." ^9was slapped.\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..cmdClient.." \"sound/player/land_hurt.wav\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("slap", commandSlap, auth.PERM_SLAP, "give a player a specified amount of damage for a specified reason", "^9[^3name|slot#^9] (^hdamage^9) (^hreason^9)", nil, (settings.get("g_standalone") == 0))
|
46
luascripts/wolfadmin/commands/admin/spec999.lua
Normal file
46
luascripts/wolfadmin/commands/admin/spec999.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local admin = wolfa_requireModule("admin.admin")
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandSpec999(clientId, command)
|
||||
local count = 0
|
||||
|
||||
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if players.isConnected(playerId) then
|
||||
if et.gentity_get(playerId, "ps.ping") > 500 and et.gentity_get(playerId, "ps.ping") <= 999 then
|
||||
admin.putPlayer(playerId, constants.TEAM_SPECTATORS)
|
||||
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dspec999: ^9"..count.." players were put to spectators.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("spec999", commandSpec999, auth.PERM_SPEC999, "moves 999 pingers to the spectator team", nil, nil, (settings.get("g_standalone") == 0))
|
130
luascripts/wolfadmin/commands/admin/stats.lua
Normal file
130
luascripts/wolfadmin/commands/admin/stats.lua
Normal file
|
@ -0,0 +1,130 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
|
||||
function commandShowStats(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.getadmin("stats")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local stats = {
|
||||
["name"] = et.gentity_get(cmdClient, "pers.netname"),
|
||||
["cleanname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^[^^]", ""),
|
||||
["codedsname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"),
|
||||
["slot"] = cmdClient,
|
||||
["team"] = et.gentity_get(cmdClient, "sess.sessionTeam"),
|
||||
["class"] = et.gentity_get(cmdClient, "sess.playerType"),
|
||||
["health"] = et.gentity_get(cmdClient, "health"),
|
||||
["kills"] = et.gentity_get(cmdClient, "sess.kills"),
|
||||
["teamkills"] = et.gentity_get(cmdClient, "sess.team_kills"),
|
||||
["totalkills"] = et.gentity_get(cmdClient, "sess.kills") + et.gentity_get(cmdClient, "sess.team_kills"),
|
||||
["damage"] = et.gentity_get(cmdClient, "sess.damage_given"),
|
||||
["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"),
|
||||
["deaths"] = et.gentity_get(cmdClient, "sess.deaths")
|
||||
}
|
||||
|
||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||
stats["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage_given")
|
||||
stats["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_damage_received")
|
||||
stats["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage_given")
|
||||
stats["totaldamagereceived"] = et.gentity_get(cmdClient, "sess.damage_received") + et.gentity_get(cmdClient, "sess.team_damage_received")
|
||||
stats["selfkills"] = et.gentity_get(cmdClient, "sess.self_kills")
|
||||
stats["gibs"] = et.gentity_get(cmdClient, "sess.gibs")
|
||||
stats["teamgibs"] = et.gentity_get(cmdClient, "sess.team_gibs")
|
||||
stats["totaldeaths"] = et.gentity_get(cmdClient, "sess.deaths") + et.gentity_get(cmdClient, "sess.self_kills")
|
||||
stats["totalgibs"] = et.gentity_get(cmdClient, "sess.gibs") + et.gentity_get(cmdClient, "sess.team_gibs")
|
||||
elseif settings.get("fs_game") == "etpro" then
|
||||
stats["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_received") -- ETPro only
|
||||
else
|
||||
stats["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage")
|
||||
stats["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage")
|
||||
stats["suicides"] = et.gentity_get(cmdClient, "sess.suicides")
|
||||
end
|
||||
|
||||
if stats["totalkills"] == 0 then stats["totalkills"] = 1 end
|
||||
if stats["totaldamage"] == 0 then stats["totaldamage"] = 1 end
|
||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||
if stats["totaldeaths"] == 0 then stats["totaldeaths"] = 1 end
|
||||
if stats["totalgibs"] == 0 then stats["totalgibs"] = 1 end
|
||||
if stats["totaldamagereceived"] == 0 then stats["totaldamagereceived"] = 1 end
|
||||
end
|
||||
|
||||
--[[ for key, value in pairs(stats) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..string.format("%-15s", key..":").." ^7"..value.."\";")
|
||||
end ]]
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dStatistics for ^7"..stats["name"].."^d:\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..stats["cleanname"].." ("..stats["codedsname"]..")\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..stats["slot"]..(stats["slot"] < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dTeam: ^2"..util.getTeamName(stats["team"]).."\";")
|
||||
|
||||
if stats["team"] ~= et.TEAM_SPECTATORS then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dClass: ^2"..util.getClassName(stats["class"]).."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHealth: ^2"..(stats["health"] < 0 and "dead" or stats["health"]).."\";")
|
||||
end
|
||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDmg gvn: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam dmg gvn: ^2"..string.format("%-4s", stats["teamdamage"]).." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDmg rcvd: ^2"..string.format("%-8s", stats["damagereceived"]).." ^dTeam dmg rcvd: ^2"..string.format("%-4s", stats["teamdamagereceived"]).." ^9("..string.format("%0.2f", (stats["teamdamagereceived"] / (stats["totaldamagereceived"] or 1) * 100)).." percent)\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam damage: ^2"..string.format("%-4s", stats["teamdamage"]).." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
||||
end
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dKills: ^2"..string.format("%-8s", stats["kills"]).." ^dTeam kills: ^2"..string.format("%-4s", stats["teamkills"]).." ^9("..string.format("%0.2f", (stats["teamkills"] / (stats["totalkills"] or 1) * 100)).." percent)\";")
|
||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSelf kills: ^2"..string.format("%-4s", stats["selfkills"]).." ^9("..string.format("%0.2f", (stats["selfkills"] / (stats["totaldeaths"] or 1) * 100)).." percent)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dGibs: ^2"..string.format("%-8s", stats["gibs"]).." ^dTeam gibs: ^2"..string.format("%-4s", stats["teamgibs"]).." ^9("..string.format("%0.2f", (stats["teamgibs"] / (stats["totalgibs"] or 1) * 100)).." percent)\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSuicides: ^2"..string.format("%-8s", stats["suicides"]).."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dK/D: ^2"..string.format("%0.2f", (stats["kills"] / ((stats["deaths"] > 0) and stats["deaths"] or 1))).."\";")
|
||||
end
|
||||
|
||||
-- NQ 1.3.0 and higher
|
||||
--[[ for key, value in ipairs(stats["weapstats"]) do
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..stats["weapstats"].."\";")
|
||||
end ]]
|
||||
|
||||
-- NQ 1.3.0 and higher
|
||||
--[[ local weapstats = et.gentity_get(cmdClient, "sess.aWeaponStats", WP_THOMPSON)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..weapstats.."\";") ]]
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dstats: ^9stats for ^7"..stats["name"].." ^9were printed to the console.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("stats", commandShowStats, auth.PERM_LISTSTATS, "display the statistics for a specific player", "^9[^3name|slot#^9]")
|
29
luascripts/wolfadmin/commands/admin/swap.lua
Normal file
29
luascripts/wolfadmin/commands/admin/swap.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandSwap(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dswap: ^9teams swapped.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "swap_teams")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("swap", commandSwap, auth.PERM_SWAP, "swap teams", nil, nil, (settings.get("g_standalone") == 0))
|
27
luascripts/wolfadmin/commands/admin/time.lua
Normal file
27
luascripts/wolfadmin/commands/admin/time.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandTime(clientId, command)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dtime: ^9current time is ^7"..os.date("%H:%M:%S").."^9.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("time", commandTime, auth.PERM_TIME, "displays the local time", nil, nil, (settings.get("g_standalone") == 0))
|
49
luascripts/wolfadmin/commands/admin/unban.lua
Normal file
49
luascripts/wolfadmin/commands/admin/unban.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local bans = wolfa_requireModule("admin.bans")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local db = wolfa_requireModule("db.db")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandRemoveBan(clientId, command, banId)
|
||||
if settings.get("g_standalone") == 0 or not db.isConnected() then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunban: ^9bans are disabled.\";")
|
||||
|
||||
return true
|
||||
elseif not banId or tonumber(banId) == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunban usage: "..commands.getadmin("unban")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if not bans.get(tonumber(banId)) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunban: ^9ban #"..banId.." does not exist.\";")
|
||||
else
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunban: ^9ban #"..banId.." removed.\";")
|
||||
|
||||
bans.remove(tonumber(banId))
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("unban", commandRemoveBan, auth.PERM_BAN, "unbans a player specified ban number as seen in ^2!showbans^9", "^9[^3ban#^9]", nil, (settings.get("g_standalone") == 0))
|
71
luascripts/wolfadmin/commands/admin/unlock.lua
Normal file
71
luascripts/wolfadmin/commands/admin/unlock.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local teams = wolfa_requireModule("game.teams")
|
||||
|
||||
local util = wolfa_requireModule("util.util")
|
||||
local constants = wolfa_requireModule("util.constants")
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandUnlock(clientId, command, team)
|
||||
if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then
|
||||
return false
|
||||
end
|
||||
|
||||
if team == "all" then
|
||||
teams.unlock(constants.TEAM_AXIS)
|
||||
teams.unlock(constants.TEAM_ALLIES)
|
||||
teams.unlock(constants.TEAM_SPECTATORS)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
teams.unlock(util.getTeamFromCode(team))
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") ~= 0))
|
||||
|
||||
function commandUnlock(clientId, command, team)
|
||||
if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunlock usage: "..commands.getadmin("unlock")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if team == "all" then
|
||||
teams.unlock(constants.TEAM_AXIS)
|
||||
teams.unlock(constants.TEAM_ALLIES)
|
||||
teams.unlock(constants.TEAM_SPECTATORS)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dlock: ^9all teams have been unlocked.\";")
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local team = util.getTeamFromCode(team)
|
||||
teams.unlock(team)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dlock: "..util.getTeamColor(team)..util.getTeamName(team).." ^9team has been unlocked.\";")
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", nil, (settings.get("g_standalone") == 0))
|
63
luascripts/wolfadmin/commands/admin/unmute.lua
Normal file
63
luascripts/wolfadmin/commands/admin/unmute.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2020 Timo 'Timothy' Smit
|
||||
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- at your option any later version.
|
||||
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = wolfa_requireModule("auth.auth")
|
||||
|
||||
local mutes = wolfa_requireModule("admin.mutes")
|
||||
|
||||
local commands = wolfa_requireModule("commands.commands")
|
||||
|
||||
local players = wolfa_requireModule("players.players")
|
||||
|
||||
local settings = wolfa_requireModule("util.settings")
|
||||
|
||||
function commandUnmute(clientId, command, victim)
|
||||
local cmdClient
|
||||
|
||||
if victim == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunmute usage: "..commands.getadmin("unmute")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(victim) == nil or tonumber(victim) < 0 or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||
cmdClient = et.ClientNumberFromString(victim)
|
||||
else
|
||||
cmdClient = tonumber(victim)
|
||||
end
|
||||
|
||||
if cmdClient == -1 or cmdClient == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunmute: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunmute: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if not players.isMuted(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dunmute: ^9no player by that name or slot # is muted\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dunmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been unmuted\";")
|
||||
|
||||
mutes.removeByClient(cmdClient)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("unmute", commandUnmute, auth.PERM_MUTE, "unmutes a player (text and voice chat)", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue