CS:GO per-team config files
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?
Solution 1:
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.
Solution 2:
You don't have to do it complicated like that.
If you want to purchase team-specific weapons using the same key for both teams you could just put both on it.
For example if you want to use F3 to buy either AK-47 or M4A1 and F4 to buy the AUG or SG depending on your team:
bind "F3" "buy ak47; buy m4a1"
bind "F4" "buy aug; buy sg556"
Pressing F3 on CT buys a M4 and on T it buys an AK-47 (and F4 for the AUG or SG).
This also works with other items available only to specific teams, like Molotov/Incendiary.
This way it is completely legal as you don't have to worry about external scripts.
Or if you really need that AUG and SG separated...
Use team based configs:
create two configs (soomething like t.cfg and ct.cfg) and put your buy scripts and other settings in there.
At the end of the t.cfg:
bind "F1" "exec ct.cfg"
echo "Terrorist Config loaded"
And vice versa the ct.cfg:
bind "F1" "exec t.cfg"
echo "Counter-Terrorist Config loaded"
You can as well replace or amend the echo with a neat sound:
play ui\now-playing-as-counter-terrorist
play ui\now-playing-as-terrorist
Now you can toggle them using F1 and don't have to worry about external scripts manipulating your game files. VAC will certainly have a look or two at your python script.