On the game server - creating a text file with a list of current players

I want to create a text file with a list of current players. This will all be done outside the game on the windows server. I have never used UE3 API so I am a noob.

I'm actually interested in seeing how this could be done.

My google searching only leaves me more confused and I was wondering if anyone has done something similar to this.

Comments

  • SacchoSaccho Posts: 1,577Player
    edited July 2016
    You need to use the A2S protocol (https://developer.valvesoftware.com/wiki/Server_queries) to query players from the server.


    I think I've seen you mention Python in the past. This is what you really want:
    https://github.com/Holiverh/python-valve


    You'll need to know your server's IP and query port (*not* 8777, in the 27000s). Throw them in where "server" is assigned. Set up the output however you want and you're done.
    import valve.source.a2s
    try:
        server = valve.source.a2s.ServerQuerier(address=('128.0.0.1', 27020), timeout = 5.0)
        info = server.info()
        players = server.players()
    
        print "{player_count}/{max_players} {server_name}".format(**info)
        for player in sorted(players["players"],
                             key=lambda p: p["score"], reverse=True):
            print "{score} {name}".format(**player)
    except valve.source.a2s.NoResponseError:
        print "Master server request timed out!"
    


    Note: The AA Devs prepend [T0], [T1], and [T-1] to each player's name in the query response. [T-1] is spectators, the other two are alpha and bravo teams (or possibly attack & defense, see if they switch at the half). You may want to strip those depending on what you want out of this project.
  • SacchoSaccho Posts: 1,577Player
    edited July 2016
    Finding the query port, if not known, is easily done via the Steam web APIs. Search an IP via
    http://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=127.0.0.1&format=json
    and the response will look like this:
    		>>>		"addr": "127.0.0.1:27020",  <<< Query port
    				"gmsindex": 65534,
    				"appid": 203290,
    				"gamedir": "aa4game",
    				"region": -1,
    				"secure": false,
    				"lan": false,
    				"gameport": 7778,
    				"specport": 0
    
  • I will check this out this week!!!! Thanks!!!
Sign In or Register to comment.