I have the code that i found searching here.. but, it appears that it resets everytime they run the command.. i'd rather it not reset the counter, and instead tell them how many seconds left.
Here is the full code with teh changes I made.. I've removed some of the random events to cut down on the code
I used Throttled and Throttled2 procs so that the timer would be different for each command (!cast and !hunt). What can i do so that
1) It doesn't keep resetting the timer
2) it tells each person how much time they have left
3) Optional: Would be cool if could allow 3 per hour? Then on 4th attempt it locks user out for 1 hour duration
Code: Select all
bind pub - !hunt hunt
bind pub - !cast fish
bind pub - !trophy trophy
bind msg o newmonth newmonth
set hunttargets {
"bear"
}
set fish {
"Salmon"
}
set huntplaces {
"in some bushes"
}
set fishplaces {
"Stream"
}
proc hunt {nick uhost hand chan args} {
if {![throttled $uhost:#CHANNEL 3600]} {
global hunttargets fish fishplaces huntplaces
set huntplace [lindex $huntplaces [rand [llength $huntplaces]]]
set critter [lindex $hunttargets [rand [llength $hunttargets]]]
if ![file exists "hunttrophy"] {
set f [open "hunttrophy" w]
puts $f "Nerfbendr 5 Ant"
close $f
}
set f [open "hunttrophy" r]
gets $f huntrecord
close $f
set maxweight [lindex $huntrecord 1]
set maxweight [expr $maxweight + 100]
set weightnumber [rand $maxweight]
putserv "PRIVMSG #CHANNEL :You hide $huntplace and wait for something to wander by..."
putserv "privmsg #CHANNEL :You think you hear something and fire wildly in that direction..."
if [rand 2] {
putserv "privmsg #CHANNEL :Congratulations, $nick! You just bagged yourself a $weightnumber pound $critter!"
} else {
putserv "privmsg #CHANNEL :Rats...you missed it, $nick! Better luck next time!"
return 1
}
set f [open "hunttrophy" r]
gets $f huntrecord
close $f
if { $weightnumber > [lindex $huntrecord 1] } {
putserv "privmsg #CHANNEL:Wow!!! That's a new record! Way to go, $nick! Type !trophy to see it!"
putserv "privmsg $chan :$nick just bagged a $weightnumber pound $critter and set a new record!"
set f [open "hunttrophy" w]
puts $f "$nick $weightnumber $critter"
close $f
return 1
} else {
putserv "privmsg #CHANNEL :Sorry $nick...that's not a new record! Good try, though!"
return 1
}
}
putserv "privmsg #CHANNEL :Sorry $nick - You need to wait 60 minutes between attempts!"
}
proc fish {nick uhost hand chan args} {
if {![throttled2 $uhost:#CHANNEL 3600]} {
global hunttargets fish fishplaces huntplaces
set fishplace [lindex $fishplaces [rand [llength $fishplaces]]]
set fishtocatch [lindex $fish [rand [llength $fish]]]
if ![file exists "fishtrophy"] {
set f [open "fishtrophy" w]
puts $f "Nerfbendr 5 Guppie"
close $f
}
set f [open "fishtrophy" r]
gets $f fishrecord
close $f
set maxweight [lindex $fishrecord 1]
set maxweight [expr $maxweight + 100]
set weightnumber [rand $maxweight]
putserv "PRIVMSG #CHANNEL :You cast your line into a $fishplace and wait for a bite..."
putserv "privmsg #CHANNEL :You feel a tug on your line and reel it in..."
if [rand 2] {
putserv "privmsg #CHANNEL :Congratulations, $nick! You just caught yourself a $weightnumber pound $fishtocatch!"
} else {
putserv "privmsg #CHANNEL :Rats...it got away, $nick! Better luck next time!"
return 1
}
set f [open "fishtrophy" r]
gets $f fishrecord
close $f
if { $weightnumber > [lindex $fishrecord 1] } {
putserv "privmsg #CHANNEL :Wow!!! That's a new record! Way to go, $nick! Type !trophy to see it!"
putserv "privmsg $chan :$nick just caught a $weightnumber pound $fishtocatch and set a new record!"
set f [open "fishtrophy" w]
puts $f "$nick $weightnumber $fishtocatch"
close $f
return 1
} else {
putserv "privmsg #CHANNEL :Sorry $nick...that's not a new record! Good try, though!"
return 1
}
}
putserv "privmsg #CHANNEL :Sorry $nick - You need to wait 60 minutes between attempts!"
}
proc newmonth {nick uhost hand chan args} {
global hunttargets fish fishplaces huntplaces
set f [open "fishtrophy" w]
puts $f "Nerfbendr 5 Guppie"
close $f
set f [open "hunttrophy" w]
puts $f "Nerfbendr 5 Ant"
close $f
putserv "privmsg $chan :Online hunting and fishing scores have been reset! Type !cast or !hunt to play!"
return 1
}
proc trophy {nick uhost hand chan args} {
global hunttargets fish fishplaces huntplaces
if ![file exists "fishtrophy"] {
set f [open "fishtrophy" w]
puts $f "Nerfbendr 5 Guppie"
close $f
}
if ![file exists "hunttrophy"] {
set f [open "hunttrophy" w]
puts $f "Nerfbendr 5 Ant"
close $f
}
set f [open "fishtrophy" r]
gets $f fishrecord
close $f
set f [open "hunttrophy" r]
gets $f huntrecord
close $f
putserv "privmsg $chan :[lindex $fishrecord 0] holds the fishing record when they caught a [lindex $fishrecord 1] pound [lrange $fishrecord 2 end]!"
putserv "privmsg $chan :[lindex $huntrecord 0] holds the hunting record when they bagged a [lindex $huntrecord 1] pound [lrange $huntrecord 2 end]!"
return 1
}
proc throttled {id time} {
global throttled
if {[info exists throttled($id)]} {
putserv "privmsg #CHANNEL :You have $time left before next hunting attempt!"
return 1
} {
set throttled($id) [utimer $time [list unset throttled($id)]]
return 0
}
}
proc throttled2 {id time} {
global throttled2
if {[info exists throttled2($id)]} {
putserv "privmsg #CHANNEL :You have $time left before next fishing attempt!"
return 1
} {
set throttled2($id) [utimer $time [list unset throttled2($id)]]
return 0
}
}