Killing Floor 2

Killing Floor 2

94 个评价
KF2 Magicked Admin - Dedicated Server Tool [0.1.5]
由 Stephen 和其他 2 人合作完成
Scripted management, statistics, and bot for ranked Killing Floor 2 servers. Provides in-game commands, player stat tracking and ranking, live welcome screen scoreboard and stats, greeter, and admin functions. Running entirely through the web admin, it does not affect a server's ranked/custom status. It can be ran either directly on the server or remotely, and manage multiple servers at once.
  • Present real-time leaderboards in your welcome screen and in-game chat
  • Record player statistics including: kills, dosh, deaths and play time
  • A variety of in-game administrative commands
  • A variety of in-game commands for players
  • Automatically issue commands based on: time, wave, joins, or trader state
  • Read player messages from your desktop
https://kf2-ma.th3-z.xyz/

Notes
  • KF2 Magicked Admin will not alter the servers ranked or custom status.
  • KF2 Magicked Admin works with weekly, survival, and endless game modes.
  • KF2 Magicked Admin can manage multiple servers in a single instance

If you have any feedback for KF2 Magicked Administrator, or this guide, let me know.
Please rate and favourite the guide if you found it useful.

If you need some help anywhere, add me on steam, and I will do my best to help you.

Thanks.
2
   
奖励
收藏
已收藏
取消收藏
Downloads
The latest version as of writing is '0.1.5', released on the 25th of October 2019. A Windows executable is provided for this release here[github.com].

For Linux and Mac OS it is recommended to run the program from Python sources since you likely already have it installed. The source for '0.1.5' is available here[github.com]. You just need to install the requirements with 'pip3 install -r requirements.txt' and run it with 'python3 -O magicked_admin/magicked_admin.py'.

Development versions and build instructions are available on GitHub here[github.com].

Note: If you want to use Magicked Admin on an endless or weekly mode server there is an extra step that you have to do which I talk about in the "Endless and weekly game mode support" section.

Running
  1. Extract 'kf2-magicked-admin-0.1.5.zip' anywhere you like.

  2. Double click the executable file

  3. You will be guided through the first time setup

    Note: If you want to re-run the first time setup, just delete the file 'conf/magicked_admin.conf'

Running with Docker

A Docker image is also available. Running with docker is easy, just issue the following command.
docker run -it -p 1880:1880 --name kf2-magicked-admin -v '<host config folder location>':'/magicked_admin/conf' th3z/kf2-magicked-admin

You will need to change '<host config folder location>' to wherever you want to store your config folder. '/mnt/user/appdata/kf2-magicked-admin' is a popular choice for systems running Unraid.

After this command runs the container will exit out and the logs will tell you to setup the config file. Go to your 'conf' folder and set things up, then run the container again and you are good to go!
Commands
In the following sections I will describe all the commands. However there are some general things to note that apply to them all.

When inputting commands into the chat they need to be prefixed with '!'. When writing commands into a script, or chaining them the '!' should be omitted.

Many commands will look for closest matches to their parameters. For example 'biotics' will match 'kf-biotics-lab' and 'userO' will match 'userOne™/@:®'.

All commands have in-game help text that can be accessed with the '-h' flag.
  • Example: '!commands -h'
All commands also have the following flags.
  • Option '-q': Suppresses output
  • Option '-p': Pads output to hide the username line
Escape sequences as follows are available to format messages.
  • '\n' - Newline
    - Example: '!say line 0 \n line 1'
  • '\t' - Tab
    - Example: '!say line 0 \n\t line 1 is indented 1 tabstop'
