This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

qstat map change notify

Old posts that have not been replied to for several years.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

last version + added to tcl archive

multi-game,mutli-server and mutli-irc-channel.
lot of it is overkill but it gave me something to do during my holiday

Code: Select all

#########################################################################
#                   qstat map change notify script                      #
#                  this is a TCL script for eggdrop                     #
#         written by Lee (Moonunit) Donaghy lee295012@yahoo.com         #
#               Titan Internet 32 Player Onslaught server               #
#  ut2004://217.77.176.198:7777 http://ut2004.titaninternet.co.uk/vbb/  #
#########################################################################

# set your qstatpath
set qstatpath "/usr/local/bin/qstat"

# number of servers to check
set server_number 1

# edit the mapchangenotify.serverlist file
# ie.
# -ut2s
# 123.123.123.123:7777
# now running on myonslaught server
# #myirchannel
# -ut2s
# etc...
set mcn_version "v0.1.1"

###############################################################
# TCL code begins, don't edit unless you know what your doing #
###############################################################
putlog "mapchangenotify $mcn_version loaded"

# read server list 
set slname "mapchangenotify.serverlist"
set slct [open $slname "r"]
set sdlist [split [read $slct] \n]
close $slct

#---------------------------------------------------------------------
# create server files if they don't exist
set cfc 0
while { $cfc != $server_number } {
if {![file exists mapchange]} {
set fname "mapchangenotify$cfc.output"
set fp [open $fname "w"]
close $fp
incr cfc
}
}
#---------------------------------------------------------------------
bind time - * qstatrun ;# runs every minute
proc qstatrun {m h d mo y} {
global qstatpath
global server_number
global slct
global sl
global sdlist

set server_count 0
set slcount 0
while {$server_count != $server_number} {

# read old map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set qstatxmlfile [split [read $fp] \n]
close $fp

#-------------------------------------------------------------------------
# using regex to find the right lines, yeah i know 50 lines is over kill.
set qstatxmlgameline 50
set qstatxmlmapline 50
set findrightlines 0
set findrightlinesmax 50
while { $findrightlines != $findrightlinesmax } {
set poon [lindex $qstatxmlfile $findrightlines]
if { [regexp "<map>(.*)</map>" $poon] == 1} {
set qstatxmlmapline $findrightlines
} 
incr findrightlines
}
#-------------------------------------------------------------------------

set mapline [lindex $qstatxmlfile $qstatxmlmapline]

# strip out <map> and <\map>
set oldmap [string range $mapline 7 [expr [string length $mapline] - 7]]

#-------------------------------------------------------------------------
# set server list 
set qstatgametype [lindex $sdlist $slcount] ; incr slcount
set qstatserverip [lindex $sdlist $slcount] ; incr slcount
set qstataddedtext [lindex $sdlist $slcount] ; incr slcount
set qstatircchan [lindex $sdlist $slcount] ; incr slcount

#-------------------------------------------------------------------------
exec $qstatpath $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set qstatxmlfile [split [read $fp] \n]
close $fp

#-------------------------------------------------------------------------
# using regex to find the right lines, yeah i know 50 lines is over kill.
set qstatxmlgameline 50
set qstatxmlmapline 50
set findrightlines 0
set findrightlinesmax 50
while { $findrightlines != $findrightlinesmax } {
set poon [lindex $qstatxmlfile $findrightlines]
if { [regexp "<map>(.*)</map>" $poon] == 1} {
set qstatxmlmapline $findrightlines
} 
if { [regexp "<gametype>(.*)</gametype>" $poon] == 1} {
set qstatxmlgameline $findrightlines
} 
incr findrightlines
}
#-------------------------------------------------------------------------

set gametypeline [lindex $qstatxmlfile $qstatxmlgameline]
set mapline [lindex $qstatxmlfile $qstatxmlmapline]

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
# strip out <gametype> and <\gametype>
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]


#--------------------------------------------------------------------------
# if qstat hit the server at the wrong time nothing is returned so having another crack at it
set recheckbreak 0
set mlbroken 0
while {[string length $mapline] < 1} {
exec /usr/local/bin/qstat $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set qstatxmlfile [split [read $fp] \n]
close $fp

#------------------------------------------------------------------------
# using regex to find the right lines, yeah i know 50 lines is over kill.
set qstatxmlgameline 50
set qstatxmlmapline 50
set findrightlines 0
set findrightlinesmax 50
while { $findrightlines != $findrightlinesmax } {
set poon [lindex $qstatxmlfile $findrightlines]
if { [regexp "<map>(.*)</map>" $poon] == 1} {
set qstatxmlmapline $findrightlines
} 
if { [regexp "<gametype>(.*)</gametype>" $poon] == 1} {
set qstatxmlgameline $findrightlines
} 
incr findrightlines
}
#------------------------------------------------------------------------

set gametypeline [lindex $qstatxmlfile $qstatxmlgameline]
set mapline [lindex $qstatxmlfile $qstatxmlmapline]

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
# strip out <gametype> and <\gametype>
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]
incr recheckbreak
if {$recheckbreak == 10} { set mlbroken 1 ; break }
}
#-----------------------------------------------------------------------------------------------------------------------------------------

incr server_count

if {$newmap != $oldmap && $mlbroken == 0 }  {
     puthelp "PRIVMSG $qstatircchan :$newmap $qstataddedtext ($gametype)"
   }
}
}
Locked