I need your advice on how to go about the following:
So the use case would look like this:
Here is a simple flask api to kick players by steamid using rcon.
You can use curl to post data to it like this:
curl -H "Content-Type: application/json" \
--d '{"steamid":"STEAM_1:0:1234567"}' \
https://myGameserver.com:8989/kickplayer
The api:
from flask import Flask, request
import valve.rcon
app = Flask(__name__)
HOST = "0.0.0.0"
PORT = 8989
DEBUG = True
# replace with your VM's local ip if you are running this web app on the same VM as the csgo server
# or with the azure public ip if not. (You will need to open up port 27015 TCP for rcon)
CSGO_SERVER_IP = "10.0.100.100"
RCON_PORT = 27015
RCON_PASS = "supersekret123456"
@app.route('/kickplayer', methods=['POST'])
def kick_player():
data = request.get_json()
steamid = data["steamid"] # STEAM_1:0:XXXXXXXXX
rcon_command = "sm_kick " + steamid
with valve.rcon.RCON((CSGO_SERVER_IP, RCON_PORT), RCON_PASS) as rcon:
response = rcon.execute(rcon_command)
return f"Kicked player {steamid}"
if __name__ == '__main__':
app.run(debug=DEBUG, host=HOST, port=PORT)