Player commands
These commands can be executed by any player. As of writing there are 18 player commands available.
  • '!commands' - Shows a list of all commands available to players

  • '!stats <user>' - Shows general statistics about a user
    - Example: '!stats' Shows stats about yourself
    - Example: '!stats the_z' Shows stats about the_z

  • '!kills <user>' - Shows kill statistics about a user
    - Example: '!kills' Shows kill stats about yourself
    - Example: '!kills the_z' Shows kill stats about the_z

  • '!dosh <user>' - Shows dosh statistics about a user
    - Example: '!dosh' Shows dosh stats about yourself
    - Example: '!dosh the_z' Shows dosh stats about the_z

  • '!map' - Shows statistics about the current map

  • '!record_wave' - Shows the highest wave achieved on the current map

  • '!top_kills' - Shows the global kills leaderboard

  • '!top_dosh' - Shows the global dosh leaderboard

  • '!top_time' - Shows the global play time leaderboard

  • '!top_wave_kills' - Shows information about who killed the most ZEDs in the current wave. Generally for use with '!start_trc'
    - Example: '!start_trc top_wave_kills'

  • '!top_wave_dosh' - Shows information about who earned the most dosh in the current wave. Generally for use with '!start_trc'
    - Example: '!start_trc top_wave_dosh'

  • '!server_kills' - Shows total kills on the server

  • '!server_dosh' - Shows total dosh earned on the server

  • '!scoreboard' - Shows the complete player scoreboard, useful on servers with >6 max players
    - Alias '!sb': Does the same

  • '!game' - Shows information about the current game

  • '!maps' - Shows the current map cycle
    - Option '-a': Shows all available maps
    - Example: '!maps -a'

  • '!player_count' - Shows the player count and max players
Administrator commands
Commands that can be ran by server administrators, and users authorized with the '!op' command. As of writing there are 24 administrator commands available.
  • '!op <user>' - Gives a user administrative rights, persists until '!deop <user>' is used.
    - Example: '!op the_z'

  • '!deop <user>' - Revokes a user's administrative rights
    - Example: '!deop the_z'

  • '!say <message>' - Echoes a message into chat
    - Example: '!say The quick brown fox jumps over the lazy dog'
    - Example: '!start_trc say The trader is open'

  • '!players' - Shows detailed information about players on the server

  • '!kick <user>' - Kicks '<user>' from the match
    - Example: '!kick the_z'

  • '!ban <user>' - Bans '<user>' from the server
    - Example: '!ban the_z'
    - Warning: The web admin currently has a bug that causes bans to persist after they are deleted, thus there is no unban command

  • '!length <length>' - Change the length to '<length>' next game
    - Example: '!length short'

  • '!difficulty <difficulty>' - Change the difficulty to '<difficulty>' next game
    - Example: '!difficulty hell'

  • '!game_mode <game_mode>' - Immediately change the game mode to '<game_mode>'
    - Example: '!game_mode endless' Changes the game mode to Endless

  • '!load_map <map>' - Immediately change the map to '<map>'
    - Example: '!load_map biotics' Changes the map to Biotics Lab

  • '!restart' - Immediately restart the current game

  • '!password [--set] <on|off>'
    - Example: '!password on' Enables the game password defined in the config
    - Example: '!password off' Disables the game password
    - Example: '!password --set superSekritPass' Sets a specific password

  • '!start_jc -- <command>' - Start a command that runs every time a player joins
    - Example: '!start_jc -- say Welcome %PLR' - Greets a player on join
    - Available tokens: '%PLR' - username, '%KLL' - total kills, '%DSH' - total dosh, '%BCK' - "back" if sessions > 1, '%DRK' - dosh rank, '%KRK' - kill rank, '%TME' - play time, '%TRK' - play time rank, '%SES' - sessions

  • '!stop_jc' - Stops all join commands

  • '!start_wc [-w <wave>] -- <command>' - Start a command that runs on wave '<wave>'
    - Option '-w': Wave to run the command on, can be omitted to have the command
    run every wave
    - Option '-w': Can be negative to count backwards from the boss wave
    - Example: '!start_wc -1 -- say Welcome to the boss wave'

  • '!stop_wc' - Stops all wave commands

  • '!start_tc [-r, -t <seconds>] -- <command>' - Start a command that runs after
    '<seconds>' seconds
    - Option '-r': Add to have the command run repeatedly
    - Option '-t': Required, the number of seconds before the command runs
    - Example: '!start_tc -rt 600 -- say Join our Steam group!\n http://steam.group/'

  • '!stop_tc' - Stops all timed commands

  • '!start_trc [-w <wave>] -- <command>' - Start a commands that runs when the trader opens
    - Option '-w': Wave to run the command on, can be omitted to have the command run every wave
    - Option '-w': Can be negative to count backwards from the boss wave
    - Example: '!start_trc -- top_wave_dosh' - Shows who earned the most dosh every wave when the trader opens

  • '!stop_trc' - Stop all commands that run on trader open

  • '!silent' - Toggles suppression of all chat output, commands still have effect, but the response will not be visible to players

  • '!run <script_name>' - Executes a script from the 'conf/scripts' folder, more information in the scripts section
    - Example: '!run example'

  • '!marquee <marquee_name>' - Runs a marquee in the chat from the 'conf/marquee' folder, experimental
    - Example: '!marquee example'

  • '!enforce_dosh <amount>' - Kicks all players that have more dosh than the specified amount.
    - Example: '!start_tc 600 -- enforce_dosh 60000'

  • '!update_motd <type>' - Refreshes the welcome screen leaderboard, type is one of: kills, dosh, or time
    - Example: '!start_tc 300 -- update_motd kills'

  • '!reload_motd' - Reloads the server's '*.motd' file from 'conf'
Welcome screen leaderboards
Writing a 'conf/server_name.motd' file containing pairs of '%PLR' and '%SCR' will allow you to render live leaderboard on the welcome screen.

A simple example could be as follows.
Welcome to our server. %SRV_K Zeds killed on this server. Top Players (total kills): 1. %PLR [%SCR] 2. %PLR [%SCR] 3. %PLR [%SCR] 4. %PLR [%SCR] 5. %PLR [%SCR] 6. %PLR [%SCR] 7. %PLR [%SCR] 8. %PLR [%SCR] 9. %PLR [%SCR] Have fun and good luck!

KF2 Magicked Admin will replace '%PLR' with the player's username, '%SCR' with the player's total kills or total dosh, '%SRV_K' with the global server kills, and '%SRV_D' with the global server dosh.

Once the file is written, use the '!update_motd <type>' command to refresh the leaderboard. This should be used in combination with '!start_tc <refresh_interval>' so that it is refreshed automatically.
- Example: '!start_tc 300 -- update_motd dosh'

The metric for '%SCR' can be either 'kills', 'time', or 'dosh'. This is can be set by changing the '<type>' parameter when using '!update_motd <type>'

Here is my survival suicidal welcome screen as an example of what can be achieved.




Notes
  • This will overwrite your existing motd.
  • '!reload_motd' Can be used to reload the template file while KF2 Magicked Admin is still running.
Scripts
KF2 Magicked Admin has some rudimentary scripting support which can be used to chain commands into a single action.

There are two categories of scripts, they differ in when and how they are executed.

  • Comments can be added to scripts by prefixing a line with ';'

Init scripts

Writing a 'server_name.init' in the 'conf/scripts' folder with a series of commands will run the commands in sequence when the bot starts on 'server_name'. The server names are defined in 'conf/magicked_admin.conf', if you haven't changed the name it will default to 'server_one'.

An example init file will have been generated on first launch, this can be used as a template for writing your own init scripts.

Run scripts

The '!run' command exists to facilitate the running of scripts at any time. These scripts should be placed in the 'conf/scripts' folder. An example script is already in the scripts folder, it can be ran with '!run example'.

These scripts are formatted much the same as the init script, the commands will be ran in sequence from top to bottom.

Notable examples

Some commands are particularly useful when used in scripts, these are: '!start_tc', '!start_trc', '!start_wc', '!start_jc', '!top_wave_kills', '!top_wave_dosh', '!enforce_dosh', '!say'.

'conf/scripts/server_one.init' - Show who earned the most dosh each wave when the trader opens, and update the welcome screen leaderboard every 5 minutes
start_trc -- top_wave_dosh start_tc 300 -- update_motd dosh

'conf/scripts/server_one.init' - Advertise your Steam group when the boss wave is reached
start_wc -w -1 -- say Join our steam group: http://our.steam/group

'conf/scripts/server_one.init' - Provide basic bot usage guidance to players
start_tc -rt 800 -- say I'm a bot, type !commands to see available commands

'conf/scripts/priv_game' - Setup a private lobby with a single command
silent -q password --set superSecretPassword difficulty hell length long load_map biotics silent -q

'conf/scripts/greeter' - Starts a player greeter
start_jc -q -- say \nWelcome %BCK %PLR.\nYou've killed %KLL ZEDs, (#%KRK)\nearned £%DSH (#%DRK) and\nplayed for %TME over %SES sessions. say Greeter started
Configuration options
Basic setup is done on the first run. However this is only to get you started, it does not cover all of the options KF2 Magicked Admin can offer. Please see the configuration file, 'conf/magicked_admin.conf', for more configuration options as some features are disabled by default.

