Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 717

Warning: Invalid argument supplied for foreach() in /var/www/ct/forums/wiki/includes/MagicWord.php on line 718

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 722

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /var/www/ct/forums/wiki/includes/MagicWord.php on line 739
Crazy Tronners Wiki - Configure a wild server

Configure a wild server

From Tronwiki
Jump to: navigation, search
Line 3: Line 3:
 
Here is a copy of what ed said
 
Here is a copy of what ed said
  
A question I get asked quite reguarly. I usually just say it's a php/mysql script written by PTA. You can get the same results with one I wrote here, it's just not as easy to admin:
+
A question I get asked quite reguarly. I usually just say it's a php/mysql script written by PTA. You can get the same results with one I wrote here, it's just not as easy to admin:
 
[[http://tron.plantpeanuts.co.uk/viewtopic.php?t=42 |http://tron.plantpeanuts.co.uk/viewtopic.php?t=42]]
 
[[http://tron.plantpeanuts.co.uk/viewtopic.php?t=42 |http://tron.plantpeanuts.co.uk/viewtopic.php?t=42]]
  
Line 35: Line 35:
 
Although it's not considered good practice and the file itself tells you not to do it, I go ahead and modify the file settings_dedicated, changing TALK_TO_MASTER to 1 so your server appears on the main server list. And change server name, etc to your own. And a few others I add, like:
 
Although it's not considered good practice and the file itself tells you not to do it, I go ahead and modify the file settings_dedicated, changing TALK_TO_MASTER to 1 so your server appears on the main server list. And change server name, etc to your own. And a few others I add, like:
  
CYCLE_RUBBER_WALL_SHRINK 0.5
+
  CYCLE_RUBBER_WALL_SHRINK 0.5
CYCLE_RUBBER_WALL_SHRINK_OVERRIDE 0
+
  CYCLE_RUBBER_WALL_SHRINK_OVERRIDE 0
  
 
the important line to add at the base of the file is:
 
the important line to add at the base of the file is:
Line 46: Line 46:
 
to run this server I have a simple bash script to make it easier for myself. This looks like:
 
to run this server I have a simple bash script to make it easier for myself. This looks like:
  
Code:
+
Code:
#!/bin/sh
+
#!/bin/sh
 
+
tron="/home/ed/tron/bin/armagetronad-dedicated"
+
tron="/home/ed/tron/bin/armagetronad-dedicated"
config="/home/ed/wild/config"
+
config="/home/ed/wild/config"
var="/home/ed/wild/var"
+
var="/home/ed/wild/var"
log="/home/ed/wild/log/wildlog.txt"
+
log="/home/ed/wild/log/wildlog.txt"
 
+
$tron --configdir $config --vardir $var | tee -a $log
+
$tron --configdir $config --vardir $var | tee -a $log
  
  
Line 105: Line 105:
 
The second everytime.cfg is kept in:
 
The second everytime.cfg is kept in:
  
/home/ed/wild/var/everytime.cfg
+
/home/ed/wild/var/everytime.cfg
  
 
This is the one that changes the map file at the end of every round. I just copied from it now and it says:
 
This is the one that changes the map file at the end of every round. I just copied from it now and it says:
  
Code:
+
Code:
MAP_FILE ed/fortress/slingshot-0.0.1.aamap.xml
+
MAP_FILE ed/fortress/slingshot-0.0.1.aamap.xml
ROUND_CENTER_MESSAGE Round 5 - Slingshot
+
ROUND_CENTER_MESSAGE Round 5 - Slingshot
  
  
 
Lets try it now, it says:
 
Lets try it now, it says:
  
Code:
+
Code:
MAP_FILE ed/fortress/chico_time-0.1.4.aamap.xml
+
MAP_FILE ed/fortress/chico_time-0.1.4.aamap.xml
ROUND_CENTER_MESSAGE Round 6 - It's Chico Time
+
ROUND_CENTER_MESSAGE Round 6 - It's Chico Time
  
  
Line 127: Line 127:
 
I created a folder called /home/ed/mapscript
 
I created a folder called /home/ed/mapscript
 
in here we have four files:
 
in here we have four files:
start_map.sh
+
start_map.sh
mapcycle2.sh
+
mapcycle2.sh
tron.class.php
+
tron.class.php
tron.php
+
tron.php
  
 
It all starts with the bash script start_map.sh that looks like this. I run this one in a new screen session:
 
It all starts with the bash script start_map.sh that looks like this. I run this one in a new screen session:
  
Code:
+
Code:
#!/bin/sh
+
#!/bin/sh
log="/home/ed/wild/log/wildlog.txt"
+
log="/home/ed/wild/log/wildlog.txt"
 
+
tail -n1 -f $log | /home/ed/mapscript/mapcycle2.sh
+
tail -n1 -f $log | /home/ed/mapscript/mapcycle2.sh
 
+
 
+
 
This will take each line of the wildlog.txt and feed it into mapcycle2.sh that looks like this:
 
This will take each line of the wildlog.txt and feed it into mapcycle2.sh that looks like this:
  
Code:
+
Code:
#!/bin/bash
+
#!/bin/bash
 
+
while true
+
while true
do
+
  do
  line=""
+
  line=""
  read line
+
  read line
  echo $line
+
  echo $line
  /home/ed/mapscript/tron.php "$line"
+
    /home/ed/mapscript/tron.php "$line"
done
+
  done
  
  
 
This will take each line and feed it to tron.php that looks like this. It will also output to screen so I can see any error message, etc:
 
This will take each line and feed it to tron.php that looks like this. It will also output to screen so I can see any error message, etc:
  
Code:
+
Code:
#!/usr/bin/php
+
#!/usr/bin/php
<?php
+
<?php
$line=$argv[1];
+
$line=$argv[1];
 
+
include("tron.class.php");
+
include("tron.class.php");
$tron=new tron;
+
$tron=new tron;
$tron->mysql_start();
+
$tron->mysql_start();
 
+
if (substr($line,0,13)=="[0] Go (round"){
+
if (substr($line,0,13)=="[0] Go (round"){
        for ($i=1;$i<13;$i++){
+
        for ($i=1;$i<13;$i++){
                if ($line=="[0] Go (round ".$i." of 12 )!"){
+
                if ($line=="[0] Go (round ".$i." of 12 )!"){
                        if ($i==12){
+
                        if ($i==12){
                                $tron->map_cycle(1);
+
                                $tron->map_cycle(1);
                        } else {
+
                        } else {
                                $tron->map_cycle($i+1);
+
                                $tron->map_cycle($i+1);
                        }
+
                        }
                }
+
                }
        }
+
        }
}
+
}
 
+
?>
+
?>
  
  
 
This calls upon tron.class.php that looks like this:
 
This calls upon tron.class.php that looks like this:
  
Code:
+
Code:
class tron {
+
class tron {
 +
 +
//
 +
// Start Config
  
//
+
var $cfg_host="localhost";
// Start Config
+
var $cfg_user="mysqlusername";
 +
var $cfg_pw="mysqlpassword";
 +
var $cfg_db="tron";
 +
var $cfg_file="/home/ed/wild/var/everytime.cfg";
 +
 +
//
 +
//
 +
// End Config
 +
//
 +
//
  
var $cfg_host="localhost";
+
function mysql_start(){
var $cfg_user="mysqlusername";
+
        mysql_connect($this->cfg_host,$this->cfg_user,$this->cfg_pw);
var $cfg_pw="mysqlpassword";
+
        mysql_select_db($this->cfg_db);
var $cfg_db="tron";
+
}
var $cfg_file="/home/ed/wild/var/everytime.cfg";
+
 +
function mysql_stop(){
 +
        mysql_close();
 +
}
  
//
+
function map_cycle($round){
//
+
        $mapquery=mysql_query('SELECT * FROM maps WHERE  round="'.$round.'"');
// End Config
+
        $maps=mysql_num_rows($mapquery);
//
+
        srand ((double)microtime()*1000000);
//
+
        $mapnumber = rand(0,$maps-1);
 +
        $mapname=mysql_result($mapquery,$mapnumber,'maps.mapname');
 +
        $mapfile=mysql_result($mapquery,$mapnumber,'maps.mapfile');
 +
        if ($round==12){
 +
                  $content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE Final Round - ".$mapname."\n";
 +
        }else{
 +
                $content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE  Round ".$round.' - '.$mapname."\n";
 +
        }
 +
        $this->filewrite($content,'new');
 +
}
 +
 +
function filewrite($content,$mode){
 +
        if ($mode=="new") {
 +
                $execfile=fopen ($this->cfg_file,'w+');
 +
        } else if ($mode=="add"){
 +
                $execfile=fopen ($this->cfg_file,'a+');
 +
        }
 +
        fputs($execfile,$content);
 +
        fclose($execfile);
 +
        echo $content;
 +
}
  
function mysql_start(){
+
}
        mysql_connect($this->cfg_host,$this->cfg_user,$this->cfg_pw);
+
?>
        mysql_select_db($this->cfg_db);
+
}
+
 
+
function mysql_stop(){
+
        mysql_close();
+
}
+
 
+
function map_cycle($round){
+
        $mapquery=mysql_query('SELECT * FROM maps WHERE round="'.$round.'"');
+
        $maps=mysql_num_rows($mapquery);
+
        srand ((double)microtime()*1000000);
+
        $mapnumber = rand(0,$maps-1);
+
        $mapname=mysql_result($mapquery,$mapnumber,'maps.mapname');
+
        $mapfile=mysql_result($mapquery,$mapnumber,'maps.mapfile');
+
        if ($round==12){
+
                $content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE Final Round - ".$mapname."\n";
+
        }else{
+
                $content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE Round ".$round.' - '.$mapname."\n";
+
        }
+
        $this->filewrite($content,'new');
+
}
+
 
+
function filewrite($content,$mode){
+
        if ($mode=="new") {
+
                $execfile=fopen ($this->cfg_file,'w+');
+
        } else if ($mode=="add"){
+
                $execfile=fopen ($this->cfg_file,'a+');
+
        }
+
        fputs($execfile,$content);
+
        fclose($execfile);
+
        echo $content;
+
}
+
 
+
}
+
?>
+
  
  
Line 245: Line 245:
 
I get this:
 
I get this:
  
Code:
+
Code:
 
+
mysql> select * from maps;
+
mysql> select * from maps;
+----+-------+----------------------------------------------------------+-------------------------+---------------+
+
  +----+-------+----------------------------------------------------------+-------------------------+---------------+
 
  | id | round | mapfile                                                  | mapname                | server        |
 
  | id | round | mapfile                                                  | mapname                | server        |
 
  +----+-------+----------------------------------------------------------+-------------------------+---------------+
 
  +----+-------+----------------------------------------------------------+-------------------------+---------------+

Revision as of 02:48, 2 November 2006

Personal tools