=====================================================================
  ZOMBIE MODE  -  DEDICATED SERVER GUIDE
  pgagaming.net  -  [pGA] Pro Gaming Arena
=====================================================================

A dedicated server runs the game with no graphics, 24/7, so your
friends (or the whole internet) can play any time, even when your
own PC is off. It runs on:

  * your Windows PC (next to the game, or a spare PC)
  * a Windows VPS / cloud server
  * a Linux VPS / cloud server (Ubuntu, Debian, ...)

Players always connect with the normal game. They find your server
in MULTIPLAYER (and on pgagaming.net), or use Join by IP.

What's in this download
-----------------------
  ZombieMode.exe / ZombieMode.console.exe / ZombieMode.pck   the game
  server.cfg                        your settings (edit this)
  Zombie Mode Server Manager.bat    Windows: settings form, start/stop, live log
  Start Server (console).bat        Windows: run in a console window
  Update Server.bat                 Windows: get the newest version
  start_server.sh                   Linux: run the server
  update_server.sh                  Linux: get the newest version
  zombiemode.service                Linux: run 24/7 with systemd
  SERVER-GUIDE.txt                  this file

What the server needs
---------------------
  * 2 CPU cores and 2 GB RAM (4 GB for a busy Survival server)
  * About 1.5 GB of disk
  * Ports open for incoming UDP:
        7777  the game            (the "port" in server.cfg)
        7778  server list queries (port + 1)
  * The same version as your players. When the game updates, update
    the server too (Update Server.bat / update_server.sh).


=====================================================================
 1. WINDOWS PC OR WINDOWS VPS
=====================================================================
1. Unzip this folder anywhere, for example C:\ZombieModeServer
2. Double-click  "Zombie Mode Server Manager.bat"
3. Pick a name, the game mode and the max players. Set an owner
   password if you want to run admin commands in game.
4. Press START SERVER. Its world and every player's Survival save are kept
   in the "serverdata" folder here, separate from your own solo game.
    The log on the right shows the server starting
   and players joining. The Internet address at the top is what you
   give to friends.
5. Open the ports (see section 3). On a VPS, also open them in your
   provider's firewall / security group.

No window wanted? Use "Start Server (console).bat" instead: it uses
server.cfg and shows the log in a console. To start it with Windows,
put a shortcut to it in shell:startup, or use Task Scheduler
("At startup", run whether user is logged on or not).


=====================================================================
 2. LINUX VPS (Ubuntu / Debian)
=====================================================================
Copy and paste, one block at a time (as a user with sudo):

  # tools
  sudo apt update && sudo apt install -y curl unzip libfontconfig1

  # a user and a folder for the server
  sudo useradd -r -m -d /opt/zombiemode zombiemode
  cd /opt/zombiemode
  sudo -u zombiemode curl -L -o server.zip https://pgagaming.net/zombiemode/ZombieMode-Server.zip
  sudo -u zombiemode unzip -o server.zip && sudo rm server.zip

  # your settings
  sudo -u zombiemode nano server.cfg

  # try it (Ctrl+C to stop). The first run downloads the Godot runtime.
  sudo -u zombiemode bash start_server.sh

  # run it 24/7 and on boot
  sudo cp zombiemode.service /etc/systemd/system/
  sudo systemctl daemon-reload
  sudo systemctl enable --now zombiemode

  # open the ports (ufw)
  sudo ufw allow 7777/udp
  sudo ufw allow 7778/udp

Useful commands:
  journalctl -u zombiemode -f          watch the log
  sudo systemctl restart zombiemode    restart (after editing server.cfg)
  sudo systemctl stop zombiemode       stop
  Update:  sudo systemctl stop zombiemode
           sudo -u zombiemode bash /opt/zombiemode/update_server.sh
           sudo systemctl start zombiemode

Saves (Survival world, bases, player saves, profiles, bans, admins)
live in the server's own folder:  /opt/zombiemode/serverdata/
(set data_dir in server.cfg to move it). Back it up now and then.


=====================================================================
 3. OPENING THE PORTS
=====================================================================
Home PC: in your router, forward UDP 7777 and UDP 7778 to the PC
running the server (the game also tries to do this by itself with
UPnP). Windows Firewall will ask the first time: allow it on
Private and Public networks. Or, in an admin command prompt:

  netsh advfirewall firewall add rule name="Zombie Mode" dir=in action=allow protocol=UDP localport=7777-7778

VPS: open UDP 7777-7778 in the server's firewall AND in the
provider's panel (AWS security group, Azure NSG, Google Cloud
firewall rule, Hetzner/DigitalOcean/Vultr cloud firewall, ...).

Several servers on one machine: give each its own folder and port
(7777, 7787, 7797 ...). Each also uses port+1.


=====================================================================
 4. server.cfg SETTINGS
=====================================================================
  server_name     name in the server list (max 48 characters)
  mode            survival | pve | pvp
  port            UDP game port (default 7777)
  max_players     2-100 (Survival up to 100, Horde 16, Infection 32)
  map             round modes: a map name below, or "" for map voting
  difficulty      Horde: easy | normal | hard | nightmare
  allies          Horde: AI survivors on the players' side, 0-4
  admin_password  owner password for /login in game chat ("" = off)
  public          true = listed in the game and on pgagaming.net
  data_dir        where the server keeps its saves ("" = serverdata/ next
                  to server.cfg). Each server has its own world.

Maps: Quarantine Yard, Blackwood Village, Sector 9 Warehouse,
Mercy Clinic, Ashfall Quarry, Rustwater Freighter, Mount Grimm,
Dustwater, Fort Ironside, Cypress Row, Starlight Mall,
Harrow Carnival, Pinecrest High, Area 51, Redline Truck Stop

Every setting can also be given on the command line, which wins over
server.cfg, for example:
  ZombieMode.console.exe --headless -- --server --config=server.cfg --port=7787 --mode=pvp


=====================================================================
 5. RUNNING THE SERVER IN GAME (owner and admin commands)
=====================================================================
Join your server, open chat (T) and type:
  /login <admin_password>     become the owner
  /help                       every command you're allowed to use
  /admin <player>             make someone an admin
  /kick <player> [reason]     /ban <player> [minutes] [reason]   /unban <name>
  /mute <player> [minutes]    /map <name>   /start   /end   /say <text>


=====================================================================
 6. TROUBLE?
=====================================================================
"Players can't join over the internet"
   The ports aren't open, or you gave the local address. Use the
   Internet address the Server Manager shows (or your VPS's IP) and
   check UDP 7777-7778 in every firewall on the way.
"This server runs version X but you have Y"
   Update the server (or the player's game: open the launcher).
"Not in the server list"
   public=true in server.cfg, and UDP 7778 open. Join by IP works
   either way.
Linux: "error while loading shared libraries"
   sudo apt install -y libfontconfig1 libxcursor1 libxinerama1 libxrandr2 libxi6

Hosting guide online: https://pgagaming.net/#host
