Players statistics, servers list and more for the Running With Rifles (RWR) game and its Pacific DLC
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
discord Fix indent Jul 10, 2018
docs/discord_bot
migrations
rwr
scripts
static
storage
templates
.gitignore
README.md
commands.py
config.example.py
dynamic_image.py
helpers.py Whoops Jul 24, 2018
hooks.py
local.py
models.py
requirements-dev.txt Well it is almost finished Jul 2, 2018
requirements.txt Add simplejson dep Jul 24, 2018
routes.py
rwrs.py
steam.py
uwsgi.py

README.md

Running With Rifles Stats (RWRS)

Players statistics, servers list and more for the Running With Rifles (RWR) game and its Pacific DLC. Available at rwrstats.com.

Features

  • Players
    • Support stats for both the official invasion (vanilla RWR) servers and official Pacific servers
    • Search for a player
    • View player stats (as well as next rank progression, unlocks, on which server he's playing on, etc)
    • Compare two players stats
    • Friends list (easily know on which server your friends are playing on. There's no need to create a user account or whatever)
    • Players list (leaderboard)
    • Stats history
    • Signatures
  • Public servers
    • Real servers location
    • Real maps name
    • Official invasion (ranked) servers are highlighted
    • Game mode (coop, PvPvE, etc) and type (vanilla RWR, Pacific DLC, etc)
    • Public server details (players list with link to their profile, current map preview and minimap, etc)
    • Filtering capabilities
    • Mapview
    • Banners
  • Online servers count (+ the active ones)
  • Total players count (+ online ones + number of playing friends)
  • Charts (for the past week)
    • Number of online players
    • Number of online servers (+ the active ones)
    • Number of players on a server
    • Peaks
  • Online multiplayer status
  • Discord bot able to give several kind of information. Available on the RWR Discord Server

Prerequisites

  • Should work on any Python 3.x version. Feel free to test with another Python version and give me feedback
  • A modern web browser (which optionally support localStorage)
  • A MySQL-compatible DBMS (MySQL, MariaDB, Percona, etc)
  • (Optional, but recommended) A uWSGI-capable web server
  • (Optional) Running With Rifles, if you need to extract data by using the commands below

Installation

  1. Clone this repo somewhere
  2. pip install -r requirements.txt
  3. set FLASK_APP=rwrs.py
  4. flask db upgrade
  5. bash scripts/geolite2_city_updater.sh

Configuration

Copy the config.example.py file to config.py and fill in the configuration parameters.

Available configuration parameters are:

  • SECRET_KEY Set this to a complex random value
  • SERVER_NAME The IP or hostname where RWRS will be available

More informations on the three above can be found here.

  • DB_USERNAME Username to access the DBMS
  • DB_PASSWORD Password to access the DBMS
  • DB_UNIX_SOCKET If set, DB_HOST and DB_PORT will be ignored in favor of using this Unix socket to communicate with the DBMS
  • DB_HOST Host of the DBMS
  • DB_PORT Port of the DBMS
  • DB_NAME Name of the database to use
  • BETA Whether or not to enable the beta mode
  • GAUGES_SITE_ID A Gauges site ID used to track visits on RWRS (optional)
  • BUGSNAG_API_KEY A Bugsnag API key so that unhandled exceptions are automatically sent to Bugsnag in production env (optional)
  • CACHE_THRESHOLD The maximum number of items the cache will store before it starts deleting some (see here for more configuration parameters related to Flask-Cache)
  • SERVERS_CACHE_TIMEOUT Cache duration of the servers list (in seconds)
  • PLAYERS_CACHE_TIMEOUT Cache duration of the players list as well as data for a single player (in seconds)
  • GRAPHS_DATA_CACHE_TIMEOUT Cache duration of the graphs data, both the players and the servers ones (in seconds)
  • STEAM_PLAYERS_CACHE_TIMEOUT Cache duration of the total number of players (in seconds)
  • STEAM_API_KEY A Steam API key
  • PACIFIC_PLAYERS_RANKS_COUNTRY Ranks image / name to show for the Pacific players stats (us, jp)
  • MY_DISCORD_ID My Discord user ID (snowflake)
  • DISCORD_BOT_TOKEN Authentication token used by the RWRS Discord bot
  • DISCORD_BOT_CHANNEL_ID The Discord channel ID the bot is allowed to talk in
  • DISCORD_BOT_ADMINS A list of Discord user IDs (snowflakes) allowed to use hidden bot commands
  • DISCORD_BOT_GUILD_ID A Discord guild (server) ID the bot will be allowed to listen for commands from
  • MAX_NUM_OF_PLAYERS_TO_TRACK_STATS_FOR How many players should RWRS track the stats for (top players storted by XP)

I'll let you search yourself about how to configure a web server along uWSGI.

Usage

  • Standalone

Run the internal web server, which will be accessible at http://localhost:8080:

python local.py

Edit this file and change the interface/port as needed.

  • uWSGI

The uWSGI file you'll have to set in your uWSGI configuration is uwsgi.py. The callable is app.

  • Others

You'll probably have to hack with this application to make it work with one of the solutions described here. Send me a pull request if you make it work.

Extracting ranks data and images

The Flask command flask extract_ranks is used to extract and save all ranks data to a JSON file located at storage/data/ranks.json. It also retrieve, process (the actual images content isn't centered) and save all the RWR ranks images. They are saved at static/images/ranks/{country}/{rank ID}.png and static/images/ranks/{country}/{rank ID}_icon.png.

  1. pip install -r requirements-dev.txt
  2. set FLASK_APP=rwrs.py
  3. flask extract_ranks --steamdir="{path to the Steam root directory}"

This command requires the game to be installed.

Extracting maps data

The Flask command flask extract_maps_data is used to extract and save all maps data to a JSON file located at storage/data/maps.json.

  1. set FLASK_APP=rwrs.py
  2. flask extract_maps_data --steamdir="{path to the Steam root directory}"

This command requires the game to be installed.

Extracting minimaps

The Flask command flask extract_minimaps is used to extract minimaps (the ones displayed when pressing on TAB). They are saved at static/images/maps/minimap/{map ID}.png and static/images/maps/minimap/{map ID}_thumb.png.

  1. pip install -r requirements-dev.txt
  2. set FLASK_APP=rwrs.py
  3. flask extract_minimaps --steamdir="{path to the Steam root directory}"

This command requires the game to be installed.

Clearing cache

  1. set FLASK_APP=rwrs.py
  2. flask cc

Clearing old graphs data

Data older than one week old will be deleted.

  1. set FLASK_APP=rwrs.py
  2. flask clean_players_count

Storing actual number of players (for graphs)

Will save the current number of Steam players which have RWR running, and the current number of players playing online.

  1. set FLASK_APP=rwrs.py
  2. flask get_players_count

Migrating the database

  1. set FLASK_APP=rwrs.py
  2. flask db upgrade

Saving RWR root servers status

Will ping RWR root servers and store their status (up or down).

  1. set FLASK_APP=rwrs.py
  2. flask get_root_rwr_servers_status

Running the RWRS Discord bot

  1. set FLASK_APP=rwrs.py
  2. flask run_discord_bot

Updating the MaxMind GeoLite2 City database

More information in the script comments.

bash scripts/geolite2_city_updater.sh

Updating RWRS

More information in the script comments.

bash scripts/rwrs_updater.sh [TYPE, default=fast, fast|full] [DOMAIN, default=rwrstats.com]

Retrieve and save the players stats in DB

  1. set FLASK_APP=rwrs.py
  2. flask save_players_stats [--reset]

Import rwrtrack data

  1. set FLASK_APP=rwrs.py
  2. flask import_rwrtrack_data --directory="{path to the rwrtrack data directory}" [--reset]

How it works

This project is mainly powered by Flask (Python) for the backend.

Data is fetched from the official servers list page (which sucks) as well from the official players list page (which sucks, too). Data is cached so there isn't many requests sent to the server who hosts these lists.

As the provided servers location is most of the time either missing or invalid, RWRS makes its own look up using a GeoLite2 database.

Credits

End words

If you have questions or problems, you can either: