rotation script

Post here if you need help setting up your server, etc.
snake
Average Program
Posts: 59
Joined: Thu Oct 13, 2011 6:24 am

rotation script

Post by snake »

Hi again,

I'm trying to make a race server with the map changing every 3 rounds, but i cant get the script to work.
I did exactly what was said in the wiki here: http://wiki.armagetronad.org/index.php/ ... u_Computer
I hope anyone can help me.

thx in advance,
$NAK3

snake
Average Program
Posts: 59
Joined: Thu Oct 13, 2011 6:24 am

Re: rotation script

Post by snake »

Anyone ?

User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1860
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: rotation script

Post by kyle »

need a more detailed description of the problem
Image

User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6709
Joined: Thu Dec 18, 2003 7:03 pm

Re: rotation script

Post by Tank Program »

E.g., error messages, the exact steps you have taken, what happens instead of what you expect. (Does it change after 4 rounds, 2 rounds, every round, etc.?)
Image

User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

Re: rotation script

Post by nelg »

Snake, youve aready asked me on tron… you probley just aren't using my advice correctly.
Last edited by nelg on Wed May 02, 2012 10:05 pm, edited 1 time in total.
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

Re: rotation script

Post by nelg »

Tank Program wrote:E.g., error messages, the exact steps you have taken, what happens instead of what you expect. (Does it change after 4 rounds, 2 rounds, every round, etc.?)
He said the script doesn't do ANYTHING... he didn't say it didn't not work INCORRECTLY
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

User avatar
Jonathan
A Brave Victim
Posts: 3392
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: rotation script

Post by Jonathan »

nelg wrote:He said the script doesn't do ANYTHING...
All I see is he can't get the script to work. If he said it elsewhere, why are you battering Tank Program?
nelg wrote:he didn't say it didn't not work INCORRECTLY
Did this really just happen? What you're saying is he didn't deny that the script works correctly.

Anyway, this stuff isn't my forte so I can't be too specific, but more information is definitely needed. Those instructions presumably work for many people; if it simply "doesn't work" for you, all people can say to that is "works for me." The best way to start if you're clueless is to state exactly what you've done. Don't skip anything that seems obvious to you, because others do do things differently, and this sort of miscommunication is precisely what makes problems hard to solve.
ˌɑrməˈɡɛˌtrɑn

User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1860
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: rotation script

Post by kyle »

well what does the screen with

Code: Select all

./start_race_parser.sh
say?
Image

User avatar
Phytotron
Formerly Oscilloscope
Posts: 5041
Joined: Thu Jun 09, 2005 10:06 pm
Location: A site or situation, especially considered in regard to its surroundings.
Contact:

Re: rotation script

Post by Phytotron »

Jonathan wrote:
nelg wrote:he didn't say it didn't not work INCORRECTLY
Did this really just happen?
That did not just happen!

Laughed equally hard at both. Or, I didn't not say I didn't not laugh unequally soft at neither.

User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

Re: rotation script

Post by nelg »

LOL! ''What you're saying is he didn't deny that the script works correctly.''


Thx for the movie: ''weeee.....THAT DID NOT JUST HAPPEN''
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

snake
Average Program
Posts: 59
Joined: Thu Oct 13, 2011 6:24 am

Re: rotation script

Post by snake »

Ill try to explain exactly what i did:

I setup a ubuntu vps and installed armagetron. I made multiple servers by that same wiki by making a start.sh script and different folders for the different gametypes/servers. All of that works and here are the 2 files that i use to start a normal server:

Command:

Code: Select all

./start.sh [server name]
start.sh:

Code: Select all

#!/bin/bash

loc="/home/dodedodo/armagetronad"

# If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in
# the /home/<your_username>/armagetrnad/servers directory will be started

if [ "$1" != "" ]; then
     screen -S $1 -X quit                               # Kill the window if it exists already, avoiding to run the same server twice
     screen -dmS $1 $loc/scripts/srv.sh $1                       # start a GNU screen window with the specified server inside
else
      for f in $(ls $loc/scripts/servers/.)      # start a loop running the following command for any existing folders in the
#/home/<your_username>/armagetronad/servers folder
               do
                      screen -S $f -X quit                              # Kill the window if it exists already, avoiding to run the same server twice
                      screen -dmS $f $loc/scripts/srv.sh $f     # start a GNU screen window with the server inside for each server folder
               done                                                     # ends the loop
fi

I assume this file redirrects to a second file i created called srv.sh:

Code: Select all

!/bin/bash

loc="/home/dodedodo/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
vardir=$loc"/servers/"$1"/var"
userconfigdir=$loc"/servers/"$1"/settings"
resourcedir=$loc"/servers/"$1"/resource/"
datapath=$loc"/servers/"$1"/var"

