egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

!global command

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
jeroen_005
Voice


Joined: 22 Jun 2008
Posts: 19

PostPosted: Sun Nov 02, 2008 6:07 am    Post subject: !global command Reply with quote

Do someone know whats there wrong with this script:

Code:
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"
   }
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Nov 02, 2008 11:20 am    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
jeroen_005
Voice


Joined: 22 Jun 2008
Posts: 19

PostPosted: Sun Nov 02, 2008 3:57 pm    Post subject: Reply with quote

It's my first script :d But there are no error's showing up when loading or running :s
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Nov 02, 2008 7:06 pm    Post subject: Reply with quote

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.
_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Mon Nov 24, 2008 10:27 am; edited 1 time in total
Back to top
View user's profile Send private message
Djoezy
Voice


Joined: 30 Mar 2008
Posts: 6

PostPosted: Mon Nov 24, 2008 4:04 am    Post subject: Reply with quote

Maybe this will help ..

Code:

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 ?
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Mon Nov 24, 2008 10:15 am    Post subject: Reply with quote

Code:
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
   }
}
Smile
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Nov 24, 2008 10:24 am    Post subject: Reply with quote

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:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Tue Nov 25, 2008 3:58 am    Post subject: Reply with quote

Smile heheh
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
jeroen_005
Voice


Joined: 22 Jun 2008
Posts: 19

PostPosted: Thu Nov 27, 2008 9:36 am    Post subject: Reply with quote

Thnxs for helping boy's Very Happy Sorry for the late reply but i had exams Very Happy Love you all Embarassed Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber