LG-Gaming Marathon
Would you like to react to this message? Create an account in a few clicks or log in to continue.


LG-Gaming Marathon Server hosted by LGrobert
 
HomeSearchLatest imagesRegisterLog in

 

 TeamSpeak Server Script

Go down 
AuthorMessage
Gast
Guest




TeamSpeak Server Script Empty
PostSubject: TeamSpeak Server Script   TeamSpeak Server Script Icon_minitimeSun Nov 30, 2008 9:54 pm

; ts2.d will write to the socket, and ts.connect ends any current connection to ts, and opens it
alias ts.connect { sockclose ts2 | if $hget(ts2) { .hfree ts2 } | sockopen ts2 $ts.ip $ts.qport | .timertsconfail 1 15 ts.sockclose cc }
alias ts2.d { if $sock(ts2) { sockwrite -n ts2 $1- } }
; ts.name gets the item in quotes, ts.rest gets the items after the quotes
alias ts.name { return $gettok($iif($gettok($1-,2,34),$ifmatch,$gettok($1-,1,34)),1,34) }
alias ts.rest { return $iif($gettok($1-,3-,34),$ifmatch,$gettok($1-,2-,34)) }
; The other aliases here are for quick referance to the configuration file
alias ts.chan { return $readini($scriptdirtsconfig.ini,general,channel) }
alias ts.slogin { return $readini($scriptdirtsconfig.ini,general,Super_Admin_Login) }
alias ts.spass { return $readini($scriptdirtsconfig.ini,general,Super_Admin_Pass) }
alias ts.qport { return $readini($scriptdirtsconfig.ini,general,TCPQuery_Port) }
alias ts.sport { return $readini($scriptdirtsconfig.ini,general,TS_Server_Port) }
alias ts.ip { return $readini($scriptdirtsconfig.ini,general,TS_IP) }
alias ts.ip.public { return $readini($scriptdirtsconfig.ini,general,TS_Public_IP) }
alias ts.timeout { return $readini($scriptdirtsconfig.ini,general,Timeout_Seconds) }
; runs the config file and asks for the first operator's name, if they are not set
on *:LOAD: {
if !%ts.ops { set %ts.ops $$?="Please enter YOUR username on IRC (Not the Bots)" }
if !$readini(tsconfig.ini,general,channel) { run notepad.exe $scriptdirtsconfig.ini }
}
; connects to TS on join
on *:join:#:if $nick == $me && # == $ts.chan { ts.connect }
on *:sockopen:ts2: { .timertsconfail off }
on *:TEXT:*:#: {
; ignores text typed anywhere except the ts channel
if # != $ts.chan { halt }
; command help
if $1- == !ts { msg # TeamSpeak Commands !TS [Command] Users, Kick, Msg, Privmsg, Operators, Ban, Banlist, Unban, Info - "!TS [command] ?" for more information. }
if $1 == !ts && $3 == ? {
if $2 == users { msg # Usage: !TS Users : Displays information about the currently connected users. }
elseif $2 == kick { msg # Usage: !TS kick "[name]" [reason] : Quotes Required : Kicks name from the server. : Limited to Channel Ops }
elseif $2 == msg { msg # Usage: !TS MSG [message] : Messages everyone on the TeamSpeak server. : Limited to Half-Ops and higher. }
elseif $2 == privmsg { msg # Usage: !TS PrivMSG "[name]" [message] : Quote Required : Messages name only. }
elseif $2 == operators { msg # Usage: !TS Operators [list/add/del] [operator if add or del] : Requires operator permissions : Lists, Adds, Or Deletes (an) operator(s). }
elseif $2 == ban { msg # Usage: !TS Ban "[name]" [reason] : Quotes Required : Bans and Kicks name from the server. : Limited to TS Operators }
elseif $2 == banlist { msg # Usage: !TS BanList : Lists information about all the banned users on the server. : Limited to Voiced Users }
elseif $2 == unban { msg # Usage: !TS Unban [banid] : Unbans the user matching the ban ID. : "!TS Banlist" for ban IDs. }
elseif $2 == info { msg # Usage: !TS Info : Lists basic information about the TeamSpeak Server }
}
; commands
if $1-2 == !ts connect && $nick isop # && $istok(%ts.ops,$nick,32) { ts.connect }
elseif $1 == !ts && !$sock(ts2) { msg # Error: Not connected to the TeamSpeak server—have an operator type !TS Connect }
elseif $1-2 == !ts users { ts.pl public }
elseif $1-2 == !ts kick && $4 && $nick isop # {
var %user = $hfind(ts2,$+(*;,$ts.name($1-),;*;*),1,w).data
if !%user { msg # User not found..."!ts users" for a list of online users. }
else {
ts2.d kick $gettok($hget(ts2,%user),1,59) (IRC Kick By $nick $+ ) $ts.rest($1-)
msg # User $ts.name($1-) kicked, reason: $ts.rest($1-)
}
}
elseif $1-2 == !ts info { ts.si public }
elseif $1-2 == !ts unban && $istok(%ts.ops,$nick,32) && $3 isnum {
var %user = $hfind(ts2,$+($3,;*),1,w).data
if !%user { msg # Ban ID not found..."!ts banlist" for a list of bans. }
else { ts2.d bandel $gettok($hget(ts2,%user),1,59) | msg # Ban removed on ip $gettok($gettok($hget(ts2,%user),2,59),1-2,46) $+ .x.x | ts.bl }
}
elseif $1-2 == !ts ban && $istok(%ts.ops,$nick,32) && $4 {
var %user = $hfind(ts2,$+(*;,$ts.name($1-),;*;*),1,w).data
if !%user { msg # User not found..."!ts users" for a list of online users. }
else {
ts2.d banplayer $gettok($hget(ts2,%user),1,59)
ts2.d kick $gettok($hget(ts2,%user),1,59) (IRC banned By $nick $+ ) $ts.rest($1-)
msg # User $ts.name($1-) banned, reason: $ts.rest($1-)
}
}
elseif $1-2 == !ts banlist && $nick !isreg # { ts.bl public }
elseif $1-2 == !ts operators && !$3 { msg # Sub Commands (!TS operators [sub]): list add del }
elseif $1-3 == !ts operators list { msg # TS Operators: %ts.ops }
elseif $1-3 == !ts operators add && $istok(%ts.ops,$nick,32) && $nick isop # && $4 && !$istok(%ts.ops,$4,32) {
msg # Operator " $+ $4 $+ " added.
set %ts.ops $addtok(%ts.ops,$4,32)
}
elseif $1-3 == !ts operators del && $istok(%ts.ops,$nick,32) && $nick isop # && $4 && $istok(%ts.ops,$4,32) {
msg # Operator " $+ $4 $+ " deleted.
set %ts.ops $remtok(%ts.ops,$4,1,32)
}
elseif $1-2 == !ts msg && $3- && $nick !isreg # && $nick !isvoice # {
ts2.d msg [IRC MSG from $nick $+ ] $3-
msg # TS Message sent to all connected users.
}
elseif $1-2 == !ts privmsg && $3 && $4 {
var %user = $hfind(ts2,$+(*;,$ts.name($1-),;*;*),1,w).data
if !%user { msg # User not found..."!ts users" for a list of online users. }
else {
ts2.d msgu $gettok($hget(ts2,%user),1,59) [IRC PRIVMSG from $nick $+ ] $ts.rest($1-)
msg # TS PRIVMessage sent to $ts.name($1-) $+ .
}
}
}
on *:sockread:ts2: {
; puts the information recieved from the ts sever into %tsl, and then throws it into $*
var %tsl | sockread -n %tsl | tokenize 32 %tsl
if %tsl == [TS] {
msg $ts.chan Connection Establised...Selecting server on port $ts.sport $+ .
set %ts.act select
ts2.d sel $ts.sport
}
; Stores user info in the hash table, and if it was called to by !ts users, displays it in $ts.chan
elseif $gettok($1,1,9) isnum && $numtok($1-,9) == 16 {
if (%ts.r == first) { set %ts.s 1 | hdel -w ts2 user* | unset %ts.r }
; 1 = pid, 14 = ip, 15 = nick, 16 = login
; Format: pid;nick;login;ip
var %login = $iif($remove($gettok(%tsl,16,9),",$ifmatch,Guest)
hadd ts2 $+(user,%ts.s) $gettok(%tsl,1,9) $+ ; $+ $remove($gettok(%tsl,15,9)," $+ ; $+ %login $+ ; $+ $remove($gettok(%tsl,14,9),"
if $gettok(%ts.act,2,32) == public { msg $ts.chan TS User %ts.s $+ : ID[07 $+ $gettok(%tsl,1,9) $+ ] Nick[10 $+ $remove($gettok(%tsl,15,9)," $+ ] Login[ $+ $iif(%login == Guest,4,03) $+ %login $+ ] }
inc %ts.s
}
; stores server info in the hash, and if it was called to by !ts info, displays it in $ts.chan
elseif server_*=* iswm $1 {
tokenize 61 $1-
if $1 == server_name { hadd ts2 servername $2 | if %ts.act == si public { msg $ts.chan TS Server Name: $2 | msg $ts.chan TS Address: $ts.ip.public } }
elseif $1 == server_platorm { hadd ts2 serverplatform $2 | if %ts.act == si public { msg $ts.chan TS Server Platform: $2 } }
elseif $1 == server_udpport { hadd ts2 serverudpport $2 | if %ts.act == si public { msg $ts.chan TS Server Port: $2 } }
elseif $1 == server_currentusers && %ts.act == si public { msg $ts.chan TS User Count: $2 }
elseif $1 == server_bwoutlastmin { unset %ts.act }
}
; Get's the server ID and stores it in a hash (for reference with the logs)
elseif $numtok($1-,9) == 4 && $gettok($1,2,9) == $ts.sport {
hadd -m ts2 sid $gettok($1,1,9)
unset %ts.act
}
; stores the ban list in the hash, and displays it in $ts.chan if it was called to by !ts banlist
elseif $gettok($1,1,9) isnum && $numtok($1-,9) == 5 && $gettok(%ts.act,1,32) == bl {
if (%ts.r == first) { set %ts.s 1 | hdel -w ts2 banlist* | unset %ts.r }
; 1 = bid, 2 = ip, 5 = adder
; Format: bpid;ip;adder
var %bid = $gettok($1-,1,9), %ip = $gettok($1-,2,9), %adder = $right($gettok($gettok($gettok($1-,5,9),2,91),1,93),-11), %adder = $iif(%adder,$ifmatch,$me)
hadd ts2 $+(banlist,%ts.s) $+(%bid,;,%ip,;,%adder)
if $gettok(%ts.act,2,32) == public { msg $ts.chan TS Ban %ts.s $+ : ID[07 $+ %bid $+ ] Added By[10 $+ %adder $+ ] On[03 $+ $gettok($1-,3,9) $+ ] IP[04 $+ $gettok(%ip,1-2,46) $+ .x.x] }
inc %ts.s
}
; Stores the last 5 logs in the hash, then activates "ts.checklogs"
elseif *-*-* iswm $1 && *:*:* iswm $2 && %ts.getlogs == getlogs {
if %ts.x == first { set %ts.s 5 | unset %ts.x }
hadd ts2 $+(logs,%ts.s) $1-
if %ts.s == 1 { unset %ts.getlogs | unset %ts.s | ts.checklogs }
dec %ts.s
}
; The following is triggered when "OK" is sent to the server, based on %ts.act, it reacts accordingly
elseif %tsl == OK {
if %ts.act == login {
msg $ts.chan Logged in as a Super Admin.
.timertscheckok 0 5 ts.checkok
.timergettslogs 0 3 ts.getlogs
.timertspingout 1 $ts.timeout ts.sockclose
set %ts.act getsid
ts2.d dbserverlist
}
elseif %ts.act == select {
msg $ts.chan Selected server on port $ts.sport $+ ...logging in
set %ts.act login
ts2.d slogin $ts.slogin $ts.spass
}
elseif $gettok(%ts.act,1,32) == pl {
unset %ts.act
}
elseif $gettok(%ts.act,1,32) == bl {
unset %ts.act
}
elseif %ts.checkok == check { .timertspingout 1 $ts.timeout ts.sockclose | unset %ts.checkok }
}
elseif $1 == ERROR, && $2- == invalid login { msg $ts.chan Failed to login... | ts.sockclose silent }
elseif $gettok(%tsl,1,32) === ERROR, { msg $ts.chan $iif($2- == no data available,No data is available for this request.,Error: $gettok(%tsl,2-,32)) }
elseif $1-5 == Your password failed 3 consecutive { msg $ts.chan Error: Authentication failure three times in a row, TeamSpeak will block this account for ten minutes! }
; else { msg #dev DEBUG: $1- }
}
; Checks if the server is still responding within 10 seconds
alias ts.checkok {
ts2.d checkserverok
set %ts.checkok check
}
; checks to see which of the last 5 logs are new, and sends the new ones to ts.logprocess
alias ts.checklogs {
if !$hfind(ts2,lastlog*,1,w) {
var %a = 5
while %a { hadd ts2 $+(lastlog,%a) $hget(ts2,$+(logs,%a)) | dec %a }
}
var %say = 1
if $hget(ts2,logs1) == $hget(ts2,lastlog1) { halt }
elseif $hget(ts2,logs1) != $hget(ts2,lastlog1) && $hget(ts2,logs2) == $hget(ts2,lastlog1) { var %say = 1 }
elseif $hget(ts2,logs3) == $hget(ts2,lastlog1) { var %say = 2 }
elseif $hget(ts2,logs4) == $hget(ts2,lastlog1) { var %say = 3 }
elseif $hget(ts2,logs5) == $hget(ts2,lastlog1) { var %say = 4 }
else { var %say = 5 }
if !%say { halt }
var %a = 5
while %a { hadd ts2 $+(lastlog,%a) $hget(ts2,$+(logs,%a)) | dec %a }
while %say { ts.logprocess $hget(ts2,$+(logs,%say)) | dec %say }
}
; Gets the last 5 logs
alias ts.getlogs {
set %ts.getlogs getlogs
set %ts.x first
if !$hget(ts2) { hmake ts2 100 }
ts2.d log 5
}
; Lists the players
alias ts.pl {
if !$hget(ts2) { hmake ts2 100 }
set %ts.act pl $iif($1 == public,public)
set %ts.r First
ts2.d pl
}
; Lists the bans
alias ts.bl {
if !$hget(ts2) { hmake ts2 100 }
set %ts.act bl $iif($1 == public,public)
set %ts.r First
ts2.d banlist
}
; Shows the server information
alias ts.si {
if !$hget(ts2) { hmake ts2 100 }
set %ts.act si $iif($1 == public,public)
ts2.d si
}
; Processes the logs, displaying them to $ts.chan in a prettier way.
alias ts.logprocess {
if $right($gettok($gettok($1-,5,44),1,58),-1) == SID && $gettok($gettok($1-,5,44),2,32) != $hget(ts2,sid) { halt }
elseif $gettok($gettok($1-,5,44),4,32) == connected {
var %login = $gettok($1-,7,44)
if *.*.*.*] iswm %login { var %login = Guest }
else { var %login = $right(%login,-12) }
var %nick = $right($gettok($1-,6,44),-6)
if $gettok($gettok($1-,5,44),3,32) == Client { msg $ts.chan [3TS Connect]: User $+(10,%nick,) $chr(91) $+ $iif(%login == Guest,04,03) $+ %login $+ ] connected to TeamSpeak. | ts.pl }
else { msg $ts.chan [3TS Connect]: User is a Server Administrator. ( $+ $right($gettok($1-,6,44),-7) $+ ) }
}
elseif $gettok($gettok($1-,5,44),4,32) == disconnected. {
if $gettok($gettok($1-,5,44),3,32) == client {
var %nick = $right($gettok($gettok($1-,5,44),2,91),-6)
var %user = $right($gettok($1-,6,44),-12)
if !%user { var %nick = $left(%nick,-1), %user = Guest }
msg $ts.chan [4TS Disconnect] User $+(10,%nick,) $chr(91) $+ $iif(%user == guest,04,03) $+ %user $+ ] disconnected from TeamSpeak.
}
}
elseif $gettok($1-,4,44) == ServerKickLog { msg $ts.chan [4TS Kick]: $right($gettok($gettok($1-,7,44),3,58),-1) kicked $right($gettok($gettok($1-,5,44),3,58),-1) from the server. }
elseif $gettok($1-,4,44) == ChatLog && *[to channel:* iswm $gettok($1-,5,44) { msg $ts.chan [7TS Chat]: $right($gettok($gettok($1-,6,44),1,93),-6) messaged $gettok($gettok($1-,5,44),3,58) with: $gettok($gettok($1-,6,44),2-,93) }
elseif $gettok($1-,4,44) == ChatLog && *[to all,* iswm $gettok($1-,5,44) { msg $ts.chan [7TS Chat]: $right($gettok($gettok($1-,6,44),1,93),-6) sent the following in a global message: $gettok($gettok($1-,6,44),2-,93) }
elseif $gettok($1-,4,44) == ChannelLog && *regist*channel created* iswm $1- { msg $ts.chan TS Channel " $+ $right($gettok($gettok($1-,5,44),3,58),-1) $+ " Created. }
elseif $gettok($gettok($1-,5,44),4,32) == disconnected && $gettok($gettok($1-,5,44),3,32) == serveradmin { return }
elseif $gettok($1-,4,44) == ChannelKickLog {
var %kicked = $right($gettok($gettok($1-,5,44),2,91),-12)
var %kicker = $right($gettok($gettok($1-,7,44),2,91),-12)
var %channel = $left($gettok($gettok($gettok($1-,7,44),7-,32),1,91),-3)
var %reason = $right($gettok($1-,10,44),-Cool
msg $ts.chan [10TS Kick]: %kicker kicked %kicked from %channel $+ , reason: $iif(%reason,$ifmatch,None Provided)
}
; else { msg $ts.chan 4DEBUG: $1- }
}
; activates if the connection is lost
on *:sockclose:ts2:msg $ts.chan Connection closed to the TeamSpeak server. | ts.sockclose
; activates when a socket times out, kills the timers
alias ts.sockclose {
if !$1 {
sockclose ts2
msg $ts.chan TS Error: Socket timed out.
.timergettslogs off
.timertscheckok off
}
elseif $1 == cc {
msg $ts.chan TeamSpeak failed to connect!
.timergettslogs off
.timertscheckok off
sockclose ts2
.timertspingout off
}
elseif $1 == silent {
.timergettslogs off
.timertscheckok off
.timertspingout off
sockclose ts2
}
}

-------------------------------------------------------
TeamSpeak Config for Server----------------------------
-------------------------------------------------------
[General]
; Your channel name.
; IE: Channel=#LG-Admin
Channel=#LG-Admin

; A valid "Super Admin" account on your TeamSpeak Server
; IE: Super_Admin_Login=TSBot
Super_Admin_Login=superadmin

; The "Super Admin" password for your Super_Admin_Login account
; IE: Super_Admin_Pass=botpass
Super_Admin_Pass=****

; The TCP Query Port for your server, if you don't know it, it's likely as provided.
; Note: This is NOT the port your connect to when connecting to TS
TCPQuery_Port=51234

; The TeamSpeak IP, if it's local, use 127.0.0.1
TS_IP=127.0.0.1

; The TeamSpeak Public Address...if you provided 127.0.0.1, as the IP, be sure to
; make this the one you want people to connect to.
TS_Public_IP=lg-gaming.homeip.net

; This is the port you connect to your TeamSpeak server on with your client
TS_Server_Port=8585

; This is the number of seconds before the server is assumed to have timed out if it
; has not responded...note the script will assume a ts server is still up, even when
; it has been shutdown, for at least this ammount of time.
Timeout_Seconds=15
------------------------------------------------------
END of Script-----------------------------------------
------------------------------------------------------
Back to top Go down
 
TeamSpeak Server Script
Back to top 
Page 1 of 1
 Similar topics
-
» LG-Gaming IRC and Teamspeak

Permissions in this forum:You cannot reply to topics in this forum
LG-Gaming Marathon :: Server :: Scripts-
Jump to: