It's quite frustrating, you loose your banlist for some unknown reason and can't reinstate the bans from log files for the most recent bans. The closet thing I saw to it is this script mentioned here. I don't know how to install it and I'm sure a lot of us would like it to log every players CD hash who enters the server into log files.
CD Hash logging
Collapse
X
-
Tags: None
-
Re: CD Hash logging
import re
def playerData():
'''Returns a dictionary containing player data; dictionary keys are
playerIDs, values are 4-element tuples, containing player name,
IP address, IP port, and cd-key hash.'''
rawData = host.rcon_invoke("admin.listplayers")
pattern = re.compile(r'''^Id:\ +(\d+) # PlayerID
\ -\ (\S+) # Player Name
\ is\ remote\ ip:\ (\d+\.\d+\.\d+\.\d+): # IP Address
(\d+).*? # Port Number
hash:\ (\w{32}) # CD Key Hash
''', re.DOTALL | re.MULTILINE | re.VERBOSE)
result = {}
for player in pattern.findall(rawData):
result[int(player[0])] = player[1:]
return result
You can log into a file:
edit the Battlefield 2 Server/python/__init__.py
replace this:
sys.stdout = fake_stream('stdout')
sys.stderr = fake_stream('stderr')
with this:
logFile = open('mylogfile.log', 'a')
sys.stdout = logFile
sys.stderr = logFile
So add this to somerwhere to playerconnect event:
info = playerData()
for playerID in info:
print info[playerID][0], info[playerID][1], info[playerID][3]
And it will log the hashes to the logfile.
-
Re: CD Hash logging
Thanks Bbrain it's been really helpful and if you could just let me know where I need to put this:
That would be awesome. Unfortunately I don't have much knowledge of how python works, but if it's like a lot of other languages does the class have to loaded into memory first?Code:import re def playerData(): '''Returns a dictionary containing player data; dictionary keys are playerIDs, values are 4-element tuples, containing player name, IP address, IP port, and cd-key hash.''' rawData = host.rcon_invoke("admin.listplayers") pattern = re.compile(r'''^Id:\ +(\d+) # PlayerID \ -\ (\S+) # Player Name \ is\ remote\ ip:\ (\d+\.\d+\.\d+\.\d+): # IP Address (\d+).*? # Port Number hash:\ (\w{32}) # CD Key Hash ''', re.DOTALL | re.MULTILINE | re.VERBOSE) result = {} for player in pattern.findall(rawData): result[int(player[0])] = player[1:] return result
My original assumption is I could create a file called hash.py in the /python directory and put the code above in the file. BF2 would auto read the file on startup and load it into memory. Then on player connect it would be able to access the class then
Comment
Comment