CS:GO per-team config files

counter-strike-global-offensive

TLDR: I want to be able to have terrorist.cfg and counterterrorist.cfg to change my keybinds (eg have F1 buy an AUG or an AK-47, but not an SG or an M4).

Here's my current plan. Step 1: Create a config file teambinds.cfg:

clear
say_team GLHF everyone!
condump
exec team.cfg

Step 2: In team.cfg, we loop:

wait
exec team.cfg

Step 3: Have a Python script watch for the file created by condump. That's its signal to go to work. It should find my "GLHF" message prefixed with either (Terrorist) or (Counter-Terrorist). That's how it knows which team I'm on. It then replaces team.cfg with either:

exec terrorist.cfg
condump

or

exec counterterrorist.cfg
condump

When the Python script sees the second condump, it cleans everything up and resets (deleting both condumps, replacing team.cfg with the loop).

Questions:

  • 1) Does this count as external assistance (will it get me VAC-banned)?
  • 2) Is there a way to trigger the initial execution?
  • 3) Surely surely SURELY there's a better way to figure out my team than say_team…. please?
  • 4) Can I just bypass this entire duct-tape-and-fencing-wire setup and actually have per-team configs?

Best Answer

Solution found. It still requires an external Python script, but much less weirdly so. The key here is a "game state integration", which is the same thing used by a custom HUD.

Step 1: Create a config file gamestate_integration_python.cfg:

"GameState Integration Configs"
{
    "uri"       "http://127.0.0.1:27014/"
    "timeout"   "5.0"
    "buffer"    "0.1"
    "throttle"  "0.5"
    "data"
    {
        "player_id"         "1"
    }
}

Step 2: Create a Python script (also in the csgo/cfg directory) which listens for incoming requests and updates the config files.

from flask import Flask, request
app = Flask(__name__)

@app.route("/", methods=["POST"])
def update_configs():
    if not request.json: return "", 400
    team = request.json.get("player", {}).get("team")
    with open("gsi_player_team.cfg", "w") as f:
        if team == "T":
            f.write("buy ak47")
        else:
            f.write("buy aug")
    return "" # Response doesn't matter

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=27014)

Step 3: bind f1 "exec gsi_player_team"

Step 4: Make sure the Python script is always running when CS:GO is.

The game state integration is automatically triggered (many times, actually), and it's given the essential information. In fact, this can be used for many other customizations, too. As far as I can tell, this doesn't violate any rules, and shouldn't result in a VAC ban.

Related Topic