Each server managed by KF2 Magicked Admin has a config section that looks something like '[server_one]', followed by several options ('x = y'). Copy the default server section and change the name if you want to manage multiple servers. '[server_one]' is the name of the server, this can be changed to whatever you want, but each section should have a unique name.

Options

The following options can be configured in the config file 'conf/magicked_admin.conf'.
  • 'address' - Web address of the server's web admin panel. Requires scheme and protocol
    - Example: 'address=https://0.0.0.0:8080'

  • 'username' - Web admin username to login with, this will appear in the chat when the bot has something to output. It's recommended to create a separate account for the bot.
    - Example: 'username=Admin'

  • 'password' - Web admin password that matches the username above.
    - Example: 'password=123'

  • 'game_password' - Default game password to set when the password is toggled using '!password <on|off>'.
    - Example: 'game_password=Hunter69'
Renaming the chatbot (multi-admin)
To rename your chatbot to something other than 'Admin' your server must be configured for multi-admin.

If your server already has multi-admin support all you need to do is create an account with the desired name and change the account credentials in 'conf/magicked_admin.conf'

The following covers the same setup as the official Tripwire documentation on this topic, which is available here[wiki.killingfloor2.com].
  1. Go to your server's config folder. 'KF2-Server\KFGame\Config\Config'.

  2. Open 'KFWebAdmin.ini' in your favourite editor, add the following under the '[WebAdmin.WebAdmin]' section, and save the file.
    AuthenticationClass=WebAdmin.MultiWebAdminAuth

  3. Now open your web admin panel and there should be a new 'Administrators' section in the sidebar.


  4. Click 'Administrators' and select 'Create Administrator'. Enter a name for the Chatbot (This is the name you will use to sign in with). Click OK.

  5. Give it a 'Display Name', 'Password', and enable the account (the display name is what players will see in chat).


  6. Leave 'Access Order' set to 'Deny/Allow', and don't add any 'Deny Patterns' or 'Allow Patterns'. If you have issues using your new account, this is a common culprit so please leave it as is.

  7. Click 'Save' and the account is ready for use.

  8. Update the account credentials in 'conf/magicked_admin.conf'
Endless and weekly game mode support
In game modes other than survival KF2 Magicked Admin will have a limited feature set due to differences in the web admin panel when in other modes. However the web admin panel can be altered to enable the full feature set.

For this reason a web admin patcher is available here[github.com].

Notes
To use this utility your server files in 'KF2Server/KFGame/Web/ServerAdmin' will have to be stock/clean. If you have edited these files I suggest the following alternatives.
  • Validate the server files with steamcmd with the command 'app_update 232130 validate' and use the patcher as normal.
  • Manually apply the diffs in 'admin-patcher/patches' to your server files.

Usage (GUI/Desktop)
  1. Run the executable
  2. Open the location where your server is installed in the destination selection window
  3. Click 'open'

Usage (Headless/Server)
  • Run the executable with a target flag, e.g. './magicked_admin.exe --target /path/to/kf2/server'
  • Check the console window for any issues
Configuring multiple servers
KF2 Magicked Admin can work with any amount of servers you run.

To configure more servers, find 'conf/magicked_admin.conf', and open it in your favourite editor.

Copy the whole '[server_one]' section, and paste it at the end of the file. Update the 'address', 'username', and 'password' options.

Below is an example.
[server_one] game_password = 123 address = http://127.0.0.1:8080 username = Admin password = root [server_two] game_password = Hunter69 address = http://127.0.0.1:8081 username = Admin password = 123

You can do this for as many servers as you want.
Renaming servers
If you have a few servers, you might want to name them so you can easily identify them.

You first need to open 'conf/magicked_admin.conf' and here you can change 'server_one' to anything you want.

You then need to go back and change 'server_one.motd' and 'server_one.init' to the name you just set it to in 'conf/magicked_admin.conf'.
Resetting stats
To reset the scoreboard all you have to do is delete the 'conf/*.sqlite' file associated with the server name, a new one will be created the next time you start KF2 Magicked Admin.

If I wanted to reset the stats on 'server_four', I would delete the 'conf/server_four.sqlite' file and restart KF2 Magicked Admin.
Planned features
Next release - 0.1.6
The following features are currently slated for the next release.
  • Command aliasing
  • Lua scripting

There is an ongoing translation effort, if you know a language other than English you can contribute on Crowdin[crowdin.com].

