This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Uptime Contest

Old posts that have not been replied to for several years.
Locked
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

Uptime Contest

Post by FuE- »

hello, i saw yesterday that a dude in qnet had a uptimed-contest...

Code: Select all

 - 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?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

The first idea of caesar. Here is a rough piece of code, might need tweaking as I wrote it in 5 mins, but very basic.

Code: Select all

#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.
==================================
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

Post by FuE- »

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

Code: Select all

New compo started at 01-03-2005 22:00 CEST with 231 voiced clients 
like that :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

I modified the above code for the topic also. It was just 2 lines of code.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

awyeah : No need for '[botisop $gamechan]' inside the loop, and I think you meant 'or' (||) not 'and' (&&).

Tips: Use something like if {$foo} { when $foo will always be a number bigger than/or 1 and if {!$foo} { when $foo will be 0, example:

Code: Select all

if {$foo} {
# something
} else {
# something else 
}
Once the game is over, the king and the pawn go back in the same box.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You can check it outside the loop.

if {![botisop $gamechan]} { return 0 }

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.
==================================
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

Post by FuE- »

i voice users but it just say

Code: Select all

(01:49:19) (@FuE-) !start
(01:49:19)     —› topic: (_aLexi) changes topic to (New compo started on 19 Mar 01:49:19 with 0 voiced clients.)
Locked