Editing and Customization > Modding Help

[Solved] How To Obtain Match Results During & After Each Match?

(1/3) > >>

Phivex:
So I'm looking to read log info from each match played. I've looked through the files, but I've yet to see a file that stores match results when the match is over. I'm also interested in the Python script(s) that outputs info to the screen about each kill or event. If it's not already written to a file, then I'd like to change that. Anyone have any insight?

Phivex:
So I *might* have found where to put some code. The function onPlayerKilled() in the gesource/python/ges/GamePlay/__init__.py may be what I'm looking for. The issue that I'm hitting now is even though I've added code to create and write to a file, it isn't running. I know how to write to a file in python, so I know it's not a syntax or logic issue. It's almost as if the python code doesn't run and it's pre-compiled and I'd have to recompile it or something. Thoughts?

So I was looking for my file in the gesource path. It actually created it in the "../Steam/steamapps/common/Source SDK 2007/" directory. However, the parameters (self, victim, killer, weapon) passed to the onPlayerKilled() function don't actually seem to have the player's name. When the victim and killer variables are output, they just output "player" as the value instead of the player's name. The weapon variable actually works, though. Example output for that variable: "weapon_d5k_silenced".

Now I just have to figure out how to get the player's name. Maybe the victim and killer variables are actually objects that have a name variable? If not, maybe there's a function that can be called and given the victim and killer variables and returns the name?

Phivex:
Okay. I think I figured out what I was trying to do. I'll post the solution so others can view in case they're curious. I imagine since no one else has responded and I've found nothing else similar very quickly, there isn't another way of doing it.

Add the following lines to the end of the function OnPlayerKilled() [line 113] in ../Steam/steamapps/sourcemods/gesource/python/ges/GamePlay/__init__.py


--- Code: ---
fileHandle = open("killLog.log", "a")
fileHandle.write("{},{},{}\n".format(killer.GetPlayerName(), victim.GetPlayerName(), weapon))
fileHandle.close()
--- End code ---

The killLog.log file will be in "../Steam/steamapps/common/Source SDK Base 2007/".

For other options available to the killer and victim objects, view the "../gesource/python/stubs/GEPlayer.py" file.

EDIT: Please note this only works for game modes where the scoring focuses on kills.

killermonkey:
Your better bet is to register an event hook in the __init__ function of GamePlay/__init__.py

This will guarantee that it is called even if the parent class does not call down into the base.

For examples of event hooks look in the utils files: https://github.com/goldeneye-source/ges-python/blob/master/ges/GamePlay/Utils/GEPlayerTracker.py

Phivex:
Hmm. Okay. Well hooks have always been a weak point of mine. Not sure why, but they always give me trouble.

So I tried adding the following snippet and it completely broke the scoring system. What am I doing wrong? How do I know what parameters are going to be passed?


--- Code: ---
def __init__(self):
    ....
    parent.RegisterEventHook( EventHooks.GP_PLAYERKILLED, self._Test )   
   
def _Test(self, killer, victim, weapon):
    GEUtil.Msg("----HOOK----")
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version