codmngr.tcl

codmngr.tcl

With this script you can start/stop your COD server and/or your Teamspeak server using simple commands on your IRC channel.

Postat de Copyright Categorie Review user Vizualizari Data
btc Nonoo games Cod netestat 553 2023-12-24 23:47:22

# codmngr.tcl - Call Of Duty server & Teamspeak starter script
#
# Copyright (C) 2006 Nonoo <[email protected]>
# http://www.nonoo.hu/codstats/
#
# WHAT'S THIS?
#
# With this script you can start/stop your COD server and/or your
# Teamspeak server using simple commands on your IRC channel.
#
# KNOWN ISSUES
#
# If your bot dies and the COD/Teamspeak server has started by eggdrop,
# the process may stuck, so you have to manually kill the COD/Teamspeak
# server and eggdrop.
#
# INSTALLATION
#
# 1. Edit this tcl file at the SETTINGS section below
# 2. Copy the tcl to your eggdrop's scripts directory
# 3. Edit your eggdrop's config and append this line to the end of the
#    file: source scripts/codmngr.tcl
# 4. Rehash your bot's config file (.rehash)
#
# CHANNEL COMMANDS
#
# !codstart (!startcod) - starts cod server
# !codstop (!stopcod) - stops cod server
# !tsstart (!startts) - starts teamspeak server
# !tsstop (!stopts) - stops teamspeak server
#
# LICENSE INFO
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

################
### SETTINGS ###
################

# important settings - you should change them
set CODCHAN "#codchannel"
set CODSERVERPATH "/usr/games/coduo"
set CODSERVERCMDLINE "+exec server.cfg +set fs_game awe_uo"
set BOTPATH "~/eggdrop"
set TSENABLED "1"
set TSPATH "/usr/games/tss2_rc2"

# not so important settings - usually you don't have to change them
set CODSERVERBIN "coduo_lnxded"
set TSBIN "teamspeak2-server_startscript"
set TSSTARTCMDLINE "start"
set TSSTOPCMDLINE "stop"

###############################################################
### usually you don't need to edit anything below this line ###
###############################################################

proc codstart {nick userhost handle channel text} {
    global CODSERVERCMDLINE CODSERVERPATH CODCHAN CODSERVERBIN BOTPATH

    if {$channel != $CODCHAN} { return }

    if {[catch {exec pidof $CODSERVERBIN}]} {
	cd $CODSERVERPATH
	exec "./$CODSERVERBIN" $CODSERVERCMDLINE >/dev/null 2>/dev/null &
	cd $BOTPATH
	puthelp "PRIVMSG $CODCHAN :* server has been started"
    } else {
	puthelp "PRIVMSG $CODCHAN :* server is running"
    }
}

proc codstop {nick userhost handle channel text} {
    global CODCHAN CODSERVERBIN

    if {$channel != $CODCHAN} { return }

    if {[catch {exec pidof $CODSERVERBIN}]} {
	puthelp "PRIVMSG $CODCHAN :* server is not running"
    } else {
	exec killall $CODSERVERBIN
	puthelp "PRIVMSG $CODCHAN :* server stopped"
    }
}

proc tsstart {nick userhost handle channel text} {
    global CODCHAN TSPATH BOTPATH TSSTARTCMDLINE TSBIN

    if {$channel != $CODCHAN} { return }

    cd $TSPATH
    if {[catch [exec "./$TSBIN" $TSSTARTCMDLINE >/dev/null 2>/dev/null]]} {
        puthelp "PRIVMSG $CODCHAN :* teamspeak server is running"
    } else {
        puthelp "PRIVMSG $CODCHAN :* teamspeak server has been started"
    }
    cd $BOTPATH
}

proc tsstop {nick userhost handle channel text} {
    global BOTPATH CODCHAN TSPATH TSBIN TSSTOPCMDLINE

    if {$channel != $CODCHAN} { return }

    cd $TSPATH
    if {[catch [exec "./$TSBIN" $TSSTOPCMDLINE >/dev/null 2>/dev/null]]} {
        puthelp "PRIVMSG $CODCHAN :* teamspeak server is not running"
    } else {
        puthelp "PRIVMSG $CODCHAN :* teamspeak server has been stopped"
    }
    cd $BOTPATH
}

bind pub o|o !codstart codstart
bind pub o|o !codstop codstop
bind pub o|o !startcod codstart
bind pub o|o !stopcod codstop
if {$TSENABLED} {
    bind pub o|o !tsstart tsstart
    bind pub o|o !tsstop tsstop
    bind pub o|o !startts tsstart
    bind pub o|o !stopts tsstop
} else {
    catch {unbind pub o|o !stopts tsstop}
    catch {unbind pub o|o !tsstop tsstop}
    catch {unbind pub o|o !startts tsstart}
    catch {unbind pub o|o !tsstart tsstart}
}

putlog "codmngr.tcl v1.1.1 loaded."