Compare commits

...

378 commits

Author SHA1 Message Date
Remy Marquis
8eb29aca14 Removed sprees code
Stop filling 30% of server logs when disabled,
you idiot!

That feature is also controversial as it is quite
quake-like and goes against the idea of better
teamwork we try to emphase in Legacy mod.

* Removed spees game plugin and command
* Removed resetsprees command and related code.
* Removed related g_botRecords
* Not touched the database to ease update.

For something supposedely modular, the spree
code is surprsingly deeply integrated in the
codebase.
2020-04-27 17:27:08 +02:00
Remy Marquis
3193d2f708 Adjusted default config 2020-04-27 17:20:02 +02:00
Remy Marquis
e507cbd000 Added database autocreation through LuaSQL 2020-04-27 17:19:07 +02:00
Timo Smit
eb39bef8bc Version 1.2.1 2020-04-14 21:03:43 +02:00
Timo Smit
b097f51b13 Copyright update 2020-04-14 21:03:02 +02:00
Timo Smit
3784b3d9cd Replaced escape util with LuaSQL native function 2020-04-14 18:06:46 +02:00
Timo Smit
cb47d833cb Fixed reference to uninitialized module (fixes #114) 2020-04-14 18:00:08 +02:00
Timo Smit
a5415cf595 Reverted default banner area to chat area
* this is supported by all mods
* the banner area is not officially released yet
2020-04-14 17:46:35 +02:00
Timo Smit
43750ba5a0 Reverted whitespace error 2020-04-14 17:30:00 +02:00
isRyven
95da07cdae Extended banner to support area prints 2020-04-14 17:21:31 +02:00
Timo Smit
3027d49847 Fixed personal messaging commands toggle for mods other than Legacy 2020-04-14 17:16:09 +02:00
Timo Smit
5ed7319b3e Fixed sprees when sprees file was not loaded (fixes #108) 2020-03-23 21:10:46 +01:00
Timo Smit
f03044563a Fixed nil reference 2020-03-23 20:46:06 +01:00
Timo Smit
8c58482efb Fixed mute command not working after next map (fixes #110)
* this is due to a type issue
2020-03-19 20:56:55 +01:00
Timo Smit
5327c47e30 Do not check for expired mutes without database 2020-03-19 20:00:52 +01:00
Timo Smit
53e411f862 Do not check for expired bans without database 2020-03-19 19:57:01 +01:00
Timo Smit
506db84674 Fixed log files not being created (fixes #99) 2020-01-12 21:12:38 +01:00
Timo Smit
f5da5b151b
Merge pull request #5 from rmarquis/develop/1.2.1 2019-11-10 13:42:49 +01:00
Remy Marquis
5a0952678f Legacy merged XP and SR shuffle commands 2019-11-10 12:27:28 +01:00
Timo Smit
af51a7fa60 Correctly mark teams as even for a one player difference (refs #102) 2019-03-26 15:20:36 +01:00
Timo Smit
2bef5f87db Parametrized !shuffle command (fixes #101) 2019-03-25 18:55:38 +01:00
Timo Smit
30dd74965d Removed unnecessary return statement 2019-03-25 18:09:21 +01:00
Timo Smit
2d1c7a22f4 Added files.exists function used in b2c357b03f 2019-02-12 18:06:29 +01:00
Timo Smit
b2c357b03f Fixed trying to play unavailable spree sounds (refs #95) 2019-02-12 16:53:29 +01:00
Timo Smit
b4a6bcbb16 Simplified GUID check to catch other non-existing GUIDs as well
* removed PunkBuster instructions as well, ET: Legacy clients don't support this any more
2019-02-12 16:35:39 +01:00
Timo Smit
5aeb70d179 Added aka print to !listplayers and fixed display of connecting clients 2019-02-12 15:42:48 +01:00
Timo Smit
71c8de4c0d Added new permission 'noaka'
* sets level to 0 and removes alias output in !listplayers
* binds !incognito to setlevel in shrubbot mode
* binds !incognito to its own permission in ACL mode
2019-02-12 13:26:11 +01:00
Timo Smit
a660a13876 Updated !finger command
* added level and level name
* version removed, since it is not sent by Legacy clients
2019-02-11 15:06:10 +01:00
Timo Smit
2e2c471d98 Improvements to spree handling
* changed default settings to disable records when bots are playing
* changed bot records bitflag to not include sprees when either source or victim is a bot
2019-02-11 13:00:09 +01:00
Timo Smit
1562e74489 Added new setting to ignore records when bots are online
* changed g_botRecords to bitflag
2019-02-11 12:48:16 +01:00
Timo Smit
9c799b8f4d Ignore settings for unknown modules 2019-02-11 12:47:31 +01:00
Timo Smit
4d5e69d785 Added team color to !listplayers 2019-02-09 17:46:46 +01:00
Timo Smit
d35ed96d26 Implemented !rename (refs #62) 2019-02-05 11:51:12 +01:00
Timo Smit
17286223d4 Added !news command 2019-02-04 13:16:07 +01:00
Timo Smit
4f5d0befca Improved seed for cointoss 2019-02-04 13:04:17 +01:00
Timo Smit
d8ef69a6da Added timers to remove expired mutes and bans from database 2019-02-04 13:00:46 +01:00
Timo Smit
d00d30b2ba Fixed chat feedback for kick and ban commands 2019-02-04 12:21:01 +01:00
Timo Smit
f835d8c6ec Fixed banners calculation (fixes #98)
* added checks for available banners
2019-02-04 12:20:06 +01:00
Timo Smit
311f4877c7 Added banners module (refs #98) 2019-02-03 23:09:28 +01:00
Timo Smit
217456cbb6 Added setting to disable spree sounds (entirely, or for others) 2019-02-02 18:12:35 +01:00
Timo Smit
2bd45363e5 Correctly enable commands on legacy 2019-01-31 11:33:41 +01:00
Timo Smit
a253e00d15 Correctly set fs_game in settings module 2019-01-31 11:33:00 +01:00
Timo Smit
5c0c9d3cee Disable !balance command on ETPub 2019-01-31 11:31:37 +01:00
Timo Smit
61ac6de86c Fixed help text and syntax for !put 2019-01-31 11:20:46 +01:00
Timo Smit
d18127fea0 Fixed syntax for !mute and !vmute 2019-01-30 17:00:10 +01:00
Timo Smit
1a8e1f6af5 Fixed correct table merging by values 2019-01-30 16:28:33 +01:00
Timo Smit
2d349919d0 Correctly merge tables when copying levels from one to another 2019-01-30 15:44:03 +01:00
Timo Smit
d5f051890a Implemented a command to clear a level's permissions 2019-01-29 22:49:40 +01:00
Timo Smit
4d332c36a0 Fixed acl not being able to copy level permissions to levels with existing permissions 2019-01-29 22:49:20 +01:00
Timo Smit
e9a4704df1 Fixed zip process of pk3 including pk3 directory itself 2019-01-28 14:32:21 +01:00
Timo Smit
251d85ab66 Merge branch 'patch-1' of github.com:IR4T4/wolfadmin into develop/1.2.1 2019-01-27 22:36:05 +01:00
IR4T4
57904d6a5c
Update putbots.lua
Fix putbots help text
2019-01-27 09:22:42 +01:00
Timo Smit
910c0e15a6 Updated default permission set
* removed 'noreason' from level 4
2019-01-22 15:03:24 +01:00
Timo Smit
f5e2a65e2e Play a sound to the player on !slap for some extra feedback 2019-01-20 21:36:45 +01:00
Timo Smit
7b70c7e7e8 Fixed !showhistory still trying to show an old syntax 2019-01-20 20:57:52 +01:00
Timo Smit
2d145254fe Miscellaneous fixes in loading of sprees, rules and greetings
* fixed counts being returned
* implement some checks for TOML parsing
2019-01-18 15:36:06 +01:00
Timo Smit
11c0903b95 Fixed file existence check for rules.toml 2019-01-18 13:15:59 +01:00
Timo Smit
b2b3fae5ce Fixed checks for punishments without reason and/or time 2019-01-17 19:16:45 +01:00
Timo Smit
14ebac44d9 Fixed util.getTimeFromString not processing a single number as seconds 2019-01-17 18:54:59 +01:00
Timo Smit
adb469a29f Fixed permission checks in certain commands 2019-01-17 16:56:42 +01:00
Timo Smit
511b663f2a Added missing checks for history saving 2019-01-17 16:56:02 +01:00
Timo Smit
cd701f187b Improved error handling of events 2019-01-17 15:31:23 +01:00
Timo Smit
6d3197413a Moved file existence checks for rules and greetings to match sprees code 2019-01-17 11:16:26 +01:00
Timo Smit
415835c723 Check whether sprees file exist (fixes #89) 2019-01-17 11:12:48 +01:00
Timo Smit
2762ff7507 Only enable chat logging in legacy
* references 0212af1a6b
2019-01-16 12:13:17 +01:00
Timo Smit
2754faf98f Fixed syntax for private message command 2019-01-16 11:51:46 +01:00
Timo Smit
f671d02a5b Fixed !rules not displaying correctly when used with arguments 2019-01-15 21:12:33 +01:00
Timo Smit
1ab9877e77 Basic Lua 5.0 compatibility for ETPro 2019-01-10 14:20:04 +01:00
Timo Smit
5e3c966453 Fixed being unable to unban 2019-01-10 10:12:38 +01:00
Timo Smit
fee38fcee5 Merge branch 'bug-mysql-init' of github.com:adawolfa/wolfadmin into develop/1.2.1 2019-01-10 10:10:28 +01:00
Timo Smit
0d36516e60 Updated version to 1.2.1-dev 2019-01-10 10:09:14 +01:00
Adam KlvaÄŤ
c7917c1e73 Fixed missing columns in MySQL initialization script 2019-01-09 23:12:17 +01:00
Timo Smit
19c18fd11a Updated version 2019-01-04 18:15:38 +01:00
Timo Smit
7f0583485f Added MySQL collation conversion (refs #46) 2019-01-04 18:10:03 +01:00
Timo Smit
45002153c9 Deploy script update, added notice on startup (fixes #73) 2019-01-04 18:09:26 +01:00
Timo Smit
1549f950e0 Merge branch 'master' of github.com:timosmit/wolfadmin into develop/1.2.0
# Conflicts:
#	README.md
2019-01-04 17:55:24 +01:00
Timo Smit
93eb1a9544 Reverted 'luamods' dir back to 'luascripts'
* reverts commit 4ae1421
2019-01-04 17:44:56 +01:00
Timo Smit
c4da960bb8 Updated links to use HTTPS protocol 2019-01-04 17:35:36 +01:00
Timo Smit
d3874d3896 Yearly copyright update 2019-01-04 17:32:24 +01:00
Timo Smit
c7009e91d3 Updated TOML lib to 2.0.1 2019-01-04 17:18:39 +01:00
Timo Smit
b98bccbba6 Fixed foreign key constraints failing 2019-01-04 16:19:51 +01:00
Timo Smit
0212af1a6b Only enable chat logging in legacy 2019-01-03 12:51:31 +01:00
Timo Smit
47f9baf277 Fixed consistent checking of standalone setting
* treat everything non-zero as true (enabled)
2019-01-03 12:49:11 +01:00
Timo Smit
6d0ba325f1 Fixed greetings returning errors when database is not connected 2019-01-03 12:14:13 +01:00
Timo Smit
2a71ab2bb1 Updated docs (part II) 2019-01-03 12:09:10 +01:00
Timo Smit
241910ad38 Updated docs.
* docs directory was obsolete and has been removed.
* the readme is more reader friendly now.
* the license has been changed to Markdown format.
2019-01-03 12:08:06 +01:00
Timo Smit
aef9e0d426 Fixed aliases not being updated on connect 2019-01-03 11:28:22 +01:00
Timo Smit
a2f7f1dec4 Fixed OS and mode detection (refs #61, #74)
* fixed OS detection echoing errors to log when executables are not available
* OS detection makes use of Unix/Windows native functions rather than environment variables which can be modified
* fixed ability to override standalone mode
2019-01-03 11:15:22 +01:00
Timo Smit
9e2359363b Fixed closing the database when it is not connected 2019-01-03 11:11:09 +01:00
Timo Smit
da4fd9d235 Implemented checks for availability of TOML files (refs #60) 2019-01-03 11:10:35 +01:00
Timo Smit
7675419d61 Fixed GPL link in README.md 2019-01-02 15:30:48 +01:00
Timo Smit
b4b2b9d2b0 Fixed missing table existence checks 2019-01-02 10:15:24 +01:00
Timo Smit
98d4a30b21 Fixed Lua game init completely being interrupted when database is unavailable (refs #59)
* database module will throw debug messages when it cannot connect or read
* ACL module will enter 'dumb' mode and disallow any permissions (should be changed in future)
2019-01-01 21:12:22 +01:00
Timo Smit
aa67685e45 Improved checks for database availability 2019-01-01 19:50:39 +01:00
Timo Smit
e66d78bd35 Added database config table and schema detection (refs #73)
* only used to store schema version for the moment.
2019-01-01 19:49:38 +01:00
Timo Smit
b8688d7fca Fixed !listplayers taking PERM_INCOGNITO into account (refs #62, #69) 2018-12-31 11:17:26 +01:00
Timo Smit
78139e6e0f Fixed !listmaps not producing any output (refs #62) 2018-12-31 11:15:38 +01:00
Timo Smit
53e31020a1 Fixed incognito command for standalone mode (refs #62) 2018-12-31 11:04:38 +01:00
Timo Smit
44f78fb1d3 ACL system improvements (refs #69)
* renamed 'roles' to 'permissions'
* added player permissions
* added functions to manipulate shrubbot files
2018-12-31 11:03:48 +01:00
Timo Smit
1872921e52 Fixed !setlevel not being correctly saved 2018-04-15 20:36:01 +02:00
Timo Smit
84f008080d Added compatibility note 2018-02-16 12:49:12 +01:00
Timo Smit
27986cbf7a Added autodetection of standalone mode (refs #61) 2018-02-16 12:49:00 +01:00
Timo Smit
de27a4172b Fixed shrubbot flags for other mods (refs #46, #69, #62)
* changed !greeting flag from 'Q' to 'j' to maintain consistency across mods
* changed !cointoss flag to 'Z' so we do not take up another flag
* moved flags to separate files for each mod that includes shrubbot, autoloads on game init
2018-02-16 12:20:23 +01:00
Timo Smit
6a3459d988 Fixed mutes being checked regardless of module mode (refs #61) 2018-02-16 11:59:20 +01:00
Timo Smit
30750d7062 Fix for ACL system being loaded regardless of g_standalone setting
Caused by ACL command which requires the ACL system
2018-02-16 11:33:47 +01:00
Timo Smit
6282c0e9bf Fixed help texts in mute commands 2018-02-15 11:07:08 +01:00
Timo Smit
48522b8dcf Added util.typecheck function to ensure types in certain utility functions (fixes #78) 2018-02-13 11:45:11 +01:00
Timo Smit
25af884c7e Disabled GUID and ban check when database is disabled (fixes #83). 2018-02-13 11:02:38 +01:00
Timo Smit
8ef2d13015 Fixed consistency in deploy script (refs #73) 2018-02-13 09:39:35 +01:00
Timo Smit
ddb2c6fc21 Improved deploy script (refs #73)
* Improved several error messages
* Fixed several bugs related to fs_homepath
* Ability to create and copy pk3
2018-02-12 18:27:08 +01:00
Timo Smit
d27921ea1a Merge branch 'develop/1.1.1' of https://github.com/timosmit/wolfadmin into develop/1.2.0
# Conflicts:
#	luascripts/admin/admin.lua
#	luascripts/admin/rules.lua
#	luascripts/admin/warns.lua
#	luascripts/commands/admin/dewarn.lua
#	luascripts/commands/admin/listlevels.lua
#	luascripts/commands/admin/lock.lua
#	luascripts/commands/admin/putbots.lua
#	luascripts/commands/admin/readconfig.lua
#	luascripts/commands/admin/setlevel.lua
#	luascripts/commands/admin/showwarns.lua
#	luascripts/commands/admin/sprees.lua
#	luascripts/commands/admin/stats.lua
#	luascripts/commands/admin/unlock.lua
#	luascripts/commands/admin/warn.lua
#	luascripts/commands/client/pm.lua
#	luascripts/commands/client/r.lua
#	luascripts/commands/commands.lua
#	luascripts/commands/server/csay.lua
#	luascripts/db/mysql.lua
#	luascripts/db/sqlite3.lua
#	luascripts/game/sprees.lua
#	luascripts/players/greetings.lua
#	luascripts/players/stats.lua
#	luascripts/util/settings.lua
2018-02-12 14:49:39 +01:00
Timo Smit
49fbd3a8f0 Updated copyright 2018-02-12 14:48:34 +01:00
Timo Smit
ed882c58f0 Updated copyright 2018-02-12 14:37:49 +01:00
Timo Smit
68a31b62dd First attempt at a deployment script (refs #73)
Current known flaws:
* only accepts default name for sqlite database (wolfadmin.db)
2018-02-12 13:45:05 +01:00
Timo Smit
ecdd4d96c2 Removed usage instructions from license docs 2017-03-22 11:25:37 +01:00
Timo Smit
3927788b66 Updated MySQL scripts to make use of UTF-8 2017-03-21 18:54:33 +01:00
Timo Smit
875da02712 Fixed !setlevel from console returning unknown command 2017-03-18 12:36:43 +01:00
Timo Smit
2de8a2511c Fixed minor typos 2017-03-17 16:10:06 +01:00
Timo Smit
62126f4b98 Removed empty file 2017-03-17 16:04:45 +01:00
Timo Smit
fba434cf10 Fixed connected players not being added to database on mod init (regression after merge) 2017-03-17 15:40:10 +01:00
Timo Smit
cfd494a5e0 Merge branch 'develop/1.1.1' into develop/1.2.0
# Conflicts:
#	luamods/wolfadmin/db/db.lua
#	luamods/wolfadmin/main.lua
#	luamods/wolfadmin/util/files.lua
#	luamods/wolfadmin/util/tables.lua
#	luascripts/admin/admin.lua
#	luascripts/commands/admin/listlevels.lua
#	luascripts/commands/admin/showwarns.lua
#	luascripts/db/mysql.lua
#	luascripts/db/sqlite3.lua
2017-03-17 15:32:03 +01:00
Timo Smit
65a8ca1854 Fixed GPL link in README.md 2017-03-17 15:02:24 +01:00
Timo Smit
f9609a3260 Added extra condition for empty GUIDs 2017-03-17 15:01:59 +01:00
Timo Smit
034a926bc9 Fixed a file descriptor leak 2017-03-17 14:59:10 +01:00
Timo Smit
a767d7d82a Updated database (upgrade) scripts
* removed level history
* reordering based on constraints
* fixed history
2017-03-17 14:46:19 +01:00
Timo Smit
ab5403da14 Removed !listlevels and moved functionality into !showhistory 2017-03-17 14:05:43 +01:00
Timo Smit
78213fbc78 Updated and fixed upgrade scripts from 1.1.0
* SQLite should now be in correct order
* MySQL added
2017-03-17 13:36:12 +01:00
Timo Smit
3ecbb438cd Updated upgrade scripts from 1.1.0
* renamed scripts
* sqlite should now be consistent with a new database
2017-03-17 12:44:51 +01:00
Timo Smit
db83c8f53f Fixed minor typo 2017-03-17 12:41:27 +01:00
Timo Smit
88512ebca7 Renamed SQL update scripts 2017-03-17 10:33:29 +01:00
Timo Smit
f9b141e675 Updated MySQL database script
* fixed consistency with SQLite
* added tables that were already present in SQLite
2017-03-17 10:23:41 +01:00
Timo Smit
8e45df170b Fixed small typo in MySQL module 2017-03-17 09:29:20 +01:00
Timo Smit
71949e069f Updated MySQL module 2017-03-17 09:06:41 +01:00
Timo Smit
2298864acf Database function naming consistency 2017-03-17 08:53:23 +01:00
Timo Smit
815af34004 Fixed private message logging 2017-03-16 22:35:17 +01:00
Timo Smit
fe30fe8d87 PM can now be sent to multiple recipients (refs #46) 2017-03-16 21:02:23 +01:00
Timo Smit
5898b079bf Fixed rename checker not being reset on client disconnect 2017-03-15 16:25:54 +01:00
Timo Smit
87950f36ce Fixed incorrect invokerId being used for setlevel history 2017-03-15 16:00:06 +01:00
Timo Smit
370ec98e38 Removed some redundant checks 2017-03-15 15:51:37 +01:00
Timo Smit
0cc4aefcee Fixed GPL link in README.md 2017-03-15 14:16:40 +01:00
Timo Smit
730bbbeb17 Updated license for lua-toml and dependency list 2017-03-15 14:14:56 +01:00
Timo Smit
39caf003a7 Ported greetings, rules and spree messages to TOML format 2017-03-15 13:43:16 +01:00
Timo Smit
90c5af82dc Fixed files.loadFromCFG not always returning two arguments 2017-03-15 13:04:46 +01:00
Timo Smit
8034b9ab91 Added toml parser dependency 2017-03-15 12:34:22 +01:00
Timo Smit
8d14486d61 Add support for TOML-formatted configs (refs #60)
* added lua-toml as dependency
* removed cvars.cfg
* removed wolfadmin.cfg
* added wolfadmin.toml
* created compatibility checks for old configs
2017-03-14 22:43:15 +01:00
Timo Smit
a24eefa248 Some more colouring fixes (refs 164e1a4) 2017-03-14 22:38:34 +01:00
Timo Smit
164e1a4569 Updated colouring scheme of debug module
* colours now also used in console (check non-legacymod servers whether this works correctly)
* slightly different colouring scheme for console to increase readibility
2017-03-14 22:11:42 +01:00
Timo Smit
f3eab54330 Fixed auto unmute message not being printed 2017-03-14 20:35:53 +01:00
Timo Smit
16891a37c8 Added extra condition for empty GUIDs 2017-03-14 17:32:50 +01:00
Timo Smit
0a230d592d Fixed possibility to slap/gib players not playing or alive 2017-03-13 18:24:04 +01:00
Timo Smit
d31c6ff0a0 Fixed maxspree message being printed when first spree > 5 2017-03-13 17:19:35 +01:00
Timo Smit
17ea943c64 Naming consistency between in balancer module
* replace occurrences of evener with balancer
2017-03-13 17:10:09 +01:00
Timo Smit
f3aa6dfad5 Fixed put spam for bots
* now makes use of forceteam instead of !put on legacymod
2017-03-13 16:58:45 +01:00
Timo Smit
144a34b3b9 Fixed balancer triggering on unknown commands
* now correctly displays a usage message
* also updated syntax info
2017-03-13 16:52:37 +01:00
Timo Smit
abb6c45e55 Fixed end of sprees not displayed in all cases 2017-03-13 16:40:05 +01:00
Timo Smit
1a3b91fb06 Fixed version info not available in !finger 2017-03-13 10:45:16 +01:00
Timo Smit
0c0392b3c5 Fixed death spree always being reset 2017-03-13 10:22:24 +01:00
Timo Smit
8e181447b2 Regardless of messages, reset sprees accordingly 2017-03-13 10:09:19 +01:00
Timo Smit
2442f49408 Added validity checks for loaded CFGs (refs #80) 2017-03-13 09:22:19 +01:00
Timo Smit
db6a378032 Fixed CFG loading with Unix file endings (refs #80) 2017-03-13 09:16:36 +01:00
Timo Smit
e9d17e8572 Fixed CFG file loading with Windows encoding (fixes #80) 2017-03-13 09:02:26 +01:00
Timo Smit
cf0988d442 Default death sprees now start at 10 deaths 2017-03-12 22:33:20 +01:00
Timo Smit
380aba96cb Removed print of end of spree messages if they're disabled 2017-03-12 21:32:22 +01:00
Timo Smit
5df1a0ac41 Set default g_spreeMessages value to 7 2017-03-11 23:37:08 +01:00
Timo Smit
8b9bfd54a6 Fix nil spree message
* for sprees % 0, it would try to find and output a max spree while there isn't
2017-03-11 23:35:36 +01:00
Timo Smit
c47c6572da Fixed connected players not being added to database on mod init 2017-03-08 13:16:29 +01:00
Timo Smit
c73a41f7e7 Fixed listings returning 'duplicate' rows (caused by references) 2017-03-08 12:31:19 +01:00
Timo Smit
d7217cfa88 Merge branch 'develop/1.2.0' of github.com:rmarquis/wolfadmin into develop/1.2.0 2017-03-03 13:05:30 +01:00
Timo Smit
ba24089a80 Revert "Allow settings to be empty"
This reverts commit 24e3242d13.
2017-03-03 12:42:31 +01:00
Timo Smit
24e3242d13 Allow settings to be empty 2017-03-03 12:35:41 +01:00
Timo Smit
7e0b9c5aba Fixed SQLite error (unknown value for column) 2017-03-02 08:48:29 +01:00
Remy Marquis
a65fe28c9a Added shuffle by skill rating for Legacy mod 2017-03-01 12:07:38 +01:00
Timo Smit
0d5e1ceaca Fixed lastseen and seen NULL in SQLite install script 2017-02-27 21:56:56 +01:00
Timo Smit
cd7ad4fd9c Fixed lastseen and seen NULL for new players 2017-02-27 21:48:46 +01:00
Timo Smit
6eeec2d20a Fixed suspicious globals (fixes #75) 2017-02-21 10:45:16 +01:00
Timo Smit
2c32671304 Fixed suspicious globals (fixes #75) 2017-02-21 10:44:14 +01:00
Timo Smit
a72f15b058 Removed redundant initialization (fixes #75) 2017-02-21 10:41:09 +01:00
Timo Smit
6c95703678 Fixed many unused initializations (fixes #75) 2017-02-21 10:33:10 +01:00
Timo Smit
3ed215ee44 Added connection count and last connection information (see 935f71d) 2017-02-18 12:06:34 +01:00
Timo Smit
fafc53710b Added connection count and last connection information 2017-02-17 12:08:42 +01:00
Timo Smit
935f71d4ab Fixed platform detection on Windows (refs #74) 2017-02-14 13:23:14 +01:00
Timo Smit
74f761f39e Added check to disable logging functionality 2017-02-12 13:33:02 +01:00
Timo Smit
d567d076bb Fixed a file descriptor leak 2017-02-12 13:29:45 +01:00
Timo Smit
10fd153b0a Added max bots vote to menu (fixes #77) 2017-02-12 11:53:10 +01:00
Timo Smit
f02f91dc34 Added vote for maximum bots 2017-02-09 10:31:27 +01:00
Timo Smit
3954583bc5 Fixed in-memory database not being detected (refs #46) 2017-02-08 22:51:12 +01:00
Timo Smit
77eaec7ef9 Removed unused parameter 2017-02-08 21:11:11 +01:00
Timo Smit
11c75c5738 Updated cvars.cfg to reflect rename limit changes 2017-02-08 18:20:04 +01:00
Timo Smit
4a80ab729b Fixed rename limit (refs #46)
* moved name change detection to players module
* rename limit now kicks instead of name forcing
* rename limit now actually calculates over past minute (approximately)
* removed g_renameInterval, obsolete
2017-02-08 18:18:51 +01:00
Timo Smit
d7d5565355 Remove player data on disconnect 2017-02-08 16:23:36 +01:00
Timo Smit
68688385a0 Sanitizing client input (refs #67) 2017-02-08 14:48:56 +01:00
Timo Smit
56d822b417 Added more levels to bot difficulties consistent with omnibot's own naming (refs #77) 2017-02-08 14:32:00 +01:00
Timo Smit
416b3bbbfc Fixed poll results on legacy (refs #46) 2017-02-08 14:05:54 +01:00
Timo Smit
291b109c06 Cleaned up files module 2017-02-07 23:10:02 +01:00
Timo Smit
0105d181ab Allow support for Legacy's in-memory database 2017-02-07 20:11:18 +01:00
Timo Smit
bc2aebe671 Load sprees from g_fileSprees and added default sounds to the sprees 2017-02-07 20:00:31 +01:00
Timo Smit
95ab757cdc Removed tags from .wav files 2017-02-07 17:38:56 +01:00
Timo Smit
a3e6241081 Fix C&P error in 2c848f0 2017-02-07 15:09:58 +01:00
Timo Smit
2c848f0237 Added cointoss role to SQL script 2017-02-07 10:46:33 +01:00
Timo Smit
e473bae2f1 Added !spec999 and !cointoss command (refs #62) 2017-02-06 18:10:39 +01:00
Timo Smit
e3345faa90 Added sound to !warn command (refs #62) 2017-02-06 17:51:10 +01:00
Timo Smit
b81894db87 Added more info to !finger and readconfig on standalone (refs #62) 2017-02-06 17:50:44 +01:00
Timo Smit
2d2e64ea2b Added spree and PM sounds to the pk3 (refs #61) 2017-02-06 16:25:12 +01:00
Timo Smit
a22859dd3d Added spree and PM sounds to the pk3 (refs #61) 2017-02-06 11:07:24 +01:00
Timo Smit
4253955dbb Performance improvement for SQLite3 databases 2017-02-05 14:46:26 +01:00
Timo Smit
4149d3163b Bumped version to 1.1.1-dev 2017-02-04 19:03:52 +01:00
Timo Smit
218dce31b8 Added possibility to disable database system 2017-02-04 19:02:08 +01:00
Timo Smit
7484421845 Also fixed pagination for negative offsets (refs #54) 2017-02-04 18:54:26 +01:00
Timo Smit
f17df67a9b Fixed paginated lists returning too many results (refs #54) 2017-02-04 18:54:19 +01:00
Timo Smit
1fe77fdaa4 Also fixed pagination for negative offsets (refs #54) 2017-02-04 14:20:18 +01:00
Timo Smit
e962fde32e Fixed config files needed to finish with two trailing newlines 2017-02-03 13:38:01 +01:00
Timo Smit
70417c1298 Fixed paginated lists returning too many results (refs #54) 2017-02-03 11:07:36 +01:00
Timo Smit
6380068889 Removed instructions of GPL (not needed) 2017-02-02 16:39:19 +01:00
Timo Smit
f619805f40 Merge branch 'master' into develop/1.2.0 2017-02-02 16:35:08 +01:00
Timo Smit
c9060064de Fixed README website links 2017-02-02 16:33:52 +01:00
Timo Smit
5840c0a1f8 Fixed setlevel in add-on mode returning error caused by 329eb3a 2017-02-02 16:27:28 +01:00
Timo Smit
acf0b698e7 Merge branch 'master' into develop/1.2.0
# Conflicts:
#	luamods/wolfadmin/main.lua
2017-02-01 17:37:33 +01:00
Timo Smit
a5067afd67 Implemented kill and death spree in standalone mode (refs #61)
* messages can be disabled per-type through g_spreeMessages
* records can be disabled through g_spreeRecords
2017-02-01 17:35:34 +01:00
Timo Smit
179ac058cb Fixed next map displaying on intermission even though it's unknown 2017-02-01 17:33:03 +01:00
Timo Smit
891a91fdf1 Replaced g_warnHistory with g_playerHistory and added possibility to disable history (refs #55) 2017-02-01 17:31:09 +01:00
Timo Smit
329eb3afc7 Fixed possibility to setlevel higher than current level 2017-02-01 14:33:33 +01:00
Timo Smit
cf959be65d Updated version 2017-01-30 17:39:20 +01:00
Timo Smit
aeb43f991b Updated installation instructions for SQLite3 (fixes #70) 2017-01-30 17:35:45 +01:00
Timo Smit
7ddde82e8d Merge branch 'develop/1.2.0' of github.com:rmarquis/wolfadmin into develop/1.2.0 2017-01-30 11:27:25 +01:00
Timo Smit
074999037a Aligned (team) damage in !stats 2017-01-30 11:25:09 +01:00
Remy Marquis
dc066b7fba expanded stats for Legacy mod
For Legacy mod only
* added damage recvd / team damage recvd
* added gibs stats
* added deaths and gibs percentage
* renamed suicide to selfkill (accidental kill)
* do not compute K/D ratio
2017-01-30 02:26:42 +01:00
Timo Smit
31c4bce960 Fixed minor typo in 2639986 2017-01-29 18:55:58 +01:00
Timo Smit
263998681e Fixed 'console:' prefix on legacymod (fixes #66) 2017-01-29 18:52:08 +01:00
Timo Smit
f7f3a5c724 Fixed PM being visible in-chat 2017-01-29 13:00:32 +01:00
Timo Smit
d58a228ed2 Fixed 'console:' prefix on legacymod (fixes #66) 2017-01-28 17:24:19 +01:00
Timo Smit
531b156cd7 Removed server logging (issue #65) 2017-01-28 16:17:25 +01:00
Timo Smit
539be1ee7b Updated modules in main 2017-01-28 15:49:24 +01:00
Timo Smit
72f5b32cd2 Added logging module and log chat (issue #65) 2017-01-28 15:24:34 +01:00
Timo Smit
f2458bb3a5 Removed debug output for opening files which might spam server console 2017-01-28 15:23:32 +01:00
Timo Smit
ad7b7c64e3 Commands now make use of lua's ellipsis instead of cmdArguments (refs #62) 2017-01-26 19:16:40 +01:00
Timo Smit
5df8c2874f Fixed nil entity error 2017-01-22 12:32:17 +01:00
Timo Smit
f39284074b Fixed missing dependencies 2017-01-22 11:34:11 +01:00
Timo Smit
04c78f0886 Fixed !stats command on legacymod (refs #46) 2017-01-21 18:04:31 +01:00
Timo Smit
3231ea6c74 Implemented /pm and /r for legacymod (refs #46) 2017-01-21 17:34:36 +01:00
Timo Smit
99817beb31 Fixed missing dependency 2017-01-21 17:28:02 +01:00
Timo Smit
9fdd36e772 Reworked some commands to disable them when in standalone mode (refs #61, #62) 2017-01-21 17:11:32 +01:00
Timo Smit
7e5c009484 Updated SQLite script with more levels and roles (refs #62, #69)
* also added transactions to improve performance
2017-01-21 16:06:25 +01:00
Timo Smit
f0618d8274 Removed unused variable from server commands (refs #75) 2017-01-21 15:30:03 +01:00
Timo Smit
75a19dfcc2 Fixed admin chat not working 2017-01-21 15:10:49 +01:00
Timo Smit
1ca7070646 Fixed acl command calling error function 2017-01-21 14:51:13 +01:00
Timo Smit
0531d27220 Fixed unknown client on several commands
* legacy returns nil instead of -1 for et.ClientNumberFromString()
2017-01-21 14:36:57 +01:00
Timo Smit
7dce37972b Sanitize command input (fixes #67) 2017-01-21 14:32:48 +01:00
Timo Smit
449e6c856f Fixed minor issues on several commands
* gib now by correct attacker (world entity)
* listlevels should not read shrubbot in standalone mode
2017-01-21 14:29:29 +01:00
Timo Smit
839036eb23 Fixed minor SQLite issue
* replace escape with tonumber for an integer value
2017-01-21 12:22:09 +01:00
Timo Smit
e36d70aefa Fixed minor rename issue caused by 9012d54da4 (refs #69, #75) 2017-01-21 12:19:07 +01:00
Timo Smit
9012d54da4 Misc auth improvements (refs #69, #75)
* renamed methods to camelCase
* renamed methods to be more precise
* auth.isPlayerAllowed now returns boolean values
2017-01-21 12:16:26 +01:00
Timo Smit
004ebea736 Reworked commands.lua
* improved documentation
* removed default W:ET client commands, moved to separate files
2017-01-21 11:57:14 +01:00
Timo Smit
86a427964d Fixed logging (refs #65) and improved logging format in standalone mode 2017-01-21 10:43:39 +01:00
Timo Smit
702ed2748d Added acl command for server console (refs #62, #69) 2017-01-20 19:53:55 +01:00
Timo Smit
a2808f3130 Removed levelTime from main 2017-01-18 19:03:47 +01:00
Timo Smit
cd4bf52aea Dynamic loading of modules (fixes #71) 2017-01-18 15:52:25 +01:00
Timo Smit
7a93c4bfc9 Improved directory structure (fixes #72) and added pk3 contents to repo 2017-01-18 14:49:48 +01:00
Timo Smit
4ae1421f0b Merge branch 'develop/1.1.0' into develop/1.2.0
# Conflicts:
#	luascripts/commands/admin/listaliases.lua
#	luascripts/commands/admin/listlevels.lua
#	luascripts/commands/admin/plock.lua
#	luascripts/commands/admin/punlock.lua
#	luascripts/commands/admin/setlevel.lua
#	luascripts/commands/admin/showhistory.lua
#	luascripts/commands/admin/stats.lua
#	luascripts/commands/admin/vmute.lua
#	luascripts/commands/admin/vunmute.lua
#	luascripts/commands/admin/warn.lua
2017-01-17 20:20:53 +01:00
Timo Smit
9eee8e8564 Fixed minor bugs caused by sanitizing (refs #67) 2017-01-17 20:12:00 +01:00
Timo Smit
c261a10c9f Added getHomePath() function, move SQLite database to homepath 2017-01-17 19:26:56 +01:00
Timo Smit
dcb2859378 Fixed minor bugs 2017-01-17 12:02:03 +01:00
Timo Smit
87ece57322 Fixed inconsistency between database and script 2017-01-16 23:09:19 +01:00
Timo Smit
c0d2aa0e92 Sanitizing some client input (fixes #67) 2017-01-16 19:49:00 +01:00
Timo Smit
f54e5aec36 Fixed inconsistency 2017-01-16 18:02:50 +01:00
Timo Smit
44c10910e1 Fixed more inconcistencies between database script + lua script 2017-01-16 17:45:40 +01:00
Timo Smit
7620862fc1 Fixed undefined player issue at connection 2017-01-16 17:36:57 +01:00
Timo Smit
0001bc7a12 Fixed wrongly named column 2017-01-16 17:34:06 +01:00
Timo Smit
2d4191f03f Minor bugfixes regarding new players 2017-01-15 12:27:18 +01:00
Timo Smit
9d4aaa7a62 Revert "PRIMARY KEY consistency"
This reverts commit c7319028b6.
2017-01-15 11:51:19 +01:00
Timo Smit
c7319028b6 PRIMARY KEY consistency 2017-01-14 15:15:36 +01:00
Timo Smit
c9889d4598 Load mutes from database and apply to online players (issue #55) 2017-01-14 15:14:43 +01:00
Timo Smit
f8ec599932 Fixed missing module 2017-01-14 14:41:48 +01:00
Timo Smit
3252c6a563 Implemented team locking (issue #62) 2017-01-14 14:30:39 +01:00
Timo Smit
039855b4d0 Fixed module loading 2017-01-13 20:12:46 +01:00
Timo Smit
8977ba41cb Implemented basic ACL functionality (issue #69) 2017-01-13 18:59:14 +01:00
Timo Smit
958b2de6f9 Version 1.1.0-beta to 1.2.0-dev 2017-01-13 14:34:46 +01:00
Timo Smit
b2a5fb53fe SQLite update
Contains update for new level setup
2017-01-12 21:12:23 +01:00
Timo Smit
a9004cdb21 SQLite script update (issue #55)
Contains create statements for mute, bans and history.
2017-01-12 21:08:07 +01:00
Timo Smit
f8cbba943f Advanced player punishments (issue #55)
Warns, mutes and bans are stored in the database. A history is available through !showhistory [player] and !showwarns has been merged into this.
2017-01-12 18:26:45 +01:00
Timo Smit
f0af3cfe03 Fixed util.getTimeFromString returning unnecessary floating point 2017-01-12 13:54:02 +01:00
Timo Smit
a14f5f1b32 Copyright update 2017-01-04 10:38:25 +01:00
Timo Smit
2e26cbc257 Fixed !finger command executing on wrong client 2016-12-15 16:26:39 +01:00
Timo Smit
74b9490433 Fixed possible floating point error in command logging 2016-11-30 14:20:43 +01:00
Timo Smit
2275d4830f Fixed console id in command logging 2016-11-30 14:20:04 +01:00
Timo Smit
d33beade2b Fixed name retrieval of console id 2016-11-30 14:18:45 +01:00
Timo Smit
0c3f0d84ee Fixed wrong client id being logged as warn invoker 2016-11-30 14:17:27 +01:00
Timo Smit
4145dd87ba Removed dependencies on stats module (issue #63) 2016-11-15 14:41:47 +01:00
Timo Smit
02dd69efea Reworked sprees module so it doesn't make use of stats anymore (issue #63) 2016-11-15 14:33:58 +01:00
Timo Smit
de294b23d6 Fix for console GUID 2016-11-15 14:20:04 +01:00
Timo Smit
c3cb849eb1 Fixed more uninitialized variables 2016-11-15 14:05:13 +01:00
Timo Smit
01e60a5055 Fixed uninitialized variable 2016-11-15 13:58:36 +01:00
Timo Smit
d3449f847b Fixed missing module 2016-11-15 13:25:06 +01:00
Timo Smit
2fa0815a97 Removed unused table 2016-11-14 17:01:20 +01:00
Timo Smit
6facbf0a7d Further commented out rename limiter 2016-11-14 16:55:57 +01:00
Timo Smit
d43e8adaaf Fixed !listplayers 2016-11-14 16:32:38 +01:00
Timo Smit
f947e8567b Fixed missing module 2016-11-14 16:32:23 +01:00
Timo Smit
0fffcca1c2 We actually have an event for team changes now, so move spree handling out of commands.lua 2016-09-07 20:23:36 +02:00
Timo Smit
7f5a18b779 Disabled rename limit for the moment 2016-09-07 20:19:58 +02:00
Timo Smit
f5bd2d0f23 Fixed missing include 2016-09-07 20:07:52 +02:00
Timo Smit
c272eb67fe Misc rewriting to make use of players module instead of stats 2016-09-07 20:06:07 +02:00
Timo Smit
7befbbf9aa Only activate mute commands in standalone mode 2016-09-07 18:54:28 +02:00
Timo Smit
03b18f9c0a (Re-)implemented muting and player locking 2016-09-07 18:52:48 +02:00
Timo Smit
5ea4fc90e4 Seperated players and stats module 2016-09-06 12:41:02 +02:00
Timo Smit
f2667e558f Fixed GUID protection (stats not set in onConnectAttempt) 2016-09-06 11:17:05 +02:00
Timo Smit
b3573b231c Fixed player info not being updated on first connect (now correctly handle new players as well) 2016-09-05 08:17:08 +02:00
Timo Smit
98e8f6d341 Fixed player info not being updated on first connect 2016-09-05 08:13:16 +02:00
Timo Smit
c0e1974893 Integrated ACL/auth into level commands 2016-09-04 22:55:50 +02:00
Timo Smit
dd5f3ac175 Merge branch 'feature/standalone' into develop/1.2.0
Conflicts:
	luascripts/commands/admin/help.lua
2016-09-04 22:40:42 +02:00
Timo Smit
1f89591410 Merge branch 'feature/auth' into develop/1.2.0
Conflicts:
	luascripts/commands/admin/help.lua
2016-09-04 22:36:34 +02:00
Timo Smit
e745fe4c2c Implemented setting player level (issue #61, #62) 2016-09-04 22:28:57 +02:00
Timo Smit
e993fcc89e Fixed listings returning 'duplicate' rows (caused by references) 2016-09-04 22:05:03 +02:00
Timo Smit
73d66589e7 Level history is now stored in player_level 2016-09-04 21:48:03 +02:00
Timo Smit
de9e7b50fe Implemented retrieval of player levels from database 2016-09-04 19:58:34 +02:00
Timo Smit
4ce4ee9b9b Seperated some more functionality from admin/player module 2016-09-04 18:31:17 +02:00
Timo Smit
913545af00 Removed some upgrade stuff for pre-1.0.0 (old rows will be deleted) 2016-09-04 18:22:26 +02:00
Timo Smit
441e4cf7bb Decoupled player handling from admin and stats module (issue #63) 2016-09-04 10:20:21 +02:00
Timo Smit
06d4413b02 Replaced last occurrences of shrubbot calls with auth module 2016-09-02 14:52:34 +02:00
Timo Smit
e33b9480c9 Removed permission for debug output
Debug output is already controlled via a CVAR and including the 'auth' module would create more dependencies in debug.lua (unwanted)
2016-09-02 14:06:33 +02:00
Timo Smit
f9b73ed8d6 Added some more match/team management commands (issue #62) 2016-09-01 18:05:38 +02:00
Timo Smit
0aa330ad1b Added some missing permissions (slap, listmaps) 2016-09-01 17:48:15 +02:00
Timo Smit
b8b4abdfb1 Implemented shuffle command 2016-09-01 17:43:47 +02:00
Timo Smit
0d5a4d0adf Implemented a first basic set of commands (issue #62) 2016-09-01 16:13:35 +02:00
Timo Smit
9b9836d40b Added some missing permissions (slap, listmaps) 2016-09-01 15:00:08 +02:00
Timo Smit
793db53aa2 Merge branch 'feature/auth' into feature/standalone 2016-08-29 23:52:48 +02:00
Timo Smit
7babdb893b Return a temp value for ACL levels 2016-08-29 23:49:54 +02:00
Timo Smit
6a6ba42d7c Merge branch 'feature/auth' into feature/standalone 2016-08-29 23:43:34 +02:00
Timo Smit
dfa2533d7b Added stub function to retrieve a player's level 2016-08-29 23:41:51 +02:00
Timo Smit
a02f933722 Merge branch 'feature/auth' into feature/standalone
Conflicts:
	luascripts/commands/admin/help.lua
2016-08-29 22:22:37 +02:00
Timo Smit
0640c4bc3b Removed some NQ and shrubbot-specific things 2016-08-29 22:18:20 +02:00
Timo Smit
5c9e93f62a Created foundation for new ACL system 2016-08-29 22:00:11 +02:00
Timo Smit
0cbdf407cb Added setting to switch to standalone mode 2016-08-29 21:54:15 +02:00
Timo Smit
32bd456fa7 Merge branch 'feature/lua5.3' into develop/1.2.0 2016-08-29 16:03:27 +02:00
Timo Smit
88cf6c1d70 Fixed Lua 5.2+ errors with backwards compatibility 2016-08-29 13:27:19 +02:00
Timo Smit
6e4b5b97a7 Fixed unknown database type error (sqlite3 default) 2016-08-29 13:22:15 +02:00
Timo Smit
e8a226cb53 Updated version 2016-08-26 10:19:01 +02:00
Timo Smit
85ac4e8d84 Updated docs 2016-08-26 10:15:50 +02:00
Timo Smit
730db32608 Renamed MySQL database scripts for consistency 2016-08-26 10:04:28 +02:00
Timo Smit
c2f5867ca9 Remove obsolete sprees.cfg 2016-08-26 10:02:29 +02:00
Timo Smit
32bf814562 Removed pre-1.0.2 update scripts 2016-08-07 19:10:47 +02:00
Timo Smit
c9c971bc30 Follow-up on bb67eb3 (removed cfg) 2016-08-07 19:09:53 +02:00
Timo Smit
ea90a08989 Use separate select statement instead of hardcoding database name 2016-08-07 19:09:08 +02:00
Timo Smit
bb67eb3f69 Removed cfg system and added checks for database availability/connectivity (issue #59) 2016-08-07 18:55:26 +02:00
Timo Smit
1be2b0f2eb Also set sqlite as default in settings.lua 2016-08-06 20:17:36 +02:00
Timo Smit
ef8d478cf9 Added SQLite support (issue #23) 2016-08-05 22:15:58 +02:00
Timo Smit
0529afb7ff Fix for latest luasql version 2016-08-04 20:11:09 +02:00
Timo Smit
00c487a6ef Added !balance options to enable/disable balancer, !putbots auto-disables balancer as needed. 2016-08-04 19:14:00 +02:00
Timo Smit
2524a1be9e Avoid objective carrier being balanced to the other team (issue #37) 2016-08-04 18:37:53 +02:00
Timo Smit
fc88fcfc4b Fix syntax help for !p(un)lock (issue #56) 2016-03-16 22:46:23 +01:00
Timo Smit
7445e7b173 Implemented pagination for !showbans, !listlevels and !listaliases (issue #54) 2016-03-09 18:21:28 +01:00
Timo Smit
f286ab78bc Reordered MySQL module + added comments to increase readability 2016-03-09 14:46:44 +01:00
Timo Smit
dad2ead47c Fixes for new naming of SQL columns 2016-03-09 11:46:25 +01:00
Timo Smit
057c37d7e7 Updated database column names to match new SQL column naming 2016-03-09 11:39:32 +01:00
Timo Smit
3c60513190 Updated SQL module to match new database table naming 2016-03-09 11:36:05 +01:00
Timo Smit
5de6be4e12 Renamed database tables/indexes/keys to increase consistency 2016-03-09 11:32:57 +01:00
Timo Smit
cb3e80b49f Added notification sound for /ac (issue #53) 2016-02-25 12:50:13 +01:00
Timo Smit
6a76718c01 Added notification sound for /r + now also displayed for sender (issue #52) 2016-02-25 12:49:49 +01:00
Timo Smit
356e6951ce Fixed minor issue with colouring of balancer message 2016-02-25 12:36:22 +01:00
Timo Smit
5e6b336139 Implemented more advanced balancing functions (issue #37)
TODO: check objective carrier
2016-02-24 11:49:00 +01:00
Timo Smit
b69b58005d Added temporary utility bits module for checking bit flags 2016-02-24 11:48:02 +01:00
Timo Smit
a1910edb28 Added tracking of teams in teams module 2016-02-24 11:46:58 +01:00
Timo Smit
9ab81bd4ac Fixed health display in !stats 2016-02-24 11:38:32 +01:00
Timo Smit
72fd6f5d32 Fixed removing/cancelling timers not working correctly 2016-02-23 17:32:52 +01:00
Timo Smit
27c62df026 Added tracking of team locks (needed for issue #37) 2016-02-22 10:28:43 +01:00
Timo Smit
abf57e2469 Fixed player locks making use of admin.lockPlayer and admin.unlockPlayer 2016-02-22 10:01:52 +01:00
Timo Smit
0764a16046 fixed missing include for util 2016-02-19 12:27:25 +01:00
Timo Smit
54ec0621ef added client commands from chat (issue #47) 2016-02-19 10:45:13 +01:00
Timo Smit
1adeb63acf cleaned client command handler 2016-02-19 10:44:59 +01:00
Timo Smit
eabf1a5fbb move server and client commands out of commands.lua (issue #51) 2016-02-18 20:45:45 +01:00
Timo Smit
ae8ae5a417 load client and server commands dynamically (issue #51) 2016-02-18 19:42:17 +01:00
Timo Smit
f883b92292 updated copyright 2016-02-16 14:10:00 +01:00
Timo Smit
72f31282ca 1.0.2 2016-02-16 12:55:13 +01:00
Timo Smit
7e9009ab17 fix unknown command when map starts and show message when player is disconnected (issue #49) 2016-02-16 12:52:34 +01:00
Timo Smit
b2e68bd99c fix sprees not being shown/updated (issue #50) 2016-02-16 12:36:01 +01:00
Timo Smit
776695b074 fixed README 2016-02-13 12:47:40 +01:00
Timo Smit
a9684b26f3 fixed README 2016-02-13 12:46:50 +01:00
Timo Smit
cc91bb480c moved documentation and added GitHub README 2016-02-13 12:44:14 +01:00
Timo Smit
63d66463d7 fixed cfg database calling for mysql function (issue #45) 2016-02-13 12:22:24 +01:00
Timo Smit
5dcc5d2a82 1.0.1 2016-02-13 12:20:14 +01:00
165 changed files with 10956 additions and 3109 deletions

68
INSTALL
View file

@ -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
View 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>.

View file

@ -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
View 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!"

View file

@ -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

View file

@ -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
View file

@ -0,0 +1,7 @@
[[level]]
level = 0
greeting = "Welcome ^7[N]^9!"
[[user]]
guid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
greeting = "Welcome the console!"

View file

@ -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
View 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!"

View file

View file

@ -1,8 +0,0 @@
[db]
type = mysql
hostname = localhost
port = 3306
database = wolfadmin
username = wolfadmin
password = suchasecret

59
config/wolfadmin.toml Normal file
View 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
View 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
View 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;

View file

@ -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);

View file

@ -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);

View file

@ -1,2 +0,0 @@
ALTER TABLE `wolfadmin`.`aliases`
ADD COLUMN `cleanalias` VARCHAR(128) NOT NULL AFTER `alias`;

View file

@ -0,0 +1,2 @@
-- rename 'incognito' permission to 'noaka'
UPDATE `player_permission` SET `permission`='noaka' WHERE `permission`='incognito';

View 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
View 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
View 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
View 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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)")

View file

@ -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")

View file

@ -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]")

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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")

View file

@ -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]")

View file

@ -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]")

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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))

View 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"))

View 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))

View 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")

View file

@ -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")

View 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))

View 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))

View file

@ -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")

View file

@ -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))

View 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)")

View 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))

View file

@ -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")

View file

@ -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)")

View file

@ -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")

View 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))

View 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))

View 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))

View file

@ -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")

View 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)")

View 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))

View 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))

View file

@ -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]")

View file

@ -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]")

View 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))

View 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]")

View 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))

View 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))

View 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))

View 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))

View file

@ -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)")

View 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))

View 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))

View 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))

View 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))

View 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))

View 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))

View 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]")

View 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))

View 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))

View 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))

View 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))

View 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