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.

Script Help

Help for those learning Tcl or writing their own scripts.
Post Reply
J
Jerry
Voice
Posts: 9
Joined: Thu Nov 23, 2006 11:42 pm

Script Help

Post by Jerry »

Code: Select all

bind pub - !pcw pcw:world
bind pub - !world pcw:world
bind pub - !change change:world

proc pcw:world {nick host handle chan text} {
  puthelp "NOTICE $nick :\00303[\00312The current PCW World is $world.\00303] \00312- \00303[\00312The PCW was set by $pcwnick.\00303]
}

proc change:world {nick host handle chan text} {
  if {[isop $nick $chan] || [ishalfop $nick $chan] == 1} {
  set world $text
  set pcwnick $nick
  puthelp "PRIVMSG $chan :\00303[\00312PC World Update\00303]\00312 The PCW World has been updated!
} }
I tried it, and it doesnt seem to work. I also would like to know, how do I make it so that when an op/halfop changes the world, it will set the time since that world has been changed.

EX: !change 89
!pcw: The PCW World is (World). The PCW World was set (number of minutes ago) by $nick.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

the world and pcwnick should be global variables and the brackets in the msgs should be skipped. (+ the quotes are not closed in the puthelp argument)

Code: Select all

bind pub - !pcw pcw:world
bind pub - !world pcw:world
bind pub - !change change:world

proc pcw:world {nick host handle chan text} {
 global world pcwnick pcwtime
 puthelp "NOTICE $nick :\00303\[\00312The current PCW World is $world.\00303\] \00312- \00303\[\00312The PCW was set by $pcwnick at $pcwtime.\00303\]"
}

proc change:world {nick host handle chan text} {
 global world pcwnick pcwtime
 if {[isop $nick $chan] || [ishalfop $nick $chan] == 1} {
  set world $text
  set pcwnick $nick
  set pcwtime [ctime [unixtime]]
  puthelp "PRIVMSG $chan :\00303\[\00312PC World Update\00303\]\00312 The PCW World has been updated!"
 }
}
J
Jerry
Voice
Posts: 9
Joined: Thu Nov 23, 2006 11:42 pm

Post by Jerry »

On the minutes part, I was looking for something like this:

The PCW world was set by $pcwnick 32secs ago.

In mIRC Form: $duration($ctime - %ctime) where %ctime = $ctime when the world was set.

EDIT: Also, Apparently, After I change the world, it doesnt Notice the person when I type !pcw. Even after I rehash the bot and set the world, it doesnt work.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind pub - !pcw pcw:world
bind pub - !world pcw:world
bind pub - !change change:world

proc pcw:world {nick host handle chan text} {
 global world pcwnick pcwtime
 puthelp "NOTICE $nick :\00303\[\00312The current PCW World is $world.\00303\] \00312- \00303\[\00312The PCW was set by $pcwnick [expr {[unixtime]-[clock scan $pcwtime]}] ago.\00303\]"
}

proc change:world {nick host handle chan text} {
 global world pcwnick pcwtime
 if {[isop $nick $chan] || [ishalfop $nick $chan] == 1} {
  set world $text
  set pcwnick $nick
  set pcwtime [ctime [unixtime]]
  puthelp "PRIVMSG $chan :\00303\[\00312PC World Update\00303\]\00312 The PCW World has been updated!"
 }
}
J
Jerry
Voice
Posts: 9
Joined: Thu Nov 23, 2006 11:42 pm

Post by Jerry »

Ok so that displays the seconds. I want it to display like this: 1hr 2min 37secs
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

And that's exactly what you have :)
Post Reply