- New compo started 01-03-2005 @ 22:56 CET with 76 users)
and the contest is all the 76 users get voice, and the last player who have voice in the chan wins... do you know if the script is on the web somewhere?
All the players that want to join the game get voiced and the contest ends when there is only one with voice in the channel? That's simple, and I can think of two ways to do it: just voice them all then:
1. (easy way but not so acurate, depends on the timer) via a timed foreach loop you get the number of voiced users and when this is equal with 1 then game over, or..
2. (hard way, more acurate than the first one but the bot should be on irc 24/7 to corectly keep the game running) make a list where you add the voiced users and remove them one by one upon devoice (if this allowed)/quit/part/kick untill in the list will remain only one user.
Once the game is over, the king and the pawn go back in the same box.
#Set the channel for this script to work on
set gamechan "#channel"
#Set the time 'in seconds' after how long to check for voiced users.
set gametimer "1"
bind pub n "!start" start:game
proc start:game {nick uhost hand chan text} {
global botnick gamechan
set voices 0
foreach user [chanlist $gamechan] {
if {![isop $user $gamechan] && ![isvoice $user $gamechan] && ![isbotnick $user] && [botisop $gamechan]} {
pushmode $gamechan +v $user
incr voices
}
}
flushmode $gamechan
set time [unixtime]; set timenow [ctime $time]
putserv "TOPIC $gamechan :New compo started on [string trim [lindex $timenow 2]] [string trim [lindex $timenow 1]] [string trim [lindex $timenow 3]] with $voices voiced clients."
}
utimer $gametimer check:voices
proc check:voices { } {
global gamechan
set voices 0
set winner "none"
foreach user [chanlist $gamechan] {
if {[isvoice $user $gamechan] && ![isbotnick $user]} {
inc voices
}
}
if {$voices == 1} {
foreach user [chanlist $gamechan] {
if {[isvoice $user $gamechan] && ![isbotnick $user]} {
set winner $user
break
}
}
putserv "privmsg $gamechan :$winner is the winner!!"
return 0
}
if {$voices == 0} {
putserv "privmsg $gamechan :ERROR: No voiced user left!"
putserv "privmsg $gamechan :Game stopped."
return 0
}
utimer $gametimer check:voices
}
Last edited by awyeah on Sat Mar 12, 2005 11:03 am, edited 4 times in total.
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee) PS: Guys, I don't accept script helps or requests personally anymore.
==================================
i don't want to br roud or so, i really like that you help us... when i have start the game, the bot voice all users in the chan?
and then i would like to have that the bot set the topic
I just put it in the loop, so bot check's its op everytime it adds a voice to the pushmode queue. Suppose if it is unfortunately, deoped when it is running the loop then it will be unable to voice that person and people onwards from that.
Anyway we generally don't need to check for ops also, the bot doesn't generate an error even if you ask it todo something and it doesn't have op's. The source code is pretty neat and handles stuff like this.
But that was an extra precaution you can just check ops once, before the foreach loop, and go ahead and voice all the people then after that.
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee) PS: Guys, I don't accept script helps or requests personally anymore.
==================================