XR1.0 contains a nice implementation of Python 2.7.
From now on, server triggers will be written in Python instead of the horrible method used in RC3.
The possibilities open by python triggers are quite mind-boggling.
All you need is a bit of imagination, and to think outside the box.
The tools at your disposal include mysql, xml, cgi...
To get started, take a look at the readme.txt files in:
/game/python
/game/python/triggers
A library of Triggers has been provided in /game/python/triggers/library.
To use them on your server, simply copy the files to /game/python/triggers.
It would be nice if server admins can share their triggers on this topic.
It will help all XR servers make progress towards better game experience!
If you would like more functions or variables added to the Python API, please ask here.
You can also ask here any question regarding Python/Triggers.
----------- Triggers FAQ ------------
Question: What are peons?
Answer: Peons are worker type npcs.
Question: Why is there no INFO_officer in GetClientInfo?
Answer: Officer state is already available in an array: sv_defs.clientList_Officer[index]
Note: I may also add INFO_officer in the future, for ease of use. Keep an eye on sv_defs.py!
Question: What are the game states?
Answer: To help you understand the game states, here is an extract from sv_events.py (in savage0.zip):
state = core.GetGameInfo(GAME_STATE)
if state == 0:
# Server is waiting for clients to connect
core.ConsolePrint('Python: Server Empty...\n')
elif state == 1:
# Setting a game up in the lobby
core.ConsolePrint('Python: Game Setup...\n')
elif state == 2:
# Warming up
core.ConsolePrint('Python: Game Warmup...\n')
elif state == 3:
# Normal play mode
core.ConsolePrint('Python: Game Normal...\n')
elif state == 4:
# Game finished and stats screen is shown
core.ConsolePrint('Python: Game Ended...\n')
sv_stats.process()
elif state == 5:
# About to load the next map
core.ConsolePrint('Python: Loading Next Map...\n')
elif state == 6:
# About to load the voted map
core.ConsolePrint('Python: Loading Voted Map...\n')
elif state == 7:
# Match is restarting (same map)
core.ConsolePrint('Python: Restarting Map...\n')