A CSGO .dem (demo) file parser in python
Without looking (and copying :D) at other projects it would have been impossible for me to understand how csgo demos work.
This is not as fast or good as the one written in golang, but I needed one in python and couldnt find any.
import DemoParser
parser = DemoParser(path_to_demo, dump=path_to_dumpfile, ent="ALL")
dump is a file to write some values in it (check this file)
ent is what entities to parse ("NONE", "P" players, "P+G" players + grenades, "ALL")
parser.parse()
Now, the parser wont return anything
You need to register some functions to use when certain events happen
Check this file
This parser will trigger events:
You can also add the function anywhere in code to create another event
Every entity has some properties of its own and some other properties stored in another entitiy called CCSPlayerResource
Entities class has a function to find properties by name since, for example, the kills for player1 are stored in CCSPlayerResource entity > m_iKills table > 001 key
You can call entity.find("kill") and get a dictioary of all keys that have kill in their name