Welcome, Guest. Please login or register.
Did you miss your activation email?
November 19, 2017, 10:45:38 am

Login with username, password and session length
Search:     Advanced search
Savage: XR is a new patch for Savage, created by the Newerth.com staff. The XR1.1 Client is out now! Download it now!
188623 Posts in 10884 Topics by 17943 Members
Latest Member: Yustus123321
* Home Forum Wiki Help Search Login Register
+  Newerth Forums
|-+  Archive
| |-+  Server Forum
| | |-+  Info: Server Triggers
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Go Down Print
Author Topic: Info: Server Triggers  (Read 8134 times)
Mohican
Order of the Stick
Former XR Dev
Legendary Member
*****
Posts: 2647



View Profile
« on: January 07, 2011, 02:38:17 am »

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):

Code:
   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')
« Last Edit: January 22, 2011, 06:31:23 am by Mohican » Logged

Mohican
Order of the Stick
Former XR Dev
Legendary Member
*****
Posts: 2647



View Profile
« Reply #1 on: January 22, 2011, 06:19:11 am »

Latest News on the Trigger System:

 - A library of triggers is now available in the folder /game/python/triggers/library.
    To use any of those triggers, just copy them to /game/python/triggers.

 - All stats recording is now done with triggers, check the library for files called "record_***.py"
    This will make customisation by server admins much easier.

Cheers, Moh
Logged

Mohican
Order of the Stick
Former XR Dev
Legendary Member
*****
Posts: 2647



View Profile
« Reply #2 on: January 22, 2011, 06:23:37 am »

If you have questions about Triggers, please ask them here!
I will answer them and keep a record in the FAQ section of the first post on this thread.

Questions by Groentjuh:

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!
Logged

Groentjuh
Newerth Serveradmin, German Mirror and Webdeveloper
Administrator
Super Hero Member
*****
Posts: 1350


View Profile WWW
« Reply #3 on: January 29, 2011, 10:49:23 am »

The recent updates in python are causing the following error in the default python systems.
Quote
Cmd_Register Error: Command triggerlist already exists
Logged


Before adding any of my IMs, ask yourself: Can I ask it in a PM?
Before sending me a PM with questions, Search the forums!
Wanna be ref? Post on my Server Forum
Mohican
Order of the Stick
Former XR Dev
Legendary Member
*****
Posts: 2647



View Profile
« Reply #4 on: January 29, 2011, 02:01:53 pm »

The recent updates in python are causing the following error in the default python systems.
Quote
Cmd_Register Error: Command triggerlist already exists

Don't worry about it.
It's the command for regular triggers, not python ones.
The code to register that function is wrongly called multiple times.
Logged

Crashday
XR Coder
Sr. Member
***
Posts: 351


soundcloud.com/bernhardfritz


View Profile
« Reply #5 on: May 22, 2012, 09:36:53 pm »

Is it possible to make a trigger which automatically changes to evolution mod on maps which start with xr_ ?
Logged

Crashday
XR Coder
Sr. Member
***
Posts: 351


soundcloud.com/bernhardfritz


View Profile
« Reply #6 on: May 23, 2012, 01:38:44 pm »

Is it possible to make a trigger which automatically changes to evolution mod on maps which start with xr_ ?

nvm i found another solution!
Logged

Daemon
XR Main Developer
Legendary Member
****
Posts: 4723


beware, for this is the everbroken...


View Profile
« Reply #7 on: May 23, 2012, 01:44:55 pm »

Be a frand and let us know how you did it Smiley. Thanks.
Logged

Groentjuh
Newerth Serveradmin, German Mirror and Webdeveloper
Administrator
Super Hero Member
*****
Posts: 1350


View Profile WWW
« Reply #8 on: May 23, 2012, 02:16:47 pm »

By reading the config files that came with the XR server...
Logged


Before adding any of my IMs, ask yourself: Can I ask it in a PM?
Before sending me a PM with questions, Search the forums!
Wanna be ref? Post on my Server Forum
Crashday
XR Coder
Sr. Member
***
Posts: 351


soundcloud.com/bernhardfritz


