Self server hosting






How to Set Up Your Game Server


How to Set Up Your Game Server

Follow the instructions below to create and run a server for your game

server 1.5.0.tar
server 1.6.0.tar

1. Prerequisites

Before starting, ensure you have the following:

  • Docker Installed: Download and install Docker from the official website.
  • Server Files: Ensure you have the server.tar file, which includes the necessary game files:
    • Linux_Core_Data
    • GameAssembly.so
    • Linux_Core.x86_64
    • UnityPlayer.so

2. Build the Docker Image

Create a Dockerfile with the following content:


FROM ubuntu:18.04

RUN apt-get update && apt-get install ca-certificates -y && update-ca-certificates

RUN useradd -ms /bin/bash unity

WORKDIR /home/unity

RUN mkdir -p /home/unity/StandaloneLinux64
RUN chown unity:unity /home/unity/StandaloneLinux64

COPY server.tar /home/unity/

RUN chown -R unity:unity /home/unity/server.tar

USER unity

RUN tar --no-same-owner -xf server.tar && rm server.tar

ENV GAME_IS_SERVER=true

RUN chmod +x ./Linux_Core.x86_64

CMD ["./Linux_Core.x86_64", "-logFile", "/dev/stdout", "-batchmode", "-nographics"]
    

Then run the following command to build the image:

docker build —no-cache -t spraynpray-game-server:latest .

3. Run the Server

Linux Command


docker run -d -p 28655:28655/udp \
  --name spraynpray-server \
  -e GAME_IS_SERVER=true \
  -e GAME_MODE=ld \
  -e GAME_MAP_NAME="BR Island" \
  -v $(pwd):/home/unity/.config/unity3d/Kama Entertainment Studio/Spray & Pray/ \
  spraynpray-game-server:latest
    

Windows Command


docker run -d -p 28655:28655/udp ^
  --name spraynpray-server ^
  -e GAME_IS_SERVER=true ^
  -e GAME_MODE=ld ^
  -e GAME_MAP_NAME="BR Island" ^
  -v "%cd%:/home/unity/.config/unity3d/Kama Entertainment Studio/Spray & Pray/" ^
  spraynpray-game-server:latest
    

4. Game Modes and Maps

Below is a list of available game modes and their corresponding maps:

Mode Maps
Bhop (bhop) Bhop Base 2, Bhop Base
Bomb Defuse (bomb_defuse) Hangar, BD Warehouse
Team Deathmatch (tdm) Hangar
Last Duo (ld) BR Island
Battle Royale (br) BR Island
Arms Race (arms_race) Hangar

5. Check Server Logs

To check the server logs, use the following command:

docker logs spraynpray-server

6. Commands

Network Commands Documentation

This document provides an overview of the network command system used in the project.
Commands are issued as text messages (typically prefixed with a symbol such as / or !)
and are parsed to perform various administrative or in-game actions.

Command Parsing Overview

The command system is implemented in the CommandBase class.
When a message is received:

  • The system checks that the message starts with a command prefix.
  • The prefix is removed and the remaining message is split into tokens (words).
  • The first token identifies the command name while the remaining tokens are its arguments.
  • A switch statement validates the argument count and type, then returns an instance of the corresponding command class.
  • If the command name or its parameters are invalid, null is returned.

Supported Commands

Command Expected Arguments Description Example
ban <userID> Bans a user. The first argument is the user ID (an integer). The second argument (whose meaning is defined by the implementation)
might represent a ban reason or duration.
/ban 123 reason
pardon <userID> Removes a ban from the specified user (user ID as integer). /pardon 123
r, rs, restart None Restarts round. /restart
op <userID> (integer) Grants operator (OP) privileges to the user with the specified ID. /op 123
deop <userID> (integer) Revokes operator (OP) privileges from the specified user. /deop 123
whitelist_add <userID> (integer) Adds the specified user to the whitelist. /whitelist_add 123
whitelist_remove <userID> (integer) Removes the specified user from the whitelist. /whitelist_remove 123
weather <weather> (byte) Sets the game weather. The argument is a numeric value corresponding to a defined value in the WeatherType enum. 0 — normal, 1 — fog, 2 -rain. /weather 1
time <time> (float) Sets the in-game time. The argument is a floating-point number. /time 1250
spawn <spawnIndex> (byte) Spawns an entity at the specified spawn index. /spawn 3
give <giveIndex> (byte) [count (byte, optional)] Gives an item identified by the index to the player. An optional count may be provided (defaults to 1 if omitted). /give 4 2
kill None Kills the invoking player or associated entity. /kill

7. Environment Variables

Game Server Environment Variables Documentation

This document outlines the environment variables used to configure the game server. These variables determine whether the application runs in server mode, the server authentication, game mode, network configuration, and other settings.

Variable Description Default Value Notes
GAME_IS_SERVER Indicates if the application should run in server mode. true If not set or empty, server mode is disabled.
GAME_MODE Specifies the game mode for the server. Not specified Optional; only applied if set and in server mode.
GAME_MAP_NAME Name of the game map to load. Not specified Optional; only applied if set and in server mode.
GAME_VIEW_MODE Specifies the view mode for the game. The value is converted to lowercase. Not specified Optional; only applied if set and in server mode.
GAME_HOST_ADDRESS IP address for the game server to bind to. IPAddress.Any (typically 127.0.0.1) If not set, the server will bind to any available address.
GAME_HOST_PORT Port number for the game server. 28655 Parsed as an unsigned short (ushort).
GAME_HOST_PORT_VOIP Port number for the VOIP (Voice Over IP) service. 28656 Parsed as an unsigned short (ushort).
GAME_WARMUP_TIME Duration for the warm-up period before the game starts. 0 Parsed as a long integer.
GAME_DIFFICULTY Sets the difficulty level for the game. Empty string Optional; only applied if set and in server mode. hard/normal/easy/peaceful

That’s it! Your server is now ready to use. Share the IP address and port with players to start the game.