Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few questions #6

Open
T1MOXA opened this issue Oct 4, 2018 · 4 comments
Open

Few questions #6

T1MOXA opened this issue Oct 4, 2018 · 4 comments

Comments

@T1MOXA
Copy link

T1MOXA commented Oct 4, 2018

Can I find out the nickname and steam id of the one who recorded the demo?
How to know who's observing who ?

P.S. Sorry for my English ))

@rmoe
Copy link
Contributor

rmoe commented Oct 11, 2018

The name of the client who recorded the demo is in header.

>>> from demoparser.demofile import DemoFile
>>> data = open("/path/to/demo/1.dem", "rb").read()
>>> df = DemoFile(data)
>>> df.header.client_name.decode('utf-8')
'максим хуй сосиム'

Then you can get the steam ID from the entities.players list. Here's an example:

players = {}

def player_connect(event, msg):
    for idx, key in enumerate(event['event'].keys):
        if key.name == 'userid':
            user_id = msg.keys[idx].val_short
        if key.name == 'networkid':
            steam_id = msg.keys[idx].val_string
        if key.name == 'name':
            name = msg.keys[idx].val_string

        players[user_id] = {
            'name': name,
            'steam_id': steam_id,
            'user_id': user_id

if __name__ == "__main__":
    data = open(sys.argv[1], 'rb').read()
    d = DemoFile(data)
    d.add_callback('player_connect', player_connect)
    print(d.players)

In the case of a GOTV demo the steam ID will just be 'bot'.

@T1MOXA
Copy link
Author

T1MOXA commented Oct 15, 2018

Is it possible to get data about for whom watching the player who recorded the demo ?

@T1MOXA
Copy link
Author

T1MOXA commented Oct 17, 2018

There is also the entprop m_hObserverTarget?
Maybe you can get it ?

@T1MOXA
Copy link
Author

T1MOXA commented Oct 17, 2018

For some reason, this code does not work...

from demoparser.demofile import DemoFile

def player_connect(event, msg):
	print('connect')

if __name__ == "__main__":
	data = open("1.dem", 'rb').read()
	d = DemoFile(data)
	d.add_callback('player_connect', player_connect)
	d.parse()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants