Cartman-2000's Sven Co-op server forum
http://sc.cartman-2000.net/forum/

toonrun1
http://sc.cartman-2000.net/forum/viewtopic.php?f=7&t=2042
Page 1 of 1

Author:  Balimbanana [ Sat Mar 14, 2015 7:28 pm ]
Post subject:  toonrun1

I am wondering if you could either change the start level whenever the server crashes, or use an auto-restart script that selects a random map from a list. It is unfortunate when there are 6 or so players on the server and it goes to toonrun1, almost always everyone leaves because everyone has played it many times. It isn't that bad of a map, it has just been played too many times.
I had created this script a while ago that allows for auto-restart and random map (generated via mapcycle.txt). I am sure there are better scripts or programs out there, but it would be nice to not have to play toonrun1 everytime.
This script was used on an Ubuntu server.

Code:
#!/bin/bash

steamhldsvalve=/steam/valve
steamcmddir=/steam

a=()
for k in $( cat $steamhldsvalve/svencoop/mapcycle.txt ); do
   k=${k//" "}
   k=${k//"-HL_OpFor_SP_Portal"/"sc_tetris1"}
   k=${k//"-blueshift"/"sc_royals1"}
   k=${k//"-They_Hunger_Ep1"/"svencoop1"}
   a+=("$k")
done

cd $steamhldsvalve
i=1

libchecker ()
{
if [ 'uname -m' == 'x86_64' ]
   then
      libarchitecture=/lib/&&updater
   else
      libarchitecture=/lib32/&&updater
fi
}

updater ()
{
echo "($(date +"%T")) ($(date +"%m-%d-%y")) Updating/installing HLDS" >> ./autoscript.log
   $steamcmddir/steamcmd.sh +login anonymous +force_install_dir "$steamhldsvalve" +app_update 90 validate +quit
echo "($(date +"%T")) ($(date +"%m-%d-%y")) Update/installation Complete" >> ./autoscript.log
reds
}

reds ()
{
b=${a[$RANDOM % ${#a[@]} ]}
echo "($(date +"%T")) ($(date +"%m-%d-%y")) Starting on $b" >> ./autoscript.log
   LD_LIBRARY=$libarchitecture ./hlds_run -game svencoop +map $b +maxplayers 10 +sv_lan 0 -adminsfile=notdeladmins.txt -port 27016 -heapsize 512000 -num_edicts 8192 +sys_ticrate 64 -insecure -norestart
echo "($(date +"%T")) ($(date +"%m-%d-%y")) Crashed $i times, restarting..." >> ./autoscript.log
let "i+=1"
reds
}

libchecker

exit $?


The variable "$steamhldsvalve" must point to where hlds_run is, and the variable "$steamcmddir" must point to where steamcmd.sh is.
Maps that start with "-" do not work correctly in the script, so I have replaced them with other default maps. If you have any custom maps that start with "-", I suggest adding:
k=${k//"-custommap"/"adifferentmap"}

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/