Currently it only has a color for each team, i've tried multiple ways to make it do TEAM1:colorcode players and Team2:colorcode players but nothing i try works :/
As well i would love for when it messages the players it actually tells them what team they are on.
Code: Select all
# pickup.tcl v0.5
#
# Pickup script for gathering players for a game.
#
# .join : Adds you to the playerlist
# .leavee : Removes you from the playerlist
# quit/part/rename/kick : Removes you from the playerlist
# .list : Shows current playerlist (not working yet)
# .last : Shows details about last pickup (time ago, players)
# .top10 : Shows the top 10 players
# -- Op Only: --
# .remove all : Removes everybody (op only)
# .remove <player> : Removes player (op only)
# .start : Starts pickup
# !stop : Stops pickup
#
# At the moment, only topic is used to display players.
#
# When 10th (or whatever's configured) player adds up, teams are randomly
# generated and information is displayed. The IP address and password are
# sent via PM to the signuppers.
#
# Todo :
# Variable number of servers, to set through PM
# Integrate a !ban script
#
#
# -o- !ts and !patch support added
# -o- Added PHP scripts to display statistics (in graphs ;))
# -o- Added !need that will amsg in all channels with !need info (op only)
# -o- Added !ban, at the moment with hardcoded options (sorry!)
# -o- Added !unban, uses the nickname used for banning as argument
# -o- Improved PMing after pickupgame starts, all at once now instead of 1 at a time
#
# Version 0.4: Cruz @ 26-03-2007
# -o- Fixed bug with \ in nicknames
# -o- Added extra logfile that can be used to generate graphs etc
#
# Version 0.3: Cruz @ 27-12-2005
# -o- !top10 support
# -o- !lastgame changed to notices so no highlight spams
#
# Version 0.2: Cruz @ 25-08-2005
# -o- Shows players in topic, preventing constant highlights
# -o- More settings, all colors are changable through PM's
# -o- Shows more info in !lastgame
# -o- Support for 4 different servers maximum
#
# Version 0.1: Cruz @ 11-06-2004
# -o- Original version
# Website:
set pickuphelpsite "http://www.comingsoon.com/pickuphelp.php"
# File containing settings
set settingsfile "./scripts/.pickupsettings"
set topplayersfile "./scripts/.pickuptopplayers"
set pickuplogfile "./scripts/.pickuplogfile"
## Default values (after changing these ingame, they're stored in the settingsfile)
# Channel:
set defpickupchan "#test
# Colors:
set defpickupcolor1 "\017\00307"
set defpickupcolor2 "\017\002\00304"
# Team colors:
set defpickupcolorteam1 "\017\002\00310"
set defpickupcolorteam2 "\017\002\00304"
# Color of promote message
set defpickupproco ""
# Playerlimit:
set defpickuplimit 2
# IP & Pass:
set defpickupmessage "\00309Join the server!"
# Game:
set defpickupgame "Vs Mode"
# Default status:
set defpickupenabled 0
# Default servers:
set defpickupserver(1) "css Pug Room #1"
set defpickupserver(2) "css Pug Room #2"
set defpickupserver(3) "css Pug Room #3"
set defpickupserver(4) "css Pug Room #4"
# MotD (topic):
set defpickuppremotd "Pickup:"
set defpickupmotd "Add up!"
# Data about last game played:
set defpickuplastdata "No Info"
# Random info:
set defpickupts ""
set defpickuppatch ""
#######################################
# Read settings:
# Making sure all files exists:
set fid [open $settingsfile a+]
close $fid
set fid [open $topplayersfile a+]
close $fid
set fid [open $pickuplogfile a+]
close $fid
# Read:
set fid [open $settingsfile r]
while {![eof $fid]} {
set line [gets $fid]
if {[regexp -nocase {^(.*?) (.*)$} $line match_var option newvalue]} {
if {[string compare $option "enabled"]==0} {
set pickupenabled $newvalue
}
if {[string compare $option "playmessage"]==0} {
set pickupmessage $newvalue
}
if {[string compare $option "gametype"]==0} {
set pickupgame $newvalue
}
if {[string compare $option "playerlimit"]==0} {
set pickuplimit $newvalue
}
if {[string compare $option "channel"]==0} {
set pickupchan $newvalue
}
if {[string compare $option "color1"]==0} {
set pickupcolor1 $newvalue
}
if {[string compare $option "color2"]==0} {
set pickupcolor2 $newvalue
}
if {[string compare $option "teamcolor1"]==0} {
set pickupcolorteam1 $newvalue
}
if {[string compare $option "teamcolor2"]==0} {
set pickupcolorteam2 $newvalue
}
if {[string compare $option "server1"]==0} {
set pickupserver(1) $newvalue
}
if {[string compare $option "server2"]==0} {
set pickupserver(2) $newvalue
}
if {[string compare $option "server3"]==0} {
set pickupserver(3) $newvalue
}
if {[string compare $option "server4"]==0} {
set pickupserver(4) $newvalue
}
if {[string compare $option "motd"]==0} {
set pickupmotd $newvalue
}
if {[string compare $option "premotd"]==0} {
set pickuppremotd $newvalue
}
if {[string compare $option "proco"]==0} {
set pickupproco $newvalue
}
if {[string compare $option "ts"]==0} {
set pickuppts $newvalue
}
if {[string compare $option "patch"]==0} {
set pickuppatch $newvalue
}
}
}
# If no settings were found, revert to default settings
if {![info exist pickupmessage]} {
set pickupmessage $defpickupmessage
}
if {![info exist pickupgame]} {
set pickupgame $defpickupgame
}
if {![info exist pickuplimit]} {
set pickuplimit $defpickuplimit
}
if {![info exist pickupenabled]} {
set pickupenabled $defpickupenabled
}
if {![info exist pickupchan]} {
set pickupchan $defpickupchan
}
if {![info exist pickupcolor1]} {
set pickupcolor1 $defpickupcolor1
}
if {![info exist pickupcolor2]} {
set pickupcolor2 $defpickupcolor2
}
if {![info exist pickupcolorteam1]} {
set pickupcolorteam1 $defpickupcolorteam1
}
if {![info exist pickupcolorteam2]} {
set pickupcolorteam2 $defpickupcolorteam2
}
if {![info exist pickupserver(1)]} {
set pickupserver(1) $defpickupserver(1)
}
if {![info exist pickupserver(2)]} {
set pickupserver(2) $defpickupserver(2)
}
if {![info exist pickupserver(3)]} {
set pickupserver(3) $defpickupserver(3)
}
if {![info exist pickupserver(4)]} {
set pickupserver(4) $defpickupserver(4)
}
if {![info exist pickupservercounter]} {
set pickupservercounter 1
}
if {![info exist pickupmotd]} {
set pickupmotd $defpickupmotd
}
if {![info exist pickuppremotd]} {
set pickuppremotd $defpickuppremotd
}
if {![info exist pickuplastdata]} {
set pickuplastdata $defpickuplastdata
}
if {![info exist pickupproco]} {
set pickupproco $defpickupproco
}
if {![info exist pickupts]} {
set pickupts $defpickupts
}
if {![info exist pickuppatch]} {
set pickuppatch $defpickuppatch
}
close $fid
## Starting Code ##
bind pub - .help pickup_help
bind pub - .join pickup_add
bind pub - .leave pickup_remove
bind pub - .remove pickup_remove
bind pub - .list pickup_display
bind pub - .top10 pickup_parsetpf
bind pub o .resettop10 pickup_resettpf
bind pub - .cyclepickup pickup_cycle
bind pub - .last pickup_lastgame
bind pub - .promote pickup_promote
bind pub - .ts pickup_ts
bind pub - .patch pickup_patch
bind part - * pickup_part
bind kick - * pickup_kick
bind sign - * pickup_signoff
bind nick - * pickup_nick
bind pub - .need pickup_need
bind pub - .start pickup_start
bind pub - .stop pickup_stop
bind msgm - "set*" pickup_setoptions
bind pub - .ban pickup_ban
bind pub - .unban pickup_unban
proc pickup_ban { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupbantypes pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# Check if it's an Op or owner:
if {[matchattr $handle o]==1 || [isop $nick $pickupchan]} {
if {[llength $arg] < 1} {
putserv "NOTICE $nick :\2Syntax\2: !ban <nick> <reason>, where reason can be : noshow/leaving/nicklame/spotsteal"
return
}
# Split arg into nick / reason
if {![regexp -nocase {^(.*?) (.*)$} $arg match_var vnick reason]} {
puthelp "PRIVMSG $channel :${pickupcolor1}Invalid syntax. It's: !ban <nick> <reason>."
return
}
# Syntax : !ban <nick> <reason>
# Check if <nick> exists:
if {![onchan $vnick $channel]} {
puthelp "PRIVMSG $channel :${pickupcolor1}$vnick not found in this channel."
return
}
# Check for the bantime:
if {[string match -nocase "$reason" "leaving"]} {
set bantime 60
set message "Banned for ${bantime}m for leaving the server"
}
if {[string match -nocase "$reason" "noshow"]} {
set bantime 360
set message "Banned for ${bantime}m for not showing up on the server"
}
if {[string match -nocase "$reason" "spotsteal"]} {
set bantime 360
set message "Banned for ${bantime}m for stealing a spot on the server"
}
if {[string match -nocase "$reason" "nicklame"]} {
set bantime 20
set message "Banned for ${bantime}m for not having the proper nickname on the server"
}
if {[info exists bantime]} {
set uhost [getchanhost $vnick $channel]
# We add the nickname to the ban message so we can later unban on the nickname!
newchanban $channel [maskhost $uhost] $nick "$vnick = $message" $bantime
} else {
puthelp "PRIVMSG $channel :${pickupcolor1}Invalid ban reason. (leaving/noshow)"
}
}
}
proc pickup_unban { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupbantypes pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# Check if it's an Op or owner:
if {[matchattr $handle o]==1 || [isop $nick $pickupchan]} {
if {[llength $arg] < 1} {
putserv "NOTICE $nick :\2Syntax\2: !unban <nick>, where nick was used for banning (ban message is 'nick = ....')"
return
}
# {*!*Heretic@*.nb.home.nl {Die spambot scum!} 1134839717 1134839417 1134839417 {[FtUC]Bob}}
# Check all bans:
foreach ban [banlist $channel] {
set banmsg [lindex $ban 1]
set banhost [lindex $ban 0]
if {[regexp -nocase {^(.*?) = (.*)$} $banmsg match_var vnick reason]} {
if {[string match -nocase "$arg" $vnick]} {
killchanban $channel $banhost
puthelp "PRIVMSG $channel :${pickupcolor1}$vnick is unbanned."
return
}
}
}
puthelp "PRIVMSG $channel :${pickupcolor1}Can't find $arg in the active ban list."
}
}
proc pickup_need { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupchan pickuplasttime pickuplastdata pickupenabled pickuplastneed pickupoldserver
if {$pickupenabled == 0} { return }
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# Only do this once every 5 minutes
if {[info exists pickuplastneed]} {
set newtime [clock seconds]
set timediff [expr $newtime - $pickuplastneed]
if {$timediff < 300} {
putserv "NOTICE $nick :${pickupcolor1}Sorry, there is a limit of 1 need message every 5 minutes."
return
}
}
# Check if this player was in the last pickup
set allowed 0
if {[matchattr $handle o]==1 || [isop $nick $pickupchan]} {
set allowed 1
}
if {[string match $pickuplastdata "*${nick}*"]} {
set allowed 1
}
if {$allowed == 0} {
putserv "NOTICE $nick :${pickupcolor1}Sorry, only Ops or people in the pickup can use !need."
return
}
# If no game has been played yet, ignore:
if {![info exists pickupoldserver]} {
putserv "NOTICE $nick :${pickupcolor1}Can't remember any pickup's being played recently."
return
}
# Check if number of needed players is given:
set number 1
regexp -nocase {^([0-9]+)$} $arg match_var number
# Send a message
set allchans ""
foreach onechannel [channels] {
set allchans "$allchans,$onechannel"
}
putserv "PRIVMSG $allchans :${pickupcolor1}:: $number player(s) needed for $channel pickup : $pickupoldserver ${pickupcolor1}::"
set pickuplastneed [clock seconds]
}
proc pickup_cycle { nick uhost handle channel arg } {
global pickupchan
if {[matchattr $handle o]==1 || [isop $nick $pickupchan]} {
pickup_nextserver
pickup_display $nick $uhost $handle $channel $arg
}
}
proc pickup_setoptions { nick uhost handle arg } {
global pickupchan pickupcolor1 pickupcolor2 pickupenabled
global pickuplimit pickupmessage pickupgame settingsfile pickupcolorteam1 pickupcolorteam2
global pickupserver pickuppremotd pickupmotd pickupproco pickupts pickuppatch
if {[matchattr $handle o]==1 || [isop $nick $pickupchan]} {
if {[regexp -nocase {^.*? (.*?) (.*)$} $arg match_var option newvalue]} {
if {[string compare $option "enabled"]==0} {
set pickupenabled $newvalue
}
if {[string compare $option "playmessage"]==0} {
set pickupmessage $newvalue
}
if {[string compare $option "gametype"]==0} {
set pickupgame $newvalue
}
if {[string compare $option "playerlimit"]==0} {
set pickuplimit $newvalue
}
if {[string compare $option "color1"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupcolor1 $newvalue
}
if {[string compare $option "color2"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupcolor2 $newvalue
}
if {[string compare $option "promotecolor"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupproco $newvalue
}
if {[string compare $option "teamcolor1"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupcolorteam1 $newvalue
}
if {[string compare $option "teamcolor2"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupcolorteam2 $newvalue
}
if {[string compare $option "channel"]==0} {
set pickupchan [string tolower $newvalue]
}
if {[string compare $option "server1"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupserver(1) $newvalue
}
if {[string compare $option "server2"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupserver(2) $newvalue
}
if {[string compare $option "server3"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupserver(3) $newvalue
}
if {[string compare $option "server4"]==0} {
if {$newvalue == 0} { set newvalue ""}
set pickupserver(4) $newvalue
}
if {[string compare $option "motd"]==0} {
set pickupmotd $newvalue
}
if {[string compare $option "premotd"]==0} {
set pickuppremotd $newvalue
}
if {[string compare $option "ts"]==0} {
set pickupts $newvalue
}
if {[string compare $option "patch"]==0} {
set pickuppatch $newvalue
}
putserv "PRIVMSG $nick :${pickupcolor1}:::: Settings Changed ::::"
# Save the new settings:
set fid [open $settingsfile w]
puts $fid "enabled $pickupenabled"
puts $fid "playmessage $pickupmessage"
puts $fid "gametype $pickupgame"
puts $fid "playerlimit $pickuplimit"
puts $fid "channel $pickupchan"
puts $fid "color1 $pickupcolor1"
puts $fid "color2 $pickupcolor2"
puts $fid "teamcolor1 $pickupcolorteam1"
puts $fid "teamcolor2 $pickupcolorteam2"
puts $fid "server1 $pickupserver(1)"
puts $fid "server2 $pickupserver(2)"
puts $fid "server3 $pickupserver(3)"
puts $fid "server4 $pickupserver(4)"
puts $fid "premotd $pickuppremotd"
puts $fid "motd $pickupmotd"
puts $fid "proco $pickupproco"
puts $fid "ts $pickupts"
puts $fid "patch $pickuppatch"
flush $fid
close $fid
} else {
# No arguments, show settings
putserv "PRIVMSG $nick :${pickupcolor1}:::: Settings ::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: channel : ${pickupcolor1}$pickupchan ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: gametype : ${pickupcolor1}$pickupgame ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: playerlimit : ${pickupcolor1}$pickuplimit ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: playmessage :\017 $pickupmessage ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: color1 :\017 $pickupcolor1 This Color ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: color2 :\017 $pickupcolor2 This Color ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: teamcolor1 :\017 $pickupcolorteam1 This Color ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: teamcolor2 :\017 $pickupcolorteam2 This Color ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: promotecolor :\017 $pickupproco This Color ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: server1 : ${pickupcolor1}$pickupserver(1) ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: server2 : ${pickupcolor1}$pickupserver(2) ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: server3 : ${pickupcolor1}$pickupserver(3) ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: server4 : ${pickupcolor1}$pickupserver(4) ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: premotd : ${pickupcolor1}$pickuppremotd ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: motd : ${pickupcolor1}$pickupmotd ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: ts : ${pickupcolor1}$pickupts ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor2}:::: patch : ${pickupcolor1}$pickuppatch ${pickupcolor2}::::"
putserv "PRIVMSG $nick :${pickupcolor1}:::: /Settings ::::"
}
}
}
proc pickup_ts { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupchan pickuphelpsite pickupts
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
putserv "PRIVMSG $pickupchan :${pickupcolor1}TeamSpeak :: ${pickupcolor2}${pickupts}${pickupcolor1}"
}
proc pickup_patch { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupchan pickuphelpsite pickuppatch
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
putserv "PRIVMSG $pickupchan :${pickupcolor1}Patches :: ${pickupcolor2}${pickuppatch}${pickupcolor1}"
}
proc pickup_help { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupchan pickuphelpsite
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
putserv "NOTICE $nick :${pickupcolor1}::Help for Pickup:"
putserv "NOTICE $nick :${pickupcolor1}::Sign up for a game with ${pickupcolor2}.join${pickupcolor1}, remove with \
${pickupcolor2}.leave${pickupcolor1}. The time since the last pickup \
is shown with ${pickupcolor2}.last${pickupcolor1}, View the top 10 players with ${pickupcolor2}.top10${pickupcolor1}"
if {[isop $nick $channel]} {
putserv "NOTICE $nick :${pickupcolor1}::Extra commands for Ops: ${pickupcolor2}.start + .stop${pickupcolor1}, and \
${pickupcolor2}.remove <name>${pickupcolor1}. You can also set options, for an overview PM me ${pickupcolor2}set${pickupcolor2}, \
${pickupcolor2}.need <amount of subs you need> to amsg the channels for a sub"
} else {
putserv "NOTICE $nick :${pickupcolor1}::See ${pickuphelpsite} for more info!"
}
}
proc pickup_lastgame { nick uhost handle channel arg } {
global pickupcolor1 pickupcolor2 pickupchan pickuplasttime pickuplastdata pickupenabled
if {$pickupenabled == 0} { return }
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if {[info exists pickuplasttime]} {
set hours 0
set minutes 0
set seconds 0
set newtime [clock seconds]
set timediff [expr $newtime - $pickuplasttime]
set hours [expr $timediff / 3600]
set timediff [expr $timediff - $hours * 3600]
set minutes [expr $timediff / 60]
set timediff [expr $timediff - $minutes * 60]
set seconds $timediff
putserv "NOTICE $nick :${pickupcolor1}:: Last pickup was: $hours hours, $minutes minutes and $seconds seconds ago : $pickuplastdata "
} else {
putserv "NOTICE $nick :${pickupcolor1}:: Last pickup was when baby Jesus was born, around that time ::"
}
}
proc pickup_start { nick uhost handle channel arg } {
global pickupenabled pickupcolor1 pickupcolor2 pickupchan pickuplimit pickupgame
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if {![isop $nick $channel]} {
return 0
}
set pickupenabled 1
putserv "PRIVMSG $channel :${pickupcolor2}Pickup Started :: ${pickupcolor1}${pickupgame} with ${pickuplimit} players"
# Call setoptions to store status:
pickup_setoptions $nick $uhost $handle "!pickupset bla bla"
}
proc pickup_stop { nick uhost handle channel arg } {
global pickupenabled pickupcolor1 pickupcolor2 pickupchan pickupplayerlist
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if {![isop $nick $channel]} {
return 0
}
set pickupenabled 0
if {[info exists pickupplayerlist]} {
unset pickupplayerlist
}
putserv "PRIVMSG $channel :${pickupcolor2}Pickup Stopped!!"
# Call setoptions to store status:
pickup_setoptions $nick $uhost $handle "!pickupset bla bla"
}
proc pickup_promote { nick uhost handle channel arg } {
global pickupchan pickupcolor1 pickupcolor2 pickuplimit pickupplayerlist pickupproco
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
set nrofplayers 0
if {[info exist pickupplayerlist]} {
set nrofplayers [llength $pickupplayerlist]
}
set missing [expr $pickuplimit - $nrofplayers]
set legal 0
if {[info exists pickupplayerlist]} {
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
if {[string compare $nick $player] == 0} {
set legal 1
}
}
}
if {[isop $nick $channel]} { set legal 1 }
if { $legal == 1 } {
puthelp "NOTICE $channel :$pickupproco $missing needed for pickup, !add up in $pickupchan"
}
}
proc pickup_add { nick uhost handle channel arg } {
global pickupplayerlist pickuplimit pickupcolor1 pickupcolor2 pickupenabled pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if { $pickupenabled == 0 } {
# putserv "NOTICE $nick :${pickupcolor1}Pickup currently not running."
return
}
#make sure it's not a double signup
if {[info exists pickupplayerlist]} {
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
if {[string compare $nick $player] == 0} {
puthelp "NOTICE $nick :${pickupcolor1}You're already signed up!"
return
}
}
}
lappend pickupplayerlist [pickup_encode $nick]
if {[llength $pickupplayerlist] >= $pickuplimit} {
pickup_finish $nick $uhost $handle $channel $arg
pickup_clear $nick $uhost $handle $channel $arg
return
}
pickup_display $nick $uhost $handle $channel $arg
}
proc pickup_remove { nick uhost handle channel arg } {
global pickupplayerlist pickupcolor1 pickupcolor2 pickupenabled pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if { $pickupenabled == 0 } {
# putserv "NOTICE $nick :${pickupcolor1}Pickup currently not running."
return
}
# Check if anybody at all signed up:
if {![info exists pickupplayerlist]} {
# putserv "NOTICE $nick :${pickupcolor2}Nobody signed up, that includes you!"
return
}
# Ops can remove players:
set removenick $nick
if {$arg != "" && [isop $nick $channel]} {
set removenick $arg
}
set isremoved 0
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
if {[string compare $removenick $player] == 0} {
# Matches with "removenick", not copying into new list
set isremoved 1
} else {
# Other nick, copy to new list
if {![info exists newlist]} {
set newlist [pickup_encode $player]
} else {
lappend newlist [pickup_encode $player]
}
}
}
# Copy new list to the pickupplayerlist
if {[info exists newlist]} {
set pickupplayerlist $newlist
} else {
unset pickupplayerlist
}
# If Op said "!remove all", remove all.
if {[string compare $arg "all"]==0 && [isop $nick $channel]} {
unset pickupplayerlist
} else {
if {$isremoved == 0} {
# putserv "NOTICE $nick :${pickupcolor1}You weren't on the list, stupid!"
return
}
}
pickup_display $nick $uhost $handle $channel $arg
}
proc pickup_display { nick uhost handle channel arg } {
global pickupplayerlist pickupcolor1 pickupcolor2 pickupenabled pickupchan pickupgame pickuplimit pickupmotd
global pickuppremotd
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
if { $pickupenabled == 0 } {
putserv "NOTICE $nick :${pickupcolor1}Pickup currently not running."
return
}
set nrofplayers 0
if {[info exist pickupplayerlist]} {
set nrofplayers [llength $pickupplayerlist]
}
set pickup_topic 1
if {$pickup_topic == 1} {
# Show players in topic:
set playerlist ""
set count 0
if {[info exists pickupplayerlist]} {
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
set playerlist "$playerlist${pickupcolor2}$player${pickupcolor1}/"
incr count
}
}
for {} {$count < $pickuplimit} {incr count} {
set playerlist "$playerlist${pickupcolor2}?${pickupcolor1}/"
}
set playerlist [string trim $playerlist /]
set server [pickup_getserver]
putserv "TOPIC $channel :$pickuppremotd Players: $playerlist Server: $server $pickupmotd"
}
}
proc pickup_getserver { } {
global pickupserver pickupservercounter
if {[info exists pickupserver($pickupservercounter)]} {
return $pickupserver($pickupservercounter)
} else {
return "invalid server"
}
}
proc pickup_nextserver { } {
global pickupserver pickupservercounter
set next $pickupservercounter
incr next
if {[info exists pickupserver($next)]} {
set pickupservercounter $next
} else {
set pickupservercounter 1
}
# Continue until we find a valid server:
if {$pickupservercounter != 1 && $pickupserver($pickupservercounter) == ""} { pickup_nextserver }
return
}
proc pickup_finish { nick uhost handle channel arg } {
global pickupplayerlist pickupcolor1 pickupcolor2 pickupcolorteam1 pickupcolorteam2 pickupmessage pickupchan
global pickuplasttime pickuplastdata pickuplogfile pickupgame pickupoldserver
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
putserv "PRIVMSG $channel :${pickupcolor1}::Pug Now started!!::"
if {![info exists pickupplayerlist]} {
putserv "PRIVMSG $channel :${pickupcolor1}Playerlist is empty"
return
}
# Shuffle the teams randomly:
set team1 ""
set team2 ""
# Compose the channel message with the correct teams:
set teamlisting ""
set i 0
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
if { $i == 0 } {
set teamlisting "$teamlisting${pickupcolor1}:: ${pickupcolorteam1}$player"
set i 1
} else {
set teamlisting "$teamlisting${pickupcolor1}:: ${pickupcolorteam2}$player"
set i 0
}
}
set teamlisting "$teamlisting\017${pickupcolor1}:: "
putserv "PRIVMSG $channel :$teamlisting[pickup_getserver]"
set pickuplastdata $teamlisting[pickup_getserver]
set pickupoldserver [pickup_getserver]
# Send a PM to every player
set playerlist ""
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
# Add player to top10 as well:
pickup_addtotpf $player
set playerlist "${playerlist},${player}"
}
puthelp "PRIVMSG $playerlist :$pickupmessage $pickupoldserver"
pickup_increase_counter
set pickuplasttime [clock seconds]
# Also add entry to logfile:
# Format:
# date;gametype;name1,name2,etc
set fid [open $pickuplogfile a+]
set time [clock seconds]
set line "$time;${pickupgame};"
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
set line "${line}${player},"
}
puts $fid $line
close $fid
}
proc pickup_clear { nick uhost handle channel arg } {
global pickupplayerlist pickupcolor1 pickupcolor2 pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
unset pickupplayerlist
pickup_nextserver
pickup_display $nick $uhost $handle $channel $arg
}
proc pickup_part { nick host handle channel arg } {
global pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# When someone leaves the channel, remove him from list
pickup_remove $nick $host $handle $channel ""
}
proc pickup_kick { nick host handle channel kicked arg } {
global pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# When someone leaves the channel, remove him from list
pickup_remove $kicked $host $handle $channel ""
}
proc pickup_signoff { nick host handle channel arg } {
global pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
# When someone leaves the channel, remove him from list
pickup_remove $nick $host $handle $channel $arg
}
proc pickup_nick { nick host handle chan newnick } {
global pickupplayerlist pickupcolor1 pickupcolor2 pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $chan]] == "-1"} {return 0}
set newlist ""
#When someone changes his/her nick, adjust it in the playerlist
if {[info exists pickupplayerlist]} {
foreach player $pickupplayerlist {
# Decode special characters first before comparing:
set player [pickup_decode $player]
if {[string compare $nick $player] == 0} {
lappend newlist $newnick
} else {
lappend newlist $player
}
}
set pickupplayerlist $newlist
}
}
proc pickup_addtotpf { player } {
global topplayersfile
set fid [open $topplayersfile r]
# Store all lines in $data instead of looping through reading the file:
set data [read -nonewline $fid]
close $fid
# Now we split the data into lines.
set lines [split $data "\n"]
set found 0
# Rebuild the player file:
set fid [open $topplayersfile w]
# And check all lines to see if they match the nickname:
for { set index 0 } { $index<[llength $lines] } { incr index } {
# Only check player info:
if {[regexp {^P (.*?) ([0-9]+)$} [lindex $lines $index] match_var nick count]} {
if {[string equal $nick $player]} {
incr count
puts $fid "P $nick $count"
set found 1
} else {
puts $fid "P $nick $count"
}
} else {
# No match, just copy/paste the non-player info
puts $fid [lindex $lines $index]
}
}
# If not in the file yet, add it:
if {$found == 0} {
puts $fid "P $player 1"
}
close $fid
}
proc pickup_increase_counter {} {
global topplayersfile
set fid [open $topplayersfile r]
# Store all lines in $data instead of looping through reading the file:
set data [read -nonewline $fid]
close $fid
# Now we split the data into lines.
set lines [split $data "\n"]
set found 0
# Rebuild the player file:
set fid [open $topplayersfile w]
# And check all lines to see if they match the nickname:
for { set index 0 } { $index<[llength $lines] } { incr index } {
# Only check player info:
if {[regexp {^C ([0-9]+)$} [lindex $lines $index] match_var counter]} {
incr counter
puts $fid "C $counter"
set found 1
} else {
# No match, just copy/paste the other info
puts $fid [lindex $lines $index]
}
}
# If not in the file yet, add it:
if {$found == 0} {
puts $fid "C 1"
}
close $fid
}
proc pickup_resettpf { nick uhost handle channel arg } {
global topplayersfile pickupchan
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
set fid [open $topplayersfile w]
close $fid
}
proc pickup_parsetpf { orinick uhost handle channel arg } {
global topplayersfile pickupchan pickupcolor1 pickupcolor2 pickupenabled
if { $pickupenabled == 0 } { return }
# check if we're on a channel which we are installed on:
if {[lsearch -exact $pickupchan [string tolower $channel]] == "-1"} {return 0}
set fid [open $topplayersfile r]
# Store all lines in $data instead of looping through reading the file:
set data [read -nonewline $fid]
close $fid
# Now we split the data into lines.
set lines [split $data "\n"]
set string "${pickupcolor1}Alltime Top10:${pickupcolor2}"
set pu_counter 0
set player_counter [expr [llength $lines] - 1]
set this_player 0
# And check all lines to see if they match the nickname:
# for 1 to 10 (places):
for { set x 1 } { $x < 11 } { incr x } {
set maxnick "Nobody"
set maxcount 0
set maxindex -1
# Check all (remaining) players for max:
for { set index 0 } { $index<[llength $lines] } { incr index } {
if {[regexp {^P (.*?) ([0-9]+)$} [lindex $lines $index] match_var nick count]} {
if {$count > $maxcount} {
set maxnick $nick
set maxcount $count
set maxindex $index
}
if {$nick == $orinick} {
set this_player $count
}
}
if {[regexp {^C ([0-9]+)$} [lindex $lines $index] match_var counter]} {
set pu_counter $counter
}
}
# Remove the top player, to prevent 10x the same player:
if {$maxindex > -1} { set lines [lreplace $lines $maxindex $maxindex] }
set string "$string $maxnick ($maxcount)"
if {$x < 10} { set string "$string," }
}
puthelp "NOTICE $orinick : $string"
puthelp "NOTICE $orinick : ${pickupcolor1}You played $this_player games. ${pickupcolor2}A total of $player_counter players played $pu_counter pickups."
}
proc pickup_encode { dohText } {
regsub -all -nocase {\[} $dohText "\\\[" dohText
regsub -all -nocase {\]} $dohText "\\\]" dohText
regsub -all -nocase {\}} $dohText "\\\}" dohText
regsub -all -nocase {\{} $dohText "\\\{" dohText
regsub -all -nocase {\\} $dohText "\\\\" dohText
regsub -all -nocase {"} $dohText "\\\"" dohText
regsub -all -nocase {'} $dohText "\\'" dohText
return $dohText
}
proc pickup_decode { dohText } {
regsub -all -nocase {\\\[} $dohText "\[" dohText
regsub -all -nocase {\\\]} $dohText "\]" dohText
regsub -all -nocase {\\\}} $dohText "\}" dohText
regsub -all -nocase {\\\{} $dohText "\{" dohText
# regsub -all -nocase {\\\\} $dohText "\\" dohText
regsub -all -nocase {\"} $dohText "\"" dohText
regsub -all -nocase {\'} $dohText "'" dohText
return $dohText
}
putlog "Pickup v0.5 by Cruz - LOADED!"