We are accepting feature requests on the issue tracker[github.com].
Bugs
  • Issue with '!difficulty' and '!length' reliability. This is caused by an issue in the web admin panel, it will forget changes to these after certain other changes are made.
    - Workaround, use '!restart' immediately after them.

If you find a bug, please add it to the issue tracker[github.com]if you have a GitHub account.

If you don't have a GitHub account you can write it in the comments or message me on Steam.
Credits
KF2 Magicked Admin is open source software (MIT), authored by the_z (th3-z).
For full source code (Python+SQLite) and developer guidance visit the GitHub repository.[github.com]

Contributors

Developers:
Testers:
Translators:

Contributions are welcome.
84 条留言
N0FeaR † 2023 年 11 月 5 日 上午 9:15 
I cannot seem to get the player kills/dosh to update on a leaderboard. The names appear, but each person's name has (0) next to it. I'm currently trying this from the example code:

{% for player in top_kills[1:10] -%}
{{loop.index}}. {{player.username|truncate(11)}} [{{millify(player.kills)}}] {% if loop.index is divisibleby 3 %}
{% endif %}
{%- endfor %}
N0FeaR † 2023 年 10 月 31 日 上午 2:19 
username*
N0FeaR † 2023 年 10 月 31 日 上午 2:19 
I found the problem i named the login with a big A and i tried to login with a small a but now its working fine
Stephen  [作者] 2023 年 10 月 31 日 上午 2:09 
† Mr. Ben Dover † , MultiAdmin is buggy. There's a specific order you have to do it in or something for it to work. Might be easier to just have it disabled.
N0FeaR † 2023 年 10 月 31 日 上午 2:00 
When i add AuthenticationClass=WebAdmin.MultiWebAdminAuth to KFWebAdmin i cannot login to my server webpage
Ramshy 2023 年 6 月 3 日 上午 4:22 
i have the following error massage playing the weekly:

Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Python\lib\threading.py", line 916, in _bootstrap_inner
File "C:\Users\wabbi\Documents\kf2-magicked-admin\kf2-magicked-admin\magicked_admin\server\game_tracker.py", line 32, in run
File "C:\Users\wabbi\Documents\kf2-magicked-admin\kf2-magicked-admin\magicked_admin\server\game_tracker.py", line 42, in __poll
File "C:\Users\wabbi\Documents\kf2-magicked-admin\kf2-magicked-admin\magicked_admin\server\game_tracker.py", line 117, in __update_game
File "C:\Users\wabbi\Documents\kf2-magicked-admin\kf2-magicked-admin\magicked_admin\server\server.py", line 209, in event_new_game
KeyError: 'kfgamecontent.KFGameInfo_WeeklySurvival'

Endless works just fine but weekly dont want to. I installed the patcher with validated files as mentioned in the discription. Any ideas?
Ramshy 2023 年 6 月 3 日 上午 4:08 
Hi, i found a very annoying bug. I was trying to implement a ASCII Character (&#208;) in my greeter massage. The problem is that the script will cut the text with the semicolon and dont translate it. Is there an option to implement ASCII Characters in Skripts?
Positiveinflux 2022 年 11 月 21 日 上午 11:06 
Anyone know how to change the colors or text in scoreboard and also start_wc in server_one_init ? also the announcing spays "spectator 2x) instead of a basic chat command.. greeter is also screwed listing every stast as zero
Mythical 2021 年 1 月 23 日 下午 9:37 
version 0.1.6 is out, nice guide :D
Hazzles 2020 年 11 月 8 日 上午 4:07 
@th3-z I think this is exactly the case, I reset the MOTD to the default one, and it works and updated perfectly. I'll try some formatting until I break it again xD In your example image above you have arrows, colours and have the text centred. I tried standard HTML formatting
e.g. <p style="color:#ffa500> SOME TEXT </p>)
which doesn't work, but
<font color="#ffa500"> SOME TEXT </font>
does work. I was just wondering if you know how to format for centering etc...

Also, in your example above it uses %KLL and %SCR for the MOTD, which whenever I try to use I get a Jinja error "Unexpected %". Not sure if the example above needs updating or I've done something wrong. Either way, I'll stop posting here to save spamming up the comments, and I'll message you if I have any more issues.

Final word here, this is an amazing tool, and anyone running a server should totally use it! The fact you're still active too is kudos to you developers :D