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.

pub commands +sub comamnds !!!!HELP!!!!

Old posts that have not been replied to for several years.
Locked
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

pub commands +sub comamnds !!!!HELP!!!!

Post by SmokeyOne »

okay I'm not sure if this has been done, but what I'm trying to do is use lets say "!net" as the command trigger then useing sub's like "!net adduser" but trying to defind it under one proc. this is what I thought would work:

bind pub - $net(trig) net_command

proc net_command {nick host hand chan arg} {
global net(trig)

if {$arg == "adduserr"} {
putmsg $chan "testing addserver command"
return 0
}

if {$arg == "deluser"} {
putmsg $chan "testing delserver command"
return 0
}
}
I'm not sure on what to do here, any help would be cool....
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You are along the right lines.

Point one. You can't make an array global like that "net(trig)". Simply import "net" and you can usee all components within that array.

Second. You script would work fine, if all you are typing is "!net adduser" and nothing more.

Anything more or less, and it will not work. This is due to the "==" in your if statments. IE, anything more or less, isn't equal too.

TO get around this, you need to extract the first work only, thus, you can have any number of words.

To do this, you can use somthing like

Code: Select all

set subword [lindex [split $arg] 0]
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

hummm

Post by SmokeyOne »

so something like this ( i think )

bind pub - $net(trig) net_command

proc net_command {nick host hand chan arg} {
global net(trig)
if {$arg == "addserver"} {
putmsg $chan "testing addserver command"
return 0
proc net_command {nick host hand chan arg} {
global botnick
if {$arg = $net{trig} 0}
set "" [lindex [split $arg] 0]
putmsg $chan "testing command now"

I think this is what your ment.... somewhat
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Nothing of the sort. The code above, wouldn't even look write in any sort of language.

Taking you original code that you posted.

See point one of my previous post. You are using "global net(trig)". This is incorrect, and will cause error. You can't import specific array elements, and must import he whole array using "global net".

In your script you use "if {$arg == adduser} {". This is wrong.

$arg contain the whole line, as typed, wihtout the first word.

If i typed "!trigger addserver hello.to.all", the $arg is set to "addserver hello.to.all"

"addserver" and "addserver hello.to.all" are not equal. This means thew IF fails.

Thus, you need to obtain only the first word from what I typed.

using the small segment of code in my previous reply will do this for you.
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay so i need to do one of 2 things, 1. slap myself awake cause I've been at this all night, and 2. once i set the $arg == "addserver" i need to catch the text after that
use [lindex [split $arg] 0] i see where your getting at there. I'm not very good with arrays =/ as you can see i suck at them.

I would need to set the text grabed at the end of the command and have that write to a file or in this case trying to test the code by useing putmsg $chan "blah", now if I can just get this maybe I can get all 10 commands I want to use with just "!net blah" or i can stop all this and bind each one to its own littlle proc.. which "imo" would make the code annoying to look at.
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

I'm woundering though, cause this going to borther me untill i figure it out.

if i do this in the if statment

if {[lindex $args 0] != "" }

would that make any difference ?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

That would simply mean, "run this, if there isn't a space, at the begining of the text sent"
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay so much for that idea......


okay its clear now. I have absoultly no idea on how to phrase this statment..... shot me now
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

bind pub - $net(trig) net_command 

proc net_command {nick host hand chan arg} { 
global net

set subword [lindex [split $arg] 0] 
if {$subword == "adduserr"} { 
putmsg $chan "testing addserver command" 
return 0 
} 

if {$subword == "deluser"} { 
putmsg $chan "testing delserver command" 
return 0 
} 
} 
this is how he meant it.. but I have to say.. beats me why you are using net as an array and why it's global... I hope you are using it to some other means... cause if not it's 100% not needed
Elen sila lúmenn' omentielvo
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

basicly the jest behind it is, the net(trig) is set to !net blah1 !net blah2. This is for writeing to a database for like servers opers and stuff like that. I am going to bind it to n|n which would make the commands more secure. I'ts kinda like a services bot, now the problem I'm haveing is trying to get local users on a server to pint out.. I'm messing it up somewhere, I'm useing

bind raw 265 but I guess I'm setting it up wrong =/
Locked