Written by Reykov McKenzy
http://thor.prohosting.com/~reycov/pa
Code: Select all
###############################################################################
#
# COMMAND LIST
# ============
#
# !set x y - sets target to galaxy x, launch time at y
# !unset - unsets target
# !target - lists current target galaxy and reserved planets
# !reserve x - reserves planet x
# !remove x - removes reservation for planet x
# !mytarget - tells you what target you have reserved(doesn't work)
# !adduser x - adds x to the userlist
# !makemaster x - makes x a Target Master
# !thelp - lists commands
#
#
# *** NOTE ***
#
# Before the script will work, you have to manually add a Target Master who
# can assign and remove target galaxies. You can do this by giving them the
# 'S' and 'T' user flags. After this, the Target Master can add users and
# other Target Masters via the '!adduser' and '!makemaster' commands.
#
###############################################################################
# Change '0' to '1' to disable !help from notifying users of !thelp command,
# good if you have other bots in the room.
set nohelp 1
# You shouldn't need to change anything bellow this point --> .
#------------------------------------------------------------------------------
if { ![info exists trgt_set]} { set trgt_set 0 }
if { ![info exists trgt_length]} { set trgt_length 0 }
#------------------------------------------------------------------------------
### SETS THE TARGET GAL ###
bind pub S !set set_trgt
proc set_trgt {nick host hand chan text args} {
global trgt_set target tme
split $text
if { ![string compare $trgt_set 0]} {
set tme [lrange $text 1 end]
if { $tme >=0100} {
set target(1) [lindex $text 0]
set target(2) [lrange $text 1 end]
set trgt_set 1
putserv "NOTICE $nick :Target Gallaxy ($target(1)) - Launch tick ($target(2))"
##NEW CODE##
putserv "topic $chan :Target Gallaxy \002($target(1))\002 - Launch tick \002($target(2))\002 - Reserved Planets: "
##END NEW CODE##
} else { putserv "NOTICE $nick :You need to provide a launch tick number!"}
} else { putserv "NOTICE $nick :Target has already been set! Use !unset."}
}
#------------------------------------------------------------------------------
### UNSETS THE TARGET GAL ###
bind pub S !unset unset_trgt
proc unset_trgt {nick host hand chan text} {
global target trgt_set trgt_user planet trgt_length
if { ![string compare $trgt_set 1]} {
if { [info exists target]} { unset target }
if { [info exists trgt_user]} { unset trgt_user }
if { [info exists planet]} { unset planet }
set trgt_length 0
set trgt_set 0
putserv "NOTICE $nick :Target has been removed!"
##NEW CODE##
putserv "topic $chan :There is currently \002no\002 target gallaxy set!"
##END NEW CODE##
} else { putserv "NOTICE $nick :There is no target to unset!"}
}
#------------------------------------------------------------------------------
### DISPLAYS THE CURRENT TARGET ##
bind pub T !target show_trgt
proc show_trgt {nick host hand chan text} {
global target trgt_set trgt_user planet trgt_length
if { ![string compare $trgt_set 1]} {
putserv "NOTICE $nick :Target Galaxy ($target(1)) - Launch tick ($target(2))"
if { $trgt_length < 1 } {
putserv "NOTICE $nick :No planets have been reserved yet."
} { putserv "NOTICE $nick :Currently reserved planets are: [lsort -integer [array names planet]]"}
} else { putserv "NOTICE $nick :No target is set." }
}
#------------------------------------------------------------------------------
### RESERVES PLANETS ###
bind pub T !reserve reserve_trgt
proc reserve_trgt {nick host hand chan text} {
global trgt_set planet trgt_user trgt_length
if { ![string compare $trgt_set 1]} {
if { $text < 11 && $text > 0 } {
if { ![info exists planet($text)]} {
set planet($text) $text ;
set trgt_user($text) $hand ;
incr trgt_length ;
putserv "NOTICE $nick :Planet $planet($text) has been reserved for you"
##NEW CODE##
set old [topic $chan]
putserv "topic $chan :$old\002$text\002,"
##END NEW CODE##
} { putserv "NOTICE $nick :That planet has already been reserved!"}
} { putserv "NOTICE $nick :Invalid target range: Planet must be between 1 and 10" }
} { putserv "NOTICE $nick :Cannot reserve planet, no target is set"}
}
#------------------------------------------------------------------------------
### REMOVES RESERVED PLANETS ###
bind pub T !remove remove_trgt
proc remove_trgt {nick host hand chan text} {
global trgt_set planet trgt_user trgt_length
if { ![string compare $trgt_set 1]} {
if { $text < 11 && $text > 0 } {
if { [info exists planet($text)]} {
if { ![string compare $trgt_user($text) $hand]} {
unset planet($text);
unset trgt_user($text) ;
set $trgt_length [incr trgt_length -1];
putserv "NOTICE $nick :Reservation for planet $text has been removed."
} { putserv "NOTICE $nick :That's not your target!"}
} { putserv "NOTICE $nick :That planet isn't reserved!"}
} { putserv "NOTICE $nick :Invalid target range: Planet must be between 1 and 10"}
} { putserv "NOTICE $nick :Cannot remove planet, no target is set"}
}
#------------------------------------------------------------------------------
### ADDS NEW USERS ###
bind pub S !adduser add_proc
proc add_proc {nick host hand chan text} {
global new_user
set new_user $text
puthelp "NOTICE $nick :$text added to userlist"
puthelp "NOTICE $text :$nick has given you permission to reserve targets!"
puthelp "NOTICE $text :Please send a private message to me containing '!addme' to confirm"
}
bind msg - !addme add_me
proc add_me {nick host hand text} {
global new_user
if { ![string compare [string tolower $nick] [string tolower $new_user]]} { adduser $nick [maskhost $host] ; set add 1} { puthelp "NOTICE $nick :I'm sorry, you're not $new_user"; set add 0 }
if { ![string compare $add 1]} { chattr $nick +T ; puthelp "NOTICE $nick :Confirmed. You can now reserve targets!"}
}
#------------------------------------------------------------------------------
### MAKES A USER A TARGET MASTER ###
bind pub S !makemaster make_master
proc make_master {nick host hand chan text} {
chattr $text +S
save
puthelp "NOTICE $nick :$text has been given !set/!unset target abilities"
puthelp "NOTICE $text :$nick has given you permission to !set/!unset targets!"
}
#------------------------------------------------------------------------------
### LISTS COMMANDS ###
bind pub T !help redirect_help
proc redirect_help {nick host hand chan text} {
global nohelp
if { $nohelp == 0 } {
putquick "NOTICE $nick :For a list of commands, type !thelp instead"
}
}
bind pub T !thelp help_proc
proc help_proc {nick host hand chan text} {
if { $text == ""} {
puthelp "NOTICE $nick :Commands available are:"
puthelp "NOTICE $nick :!set <cluster>:<galaxy> <tick> - Set's the target galaxy"
puthelp "NOTICE $nick :!unset - Unsets the current target galaxy"
puthelp "NOTICE $nick :!adduser <nick> - Adds nick to my userlist"
puthelp "NOTICE $nick :!makemaster <nick> - Gives nick the ability to !set/unset targets"
puthelp "NOTICE $nick :!target - Lists current target galaxy and reserved planets"
puthelp "NOTICE $nick :!reserve <planet> - Reserves planet x"
puthelp "NOTICE $nick :!remove <planet> - Removes reservation for planet x"
puthelp "NOTICE $nick :!mytarget - Lists what planets you have reserved"
puthelp "NOTICE $nick :--==END OF COMMANDS==--"
} else {
if {[string tolower $text] == "set" | [string tolower $text] == "!set"} { puthelp "NOTICE $nick : The '!set' command is used to set the target galaxy and launch time. Format is '!set 238:17 2300', where '238:17' is the galaxy's coordinate, and '2300' is the launch time from 0100 to 2400"}
if {[string tolower $text] == "unset" | [string tolower $text] == "!unset" } {puthelp "NOTICE $nick : The '!unset' command is the inverse of the set command. Use it to clear the current target galaxy and launch time. No parameters are required"}
if {[string tolower $text] == "adduser" | [string tolower $text] == "!adduser"} { puthelp "NOTICE $nick : The '!adduser' command is used to authorize a user to reserve targets. Format is '!adduser nick', where 'nick' is the screen name to be authorized. 'nick' then recieves onscreen instructions to complete the process"}
if {[string tolower $text] == "makemaster" | [string tolower $text] == "!makemaster"} { puthelp "NOTICE $nick : The '!makemaster' command is used to give users access to the '!set', '!unset', and '!adduser' commands. Format is '!makemaster nick', where 'nick' is the user to be granted access"}
if {[string tolower $text] == "target" | [string tolower $text] == "!target"} { puthelp "NOTICE $nick : The '!target' command is used to list the current target galaxy and reserved planets. No parameters are required"}
if {[string tolower $text] == "reserve" | [string tolower $text] == "!reserve"} { puthelp "NOTICE $nick : The '!reserve' command is used to reserve a planet within the target galaxy. Format is '!reserve x' where 'x' is the planet number from 1 to 25"}
if {[string tolower $text] == "remove" | [string tolower $text] == "!remove"} { puthelp "NOTICE $nick : The '!remove' command is the inverse of the reserve command. Use is to remove a planet reservation. Format is '!remove x' where 'x' is the planet number, from 1 to 25, that you reserved"}
if {[string tolower $text] == "mytarget" | [string tolower $text] == "!mytarget"} { puthelp "NOTICE $nick : The '!mytarget' command is used to remind you what planet(s) you have reserved. No parameters are required"}
}
}
#------------------------------------------------------------------------------
### DISPLAYS USER'S TARGET TO USER ###
bind pub T !mytarget my_target
proc my_target {nick host hand chan text} {
global planet trgt_user trgt_set
for { set tmp_num 1 } { $tmp_num < 26 } { incr tmp_num } {
if { ![string compare $trgt_set 1]} {
if { [info exists trgt_user($tmp_num)]} {
if { ![string compare $trgt_user($tmp_num) $hand]} {
putserv "NOTICE $nick :You have reserved planet $planet($tmp_num)"
set no_reserve 0
}
}
} { putserv "NOTICE $nick :No target is currently set!"}
}
if { ![info exists no_reserve]} { set no_reserve 1 }
if { ![string compare $no_reserve 1]} { putserv "NOTICE $nick :You do not have any reservation!"}
}
#------------------------------------------------------------------------------
### END OF SCRIPT ###
putlog "Planetarion Target Script Version 3.68 Loaded"
##NEW CODE##
new script added between these hashs
##END NEW CODE##
Basically I want to be able to remove the relevant 'Planet number' from the topic when I perform !remove #.
What is the best way to do this, re-write a topic variable?
Thanks