<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Scripts%3AEventsPy</id>
	<title>Scripts:EventsPy - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Scripts%3AEventsPy"/>
	<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Scripts:EventsPy&amp;action=history"/>
	<updated>2026-08-06T01:09:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://bf2tech.uturista.pt/index.php?title=Scripts:EventsPy&amp;diff=125&amp;oldid=prev</id>
		<title>Pireax: Created page with &quot;__TOC__ == What It Does  ==  * Prints connections, disconnections, and chat messages to the server console.  == Installation  ==  # Browse to &lt;code&gt;admin/standard_admin&lt;/code&gt;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Scripts:EventsPy&amp;diff=125&amp;oldid=prev"/>
		<updated>2018-06-22T15:35:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__TOC__ == What It Does  ==  * Prints connections, disconnections, and chat messages to the server console.  == Installation  ==  # Browse to &amp;lt;code&amp;gt;admin/standard_admin&amp;lt;/code&amp;gt;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
== What It Does  ==&lt;br /&gt;
&lt;br /&gt;
* Prints connections, disconnections, and chat messages to the server console.&lt;br /&gt;
&lt;br /&gt;
== Installation  ==&lt;br /&gt;
&lt;br /&gt;
# Browse to &amp;lt;code&amp;gt;admin/standard_admin&amp;lt;/code&amp;gt; in your bf2 server directory&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;__init__.py&amp;lt;/code&amp;gt; so it looks something like the code snippet below.&lt;br /&gt;
# Save the below code to &amp;lt;code&amp;gt;admin/standard_admin/events.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Run your server. If &amp;quot;&amp;lt;code&amp;gt;events.py loaded&amp;lt;/code&amp;gt;&amp;quot; comes up in your server console it should work from there.&lt;br /&gt;
&lt;br /&gt;
== Code  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== __init__.py  ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import autobalance&lt;br /&gt;
import tk_punish&lt;br /&gt;
import events&lt;br /&gt;
&lt;br /&gt;
autobalance.init()&lt;br /&gt;
tk_punish.init()&lt;br /&gt;
events.init()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== events.py  ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# script for viewing interesting events in the server console&lt;br /&gt;
# -- by dackz (http://dackz.net/)&lt;br /&gt;
&lt;br /&gt;
import bf2&lt;br /&gt;
import host&lt;br /&gt;
from bf2 import g_debug&lt;br /&gt;
&lt;br /&gt;
def init():&lt;br /&gt;
    if g_debug: print &amp;#039;initialising events script&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    host.registerHandler(&amp;#039;PlayerConnect&amp;#039;, onPlayerConnect, 1)&lt;br /&gt;
    host.registerHandler(&amp;#039;PlayerDisconnect&amp;#039;, onPlayerDisconnect, 1)&lt;br /&gt;
    host.registerHandler(&amp;#039;ChatMessage&amp;#039;, onChatMessage, 1)&lt;br /&gt;
&lt;br /&gt;
    host.rcon_invoke(&amp;#039;echo &amp;quot;events.py loaded&amp;quot;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
def onPlayerConnect(player):&lt;br /&gt;
    host.rcon_invoke(&amp;#039;echo &amp;quot;Connected: %s&amp;quot;&amp;#039; % (player.getName()))&lt;br /&gt;
&lt;br /&gt;
def onPlayerDisconnect(player):&lt;br /&gt;
    host.rcon_invoke(&amp;#039;echo &amp;quot;Disconnected: %s&amp;quot;&amp;#039; % (player.getName()))&lt;br /&gt;
&lt;br /&gt;
def onChatMessage(player_id, text, channel, flags):&lt;br /&gt;
    player = bf2.playerManager.getPlayerByIndex(player_id)&lt;br /&gt;
&lt;br /&gt;
    host.rcon_invoke(&amp;#039;echo &amp;quot;&amp;lt;%s&amp;gt;%s: %s&amp;quot;&amp;#039; % (channel, player.getName(), text))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes  ==&lt;br /&gt;
&lt;br /&gt;
The chat text might look a little weird as the script doesn&amp;#039;t clean it up at all. You might see things like &amp;lt;code&amp;gt;HUD_TEXT_CHAT_TEAM&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;*Â§DEADÂ§*&amp;lt;/code&amp;gt;, et cetera. Perhaps that will be fixed in the future.&lt;/div&gt;</summary>
		<author><name>Pireax</name></author>
	</entry>
</feed>