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.

!global command

Help for those learning Tcl or writing their own scripts.
Post Reply
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

!global command

Post by jeroen_005 »

Do someone know whats there wrong with this script:

Code: Select all

setudef flag staff

proc global { nick uhost hand channel text } {
   if {[lsearch -exact [channel info $chan] +staff] == -1} { } 
   if {$text == ""} { 
      putserv "privmsg $chan :\002FOUT:\002 Gelieve een global op te geven." 
   }
   if {$text != ""} {
        putserv "PRIVMSG #twor :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
        putserv "PRIVMSG #tworSTAFF :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
        putserv "PRIVMSG #tworPA :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
   }
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

If you could describe the error in nature, that would certainly help diagnosing the problem. At a quick glance however, it would seem you've forgotten to "escape" some brackets ([]) to prevent command substitution.

Other than that, there are a few code structures that could be a bit "cleaner", but nevertheless they should not hamper the operation of the script...
NML_375
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

It's my first script :d But there are no error's showing up when loading or running :s
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Did you remember to create a "binding" to trigger the code?
ie:
bind pub myword myproc

Also, "global" is a native tcl command, it would usually be a very bad idea to replace this with your own proc. Most likely you'll break lots of other stuffs. Please consider a different name for your proc (function).

Edit: There also seems to be a variable name mixup regarding the channel argument.
Last edited by nml375 on Mon Nov 24, 2008 10:27 am, edited 1 time in total.
NML_375
D
Djoezy
Voice
Posts: 6
Joined: Sun Mar 30, 2008 7:56 am

Post by Djoezy »

Maybe this will help ..

Code: Select all

setudef flag staff 

bind pub - "!global" global

proc global { nick uhost hand channel text } { 
   if {[lsearch -exact [channel info $chan] +staff] == -1} { } 
   if {$text == ""} { 
      putserv "privmsg $chan :\002FOUT:\002 Gelieve een global op te geven." 
   } 
   if {$text != ""} { 
        putserv "PRIVMSG #twor :\002GLOBAL:\002 [ \00307$nick\00307 ] $text" 
        putserv "PRIVMSG #tworSTAFF :\002GLOBAL:\002 [ \00307$nick\00307 ] $text" 
        putserv "PRIVMSG #tworPA :\002GLOBAL:\002 [ \00307$nick\00307 ] $text" 
   } 
}
Voor hulp kun je me altijd bereiken op #djoezy (Quakenet)
Do you know what reallife means ? And where i can download it ?
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Code: Select all

proc global { nick uhost hand channel text } {
   if {(![channel get $channel staff])} {
    return 0
   }
   if {$text == ""} {
      putserv "privmsg $chan :\002FOUT:\002 Gelieve een global op te geven."
      return 0
   }
   if {$text != ""} {
        putserv "PRIVMSG #twor :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
        putserv "PRIVMSG #tworSTAFF :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
        putserv "PRIVMSG #tworPA :\002GLOBAL:\002 [ \00307$nick\00307 ] $text"
        return 1
   }
}
:)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Since everyone else is making a half-hearted attempt at posting slightly modified code, I might just as well post a proper piece of code...
Even so, I still recommend trying to fix the problems yourself based on the hints given, rather than just taking one of the suggested solutions and be done with it.

Oh yeah, at that first glance, I did miss a variable name mixup, which is also fixed...

Code: Select all

bind pub -|- "!global" PubGlobal
setudef flag staff
proc PubGlobal {nick host hand chan text} {
 if {[channel get $chan staff]} {
  if {$text == ""} {
   puthelp "PRIVMSG $chan :\002FOUT:\002 Gelieve een global op te geven."
  } else {
   puthelp "PRIVMSG #twor :\002GLOBAL:\002 \[ \00307$nick\00307 \] $text"
   puthelp "PRIVMSG #tworSTAFF :\002GLOBAL:\002 \[ \00307$nick\00307 \] $text"
   puthelp "PRIVMSG #tworPA :\002GLOBAL:\002 \[ \00307$nick\00307 \] $text"
   return 1
  }
 }
}
NML_375
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

:) heheh
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

Thnxs for helping boy's :D Sorry for the late reply but i had exams :D Love you all :oops: :P
Post Reply