BF2 and Python

From Tactical Wiki

Jump to: navigation, search

Contents

[edit] standard_admin

The Battlefield 2\admin\standard_admin folder is where (by default) BF2 looks for its plugins. Internally, the __init__.py file is called (probably through an import) and whatever is in that file will be run. The default installation has the following for __init__.py:

import autobalance
import tk_punish

autobalance.init()
tk_punish.init()	

Any new plugins would need to be added similarly so that they initialize and make thier hooks into the game. Initialization generally involves registering an event handler to fire on one of the BF2 Events, such as PlayerSpawn.

According to another BF2 Modding wiki, the Python interpreter is instanciated on each level load, so plugins can be modified without the need to restart the server.

[edit] RCON

RCON for BF2 can be handled via BF2CC, but the game also comes with a barebones RCON interface, located in /Battlefield 2/AdminUtils/rcon/. There you can find a command-line RCON executable as well as the Python files from which it was created (using py2exe). You can use this application to remotely administrate your server, as well as get values associated with BF2 Status Commands.

[edit] Official BF2 Python Documentation

It's terribly limited, but the bone that DICE and EA have thrown developers can be found reprinted at the link below.
Official BF2 Python Doc

[edit] Tools

[edit] Other Sites

BF2 Tech Wiki
BF2 Modding


Return to Battlefield 2.