mkdir $loc"/servers/"$1"/logs"
screen -S $1 -X logtstamp on                                    # print timestamps in log file
screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log     # create a logfile in the logs subf
screen -S $1 -X log on                                  # Turn on logging for the server window
while true; do                                          # start a loop to allow server restart if it crashes

#Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
# in /home/vertrex/armagetronad/bin directory.

        $tron --vardir $vardir
        $tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir

# Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
      echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
      sleep 5
            done # end the loop


I have mado those executable to .







Now i have tried to make a racing server with a script that should rotate the map every 3 rounds (1 match). I made 3 files for this: race_rotation.php race_srv.sh and race_start.sh.

Again i use

Code: Select all

race_start.sh [server name]
to start the server

race_start.sh:

Code: Select all

#!/bin/bash

loc="/home/dodedodo/armagetronad"
# If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in the /home/<your_username>/armagetrnad-0.2.8/servers di$
# will be started
if [ "$1" != "" ]; then
      screen -S $1 -X quit                             # Kill the window if it exists already, avoiding to run the same server twice
      screen -dmS $1 $loc/scripts/race_srv.sh $1                     # start a GNU screen window with the specified server inside
else
      for f in $(ls $loc/scripts/servers/.)     # start a loop running the following command for any existing folders in the
# /home/<your_username>/armagetronad/servers folder
               do
                      screen -S $f -X quit                             # Kill the window if it exists already, avoiding to run the same server twice
                      screen -dmS $f $loc/scripts/race_srv.sh $f    # start a GNU screen window with the server inside for each server folder
               done                                                    # ends the loop
fi

And again i assume it redirrects to race_srv.sh

race_srv.sh:

Code: Select all

#!/bin/bash

loc="/home/dodedodo/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
vardir=$loc"/servers/"$1"/var/"
log=$var"console_log.txt"
userconfigdir=$loc"/servers/"$1"/settings/"
resourcedir=$loc"/servers/"$1"/resource"
parser=$loc"/scripts/race_rotation.php"
ladderlog=$var"ladderlog.txt"
cmd=$loc"/scripts/cmd.txt"

mkdir $loc"/servers/"$1"/logs"
screen -S $1 -X logtstamp on                                    # print timestamps in log file
screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log     # create a logfile in the logs subf
screen -S $1 -X log on                                  # Turn on logging for the server window
while true; do                                          # start a loop to allow server restart if it crashes

#Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
# in /home/vertrex/armagetronad/bin directory.

tail -f $ladderlog | $parser | $tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir | tee -a $log

#$tron --help

# Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
      echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
      sleep 5
           done # end the loop

I assume race_srv.sh should include race_rotation.php

race_rotation.php:

Code: Select all

#!/usr/bin/php
<?php
$maps=array("turtle/adventure/chasm_f-0.0.2.aamap.xml","turtle/adventure/island_f-0.0.2.aamap.xml");
while (1)  {
   $line = rtrim(fgets(STDIN, 1024));
   if ( preg_match( "/^ROUND_COMMENCING/", $line ) ){
       $keywords = preg_split("/ /", $line);
  $map=rand (0 , count($maps )-1);
       echo "MAP_FILE ".$maps[$map]."\n";
       echo "WAIT_FOR_EXTERNAL_SCRIPT 0\n";
       sleep(6);
       echo "WAIT_FOR_EXTERNAL_SCRIPT 1\n";
   }
}
?>
I made all the files displayed above executable.
When i start the server just nothing hapens, no error, no map change totaly nothing. Its almost ass if i used the start.sh instead of race_start.sh
And a spoiler mod on this forum would be realy grat ;)

I hope this gives you enough information and i would be rlly thankfull to any sugestions.

P.S. oh and my username is dodedodo ;)

Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: rotation script

Post by Moofie »

Try using

Code: Select all

SPAWN_SCRIPT race_rotation.php
in the server.

With that I'm sure you can use your start.sh like the other servers, but I don't know that much about race servers... but the start and srv files looked about the same...

User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1860
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: rotation script

Post by kyle »

do you have

Code: Select all

ladderlog_write_ROUND_COMMENCING 1
set in your server config
Image

snake
Average Program
Posts: 59
Joined: Thu Oct 13, 2011 6:24 am

Re: rotation script

Post by snake »

ok ill try that :)

and they are not totaly the same, srv.sh doesnt have

Code: Select all

parser=$loc"/scripts/race_rotation.php"
race_srv.sh does
Last edited by snake on Thu May 03, 2012 7:02 pm, edited 2 times in total.

snake
Average Program
Posts: 59
Joined: Thu Oct 13, 2011 6:24 am

Re: rotation script

Post by snake »

I added ladderlog_write_ROUND_COMMENCING 1 in the server cfg and it loaded correctly. Only it didnt make a difference :( Im still not getting anything from the script.

Post Reply