Results 1 to 4 of 4
  1. #1
    GromisLT's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    15
    Reputation
    33
    Thanks
    0
    My Mood
    Amazed

    Lightbulb Get Steam server info with Steam ID's on that server? [Python]

    I am currently working on a project. I want to make a bot feature, which would query the steam servers, to get which players are currently playing on that server. I know you can get it with GetPlayerSummaries(), however that returns only the player name score and time played on the server. As some, who already worked with steam API or server queries will know, that you can kinda hide from people in some games by using Steam Name 123.

    Which is why I am looking if there is a possibility to get players playing on that server with their Steam ID's - that way I would love to whitelist who is enemy, friendly etc. Which would give me a possibility to do alert feature in *******. I managed to get the Servers Steam ID, but as from reading Web API documentation I only found the function to find IP by the Server ID. I am currently working with Python 3.5 and using other libraries such as python-valve.

    Additional info:

    I already tried one method, which should technically is a workaround. I call the players ID to get which server they are playing on, then I call to check if the server is the server which I am checking. I could leave it like that, but I think it is way too slow, especially, checking +50 players every minute or so.

    #This gets the basic stats of the server
    Code:
    def getServerStats(server_address):
        playerlist = []
        tempstr = ""
        with valve.source.a2s.ServerQuerier(server_address) as server:
            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):
                if player["name"]:
                    name = "{name}".format(**player)
                    seconds = float("{duration}".format(**player))
                    seconds = round(seconds)
                    hours = round(int(seconds) / 3600)
                    minutes = (seconds / 60) - (hours*60)
                    playerlist.append(name + " - Online: " + "%dhours %dminutes" % (hours,minutes))
                print(playerlist)
    return playerlist[0::]
    These are the options I can get from this call:

    Header byte Always equal to 'I' (0x49)
    Protocol byte Protocol version used by the server.
    Name string Name of the server.
    Map string Map the server has currently loaded.
    Folder string Name of the folder containing the game files.
    Game string Full name of the game.
    ID short Steam Application ID of game.
    Players byte Number of players on the server.
    Max. Players byte Maximum number of players the server reports it can hold.
    Bots byte Number of bots on the server.
    Server type byte Indicates the type of server:
    Environment byte Indicates the operating system of the server:
    Visibility byte Indicates whether the server requires a password:
    VAC byte Specifies whether the server uses VAC:
    And additionally A2S Player:

    For every player in "Players" there is this chunk in the response:
    Data Type Comment
    Index byte Index of player chunk starting from 0.
    Name string Name of the player.
    Score long Player's score (usually "frags" or "kills".)
    Duration float Time (in seconds) player has been connected to the server.
    The workaround code, which I talked above:
    Code:
    def onServer(steamID):
        with urlopen(STEAM_GET_PLAYER_SUMMARIES_URL.format(api_key=STEAM_WEB_API_KEY, steamid=steamID)) as response:
            profile_info = json.loads(response.read().decode('utf-8'))
        print(profile_info)
        playerSeenOn = profile_info['response']['players'][0]['gameserverip']
        playerSeenOn_serverID = profile_info['response']['players'][0]['gameserversteamid']
        print(playerSeenOn_serverID)
        temp = playerSeenOn.split(":")
        temp_port = temp[1]
        server_ip = temp[0]
        with urlopen(STEAM_GET_SERVER_PORT.format(ip=server_ip)) as response:
            temp_server = json.loads(response.read().decode('utf-8'))
            temp = temp_server['response']['servers']
    
        for servers in temp:
            if int(servers['gameport']) == int(temp_port):
                tmp = str(servers['addr'])
                server_port = tmp.split(":")
                server_port = server_port[1]
    
        server_adress = (server_ip, int(server_port))
    
        if(getServerStats(server_adress)):
            print("Player seen on the server!")
    So I am expecting to make something like this(Bear in mind that this photo is not mine, but from this, I know that there is a possibility):
    Attached Thumbnails Attached Thumbnails
    123.PNG  

    Last edited by MikeRohsoft; 1 Week Ago at 12:43 AM. Reason: added Code Tags

  2. #2
    Zaczero's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    localhost
    Posts
    3,268
    Reputation
    1412
    Thanks
    12,723
    My Mood
    Sleepy
    @ @GromisLT
    Okay so after my research I found 2 possible solutions:
    (not tested but seems promising)

    1)
    >> https://developer.valvesoftware.com/..._RCON_Protocol
    Connect using RCON protocol to the server and authenticate
    Execute command "listplayers" which will return index, username, steamid.
    Preview: https://i.imgur.com/zOBhZs7.png

    2)
    >> https://developer.valvesoftware.com/wiki/Server_queries
    Use A2S_INFO query to receive server's steamid.
    >> https://partner.steamgames.com/doc/api/ISteamFriends
    Then use GetFriendCount and GetFriendFromSourceByIndex functions to get steamid of the users (steamid in the parameter is server's steamid).


    Good luck man!
    Let us know if you managed to get it working


    --- References:
    1. https://forum.facepunch.com/dev/pefb...-A2S-PLAYER/1/
    . . . malsignature.com . . .



    [ global rules ] [ scam report ] [ image title ] [ name change ] [ anime force ]
    [ league of legends marketplace rules ] [ battlefield marketplace rules ]

    "because everytime you post a picture of anime in here
    your virginity's time increases by 1 month"
    ~Smoke 2/18/2018


    Former Staff 09-29-2018
    Battlefield Minion 07-21-2018
    Premium Seller 03-04-2018
    Publicist 12-10-2017
    League of Legends Minion 05-31-2017
    Premium 02-05-2017
    Member 10-13-2013

  3. #3
    GromisLT's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    15
    Reputation
    33
    Thanks
    0
    My Mood
    Amazed
    @Zaczero
    I will try these two methods, the only problems I may face:

    1 idea:
    It is official ark servers, which I don't think give you access with RCON protocol.

    2 idea:
    The function mentioned is only available on Steamworks SDK, I can't reach it by the web API, if you have any ideas let me know, I am jumping back on trying your ideas!
    Last edited by GromisLT; 1 Week Ago at 02:24 PM.

  4. #4
    GromisLT's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    15
    Reputation
    33
    Thanks
    0
    My Mood
    Amazed
    Up. No luck... It is irritating, as I know a few groups of people who managed to do it, haha

Similar Threads

  1. [WTT] looking for empty steam a/c with steam guard enabled
    By Fanbo in forum Selling Accounts/Keys/Items
    Replies: 6
    Last Post: 07-01-2013, 06:46 AM
  2. [WTT] looking for empty steam a/c with steam guard enabled
    By Fanbo in forum Trade Accounts/Keys/Items
    Replies: 4
    Last Post: 07-01-2013, 06:00 AM
  3. [Help Request] Getting proxies to work with Vindictus EU - Authentication to NGM server failed
    By Question2 in forum Vindictus Help
    Replies: 0
    Last Post: 10-12-2012, 08:29 AM
  4. DOTA2 as a Steam gift TRADABLE with steam Client FAIR
    By 7FoX in forum Selling Accounts/Keys/Items
    Replies: 0
    Last Post: 11-24-2011, 04:14 PM
  5. [Help] Retrieveing steam server info
    By Accelerate' in forum Visual Basic Programming
    Replies: 4
    Last Post: 07-20-2011, 09:19 PM