ValvePython / csgo

đŸ”« Python package for interacting with CS:GO Game Coordinator
http://csgo.readthedocs.io
123 stars 17 forks source link

Trying to find a user's most recent match #48

Closed ZacharyWix closed 3 years ago

ZacharyWix commented 3 years ago

I'm trying to find a user's most recent match so I can check whether it was a win or a loss. I'm very new when it comes to python, so trying to do this is a little over my skill level in this language. So far what I have is,

from steam.client import SteamClient
from csgo.client import CSGOClient
from csgo.enums import ECsgoGCMsg
#from google.protobuf.json_format import MessageToDict
#import logging

#logging.basicConfig(format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG)

client = SteamClient()
cs = CSGOClient(client)

@client.on('logged_on')
def start_csgo():
    cs.launch()

@cs.on('ready')
def gc_ready():
    # send messages to gc
    pass

client.cli_login()
client.run_forever()

cs.request_recent_user_games(XXXXXXXXXXXXX) #i put my user's steam id here
response, = cs.wait_event('recent_user_games')

print(str(response))

I'm currently just trying to retrieve the match list and print the most recent games, but no matter what I try I can't get it to print. Also, I'm unsure if I'm using the account_id correctly for cs.request_recent_user_games(). I'm also using the Steam Profile ID that you can find on your steam profile (17 numbers), but i don't know if I should be using something else. Does anyone know what I'm doing wrong here?

rossengeorgiev commented 3 years ago

Looking at the docs, that method takes account id (32bit), if you are passing steam id (64 bit), then it won't work

cs.request_recent_user_games(SteamID('steamid or accountid').as_32)