View Profile
« Reply #9 on: May 23, 2012, 06:11:58 pm »

go to /game/mods/prefix/xr.cfg and exchange xr with evolution like this:


Code:
// -- INSTRUCTIONS --
//This file contain the settings for a mod.
//To enabled this mod, execute this file in server_maps_lookup.cfg as descripted in server_maps_lookup.cfg

// -- WARNING --
//Do not edit this file! All changes WILL BE REVERTED DURING THE NEXT UPDATE!

set map_prefix_#map_prefix_last# "xr_" //Map prefix of the mod's maps
set map_objpath_#map_prefix_last# "evolution/" //Relative path to script files, in gamescript
set map_objlist_#map_prefix_last# "Evolution.objlist" //Specific list of objects to be loaded from objects
set map_gametype_#map_prefix_last# "RTSS" //Type that appears when using the Game Info button
set map_config_#map_prefix_last# "Evolution_normal.cfg" //Gametype config located in objpath folder
set map_devmode_#map_prefix_last# "Evolution_dev.cfg" //Gametype(dev-world) config located in objpath folder
set map_user_#map_prefix_last# "Evolution_user.cfg" //Optional user settings read when server loads map
set map_tag_#map_prefix_last# "^900XR" //Version of the server which appears in the serverlist

inc map_prefix_last 1

// -- WARNING --
//Do not edit this file! All changes WILL BE REVERTED DURING THE NEXT UPDATE!
Logged

Groentjuh
Newerth Serveradmin, German Mirror and Webdeveloper
Administrator
Super Hero Member
*****
Posts: 1350


View Profile WWW
« Reply #10 on: May 23, 2012, 08:31:37 pm »

go to /game/mods/prefix/xr.cfg and exchange xr with evolution like this:
Code:
// -- INSTRUCTIONS --
//This file contain the settings for a mod.
//To enabled this mod, execute this file in server_maps_lookup.cfg as descripted in server_maps_lookup.cfg

// -- WARNING --
//Do not edit this file! All changes WILL BE REVERTED DURING THE NEXT UPDATE!
[....]
It would be better to copy and then modify that file so the Auto-updater will not revert your changes.
Read the instructions! Those aren't there for nothing! In server_maps_lookup.cfg you can change the exec line to point to your copied version!
Logged


Before adding any of my IMs, ask yourself: Can I ask it in a PM?
Before sending me a PM with questions, Search the forums!
Wanna be ref? Post on my Server Forum
Crashday
XR Coder
Sr. Member
***
Posts: 351


soundcloud.com/bernhardfritz


View Profile
« Reply #11 on: May 23, 2012, 08:55:14 pm »

but i want it only for maps with prefix "xr_" not for all maps
Logged

Daemon
XR Main Developer
Legendary Member
****
Posts: 4723


beware, for this is the everbroken...


View Profile
« Reply #12 on: May 23, 2012, 11:41:29 pm »

I think Groen means that whenever an update occurs, your file will be reverted to the default one. So you should link to another .cfg file you create, instead of using the old one, so it doesn't get overwritten by the AU.
Logged

Crashday
XR Coder
Sr. Member
***
Posts: 351


soundcloud.com/bernhardfritz


View Profile
« Reply #13 on: May 24, 2012, 11:14:17 am »

hmm and where should i link to it? i guess not in the same file, when everything gets overwritten at each update...
Logged

Daemon
XR Main Developer
Legendary Member
****
Posts: 4723


beware, for this is the everbroken...


View Profile
« Reply #14 on: May 24, 2012, 11:20:03 am »

go to /game/mods/prefix/xr.cfg and exchange xr with evolution like this:
Code:
// -- INSTRUCTIONS --
//This file contain the settings for a mod.
//To enabled this mod, execute this file in server_maps_lookup.cfg as descripted in server_maps_lookup.cfg

// -- WARNING --
//Do not edit this file! All changes WILL BE REVERTED DURING THE NEXT UPDATE!
[....]

server_maps_lookup.cfg, perhaps. Tongue
Logged

Pages: [1] 2 Go Up Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.041 seconds with 19 queries.