Scripts:EventsPy
From BF2 Technical Information Wiki
Contents |
What It Does
- Prints connections, disconnections, and chat messages to the server console.
Installation
- Browse to
admin/standard_adminin your bf2 server directory - Edit
__init__.pyso it looks something like the code snippet below. - Save the below code to
admin/standard_admin/events.py. - Run your server. If "
events.py loaded" comes up in your server console it should work from there.
Code
__init__.py
import autobalance import tk_punish import events autobalance.init() tk_punish.init() events.init()
events.py
# script for viewing interesting events in the server console
# -- by dackz (http://dackz.net/)
import bf2
import host
from bf2 import g_debug
def init():
if g_debug: print 'initialising events script'
host.registerHandler('PlayerConnect', onPlayerConnect, 1)
host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
host.registerHandler('ChatMessage', onChatMessage, 1)
host.rcon_invoke('echo "events.py loaded"')
def onPlayerConnect(player):
host.rcon_invoke('echo "Connected: %s"' % (player.getName()))
def onPlayerDisconnect(player):
host.rcon_invoke('echo "Disconnected: %s"' % (player.getName()))
def onChatMessage(player_id, text, channel, flags):
player = bf2.playerManager.getPlayerByIndex(player_id)
host.rcon_invoke('echo "<%s>%s: %s"' % (channel, player.getName(), text))
Notes
The chat text might look a little weird as the script doesn't clean it up at all. You might see things like HUD_TEXT_CHAT_TEAM, *§DEAD§*, et cetera. Perhaps that will be fixed in the future.