Contents
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Random Thumbnail
reactorlevel.jpg
Search
Login
Who Is Online?
We have 119 guests online
Navigation
Home Descent 3 Descent 3 dedicated server tool for Windows Running applications on server events
Most Recent
Featured Articles
Joomla 1.5 Featured Articles
Navigation
Home Descent 3 Descent 3 dedicated server tool for Windows Running applications on server events
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Running applications on server events E-mail
User Rating: / 18
PoorBest 
Descent 3 - Descent 3 dedicated server tool for Windows
Written by Thomas   
Sunday, 12 December 2010 22:41
Article Index
Running applications on server events
Server events reference - The [General] section
Server events reference - The [OnServerEvent] sections and variables
Server events reference - Events list part 1
Server events reference - Events list part 2
All Pages

 

D3Server3 supports the invocation of external executable files on certain events. This funcionality can for example be used to upload statistics files or perform clean-up tasks.

The currently supported events are:

  • When D3Server3 starts up.
  • When a dedicated server is started.
  • When a dedicated server is started manually (with the button Start server(s)).
  • When a dedicated server is stopped.
  • When a dedicated server is stopped manually (with any of the Stop buttons).
  • When a new level in a mission begins.
  • When a level in a mission ends.
  • When a player joins a server.
  • When a player leaves a server.
  • When a player used profanity.
  • When a player's first and second profanity threshold have been reached or exceeded.
  • When D3Server3 is closed.
  • When D3Server3 shuts down for an automatic update.
  • When D3Server3 restarted after an automatic update.
  • When a player is banned due to an entry in the hosts.deny file.
  • When a dedicated server's remote console is not responding.
  • When the statistics archiver has run.
  • Every time a server event occurrs.

 

You can run different executable files for different servers or specify a default file for all dedicated servers.

The command line provided for the events can contain environment variables. D3Server3 resolves them before the executable file is invoked, if they are enclosed in ''%' characters, like in a command-line script itself. For example, to call a batch file MyBatchFile.cmd on an event, use:

"%COMSPEC%" /C MyBatchFile.cmd

The environment variable COMSPEC points to the command-line interpreter on normal Windows operating systems (Windows NT, 2000, XP, Vista, 7, servers).

The events for invoking the external program are stored in a Windows ini file called 'ServerEvents.ini'. Each section in this file is responsible for a different event. Each key in a section specifies the name of a dedicated server, the UDP port and the name of a dedicated server, where the port and the name are separated by a colon (':'), or a default command line for any server/port.

The following example shows what the section [OnServerStart] could look like. This event occurs when a dedicated server is started. The lines are explained below the example.

  1. [OnServerStart]
  2. Default="%COMSPEC%" /C MyBatchFile.cmd
  3. 2099:This is the server name=%COMSPEC% /C MyOtherBatchFile.cmd
  4. This is the server name=%COMSPEC% /C MyLastBatchFile.cmd

The section name [OnServerStart] specifies the event the section is for. It occurs when a dedicated Descent 3 server is started.

The Default key provides a command line to execute a program for any server. In the above example, the application called is stored in the environment variable COMSPEC, which contains the full path and file name of the Windows command interpreter CMD.EXE. The variable's name is enclosed in double quotation marks in case the path contains space characters. CMD.EXE is given the command-line parameter /C to make it execute the command-line script MyBatchFile.cmd and then exit.

The next line calls the batch file MyOtherBatchFile.cmd when the server "This is the server name" runs on port 2099. Note that the server's port is separated by a colon (':') from its name.

The batch file MyLastBatchFile.cmd is called independent of the server port, but only if the server "This is the server name" is not running on port 2099, since the events are checked from top to bottom. The Default key is the only exception. It is only processed when no other event for a server could be found.

The working directory (or current directory) is the directory in which D3Server3.exe resides. Since Windows ini files use the square brackets ('[' and ']') for section names, it is currently not possible to specify server names that contain square brackets in their names.

 

A ServerEvents.ini file can contain a [General] section. If the key ShowWindow in this section has a value of HIDE, the applications are executed hidden. This can prevent their windows from popping up every time an event occurs. If ShowWindow is not HIDE, the started applications receive the focus on the desktop, which can be quite annoying if you're working on the computer when an event occurs. However, an application can opt to ignore this initial information and display its window however it likes.

 

The applications are executed one by one, and by default D3Server3 waits for each one to terminate before the next program is opened. You can change this behaviour if the application to execute itself opens another process and then terminates. D3Server3 would not know about the second application. Note that by default the server tool waits for the application's process to terminate, which is not what most other softwares do. You can also control D3Server3's behaviour by placeing a key for the event in question in the General section of the file ServerEvents.ini. They key's name must be the event name, for example OnD3Server3Start. A value of WAIT waits for the application while a value of NOWAIT just launches it without further action.

  1. [General]
  2. ShowWindow=HIDE
  3. LogEvents=TRUE
  4. OnD3Server3Close=NOWAIT
  5. OnServerManualStop=WAIT

In the example above D3Server3 is going to wait for the application that is executed when a dedicated server is stopped manually (OnServerManualStop=WAIT). In the contrary, D3Server3 would not wait for the application that is started when the server tool is closed (OnD3Server3Close=NOWAIT).

D3Server3 places the applications to execute in a queue every time the appropriate event occurs. The size of this queue is currently limited to 100. This means that D3Server3 will only hold up to 100 waiting application executions. Additional events cannot trigger the programs to be called anymore until previous processes terminate.

When D3Server3 terminates, remaining application calls are not processed. D3Server3 tries to process the [OnD3Server3Close] section right after you close the server tool. This section can only have a Default key since this event does not occur for a particular server.

 

Here's an example of a ServerEvents.ini file:

  1. [General]
  2. ShowWindow=HIDE
  3.  
  4. [OnServerStart]
  5. Default="%COMSPEC%" /C ServerEventScript.cmd
  6. 2099:This is the server name=%COMSPEC% /C batch.cmd
  7. This is the server name=%COMSPEC% /C batch.cmd
  8.  
  9. [OnServerStop]
  10. Default="%COMSPEC%" /C ServerEventScript.cmd
  11. 2099:This is the server name=%COMSPEC% /C batch.cmd
  12. This is the server name=%COMSPEC% /C batch.cmd
  13.  
  14. [OnLevelStart]
  15. Default="%COMSPEC%" /C ServerEventScript.cmd
  16. 2099:This is the server name=%COMSPEC% /C batch.cmd
  17. This is the server name=%COMSPEC% /C batch.cmd
  18.  
  19. [OnLevelEnd]
  20. Default="%COMSPEC%" /C ServerEventScript.cmd
  21. 2099:This is the server name=%COMSPEC% /C batch.cmd
  22. This is the server name=%COMSPEC% /C batch.cmd
  23.  
  24. [OnPlayerJoined]
  25. Default="%COMSPEC%" /C ServerEventScript.cmd
  26. 2099:This is the server name=%COMSPEC% /C batch.cmd
  27. This is the server name=%COMSPEC% /C batch.cmd
  28.  
  29. [OnPlayerLeft]
  30. Default="%COMSPEC%" /C ServerEventScript.cmd
  31. 2099:This is the server name=%COMSPEC% /C batch.cmd
  32. This is the server name=%COMSPEC% /C batch.cmd
  33.  
  34. [OnD3Server3Close]
  35. Default="%COMSPEC%" /C ServerEventScript.cmd

 



Last Updated on Sunday, 25 January 2015 12:58
 
You need to login or register to post comments.
Discuss this item on the forums. (0 posts)
Discuss (0 posts)