egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

qstat map change notify
Goto page Previous  1, 2, 3
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Tue Jul 26, 2005 11:54 am    Post subject: Reply with quote

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:
#########################################################################
#                   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)"
   }
}
}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber