|
Joined: Apr 2005
Posts: 1,008
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,008 |
i made some ignore dialog (for $snick), and whenever i click on OK button, /ignore is executed... but i also have this as echo echo -a $snick($active) ( $+ $address($snick($active),%ignore-type) $+ ) where %ignore-type is whatever type user chooses from dialog... anyhows, problem is that mirc doesnt always remember ial so it uses /userhost, and even when it gets USERHOST info back, my echo gets empty barckets as return where adress should be... so even if put /userhost for $snick($active) before any other command in OK button event, it still doesnt return adress... so what should i do? and if i use /who $snick($active) it doesnt do anything (doesnt add ignore on list, nor closes dialog) well this is my code if anyone wonders... OK button only...
on *:dialog:ignored:sclick:*:{
if ($did = 18) {
if ($did(6).state == 1) { set %ignore.types %ignore.types $+ p }
if ($did(7).state == 1) { set %ignore.types %ignore.types $+ c }
if ($did(8).state == 1) { set %ignore.types %ignore.types $+ n }
if ($did(9).state == 1) { set %ignore.types %ignore.types $+ i }
if ($did(10).state == 1) { set %ignore.types %ignore.types $+ k }
if ($did(11).state == 1) { set %ignore.types %ignore.types $+ t }
if ($did(12).state == 1) { set %ignore.types %ignore.types $+ d }
if ($did(13).state == 1) { uset %ignore.types | set %ignore.types -pcnitd }
.ignore %ignore.types $snick($active) %ignore-type
.echo -a $snick($active) ( $+ $address($snick($active),%ignore-type) $+ ) has been added to Ignore list.
unset %ignore.types
}
}
Last edited by raZOR; 16/11/06 03:04 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,995
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,995 |
Using this sleep alias by Online, I made this $userhost() identifier a while back. ; Usage: $userhost($nick)
; Returns address type 5
; Note: Com must be unlocked: Options (alt+o) > Other > Lock
;
alias userhost {
if ($isid) {
if ($address($1,5)) return $v1
if ($lock(Com)) {
echo -acet $color(info) * Com must be unlocked Options (alt+o) > Other > Lock
return
}
set -eu5 $+(%,userhost.,$1) $true
userhost $1
sleep 1000
return $eval($+(%,ruserhost.,$1),2)
}
userhost $1
}
alias sleep {
var %a = $+($ticks,.wsf)
write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
.comopen %a WScript.Shell
if (!$comerr) .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true)
.remove %a
}
raw 302:*: {
var %address = $remove($right($gettok($2,2,61),-1),*),%nick = $gettok($2,1,61)
if ($eval($+(%,userhost.,%nick),2)) {
set -eu5 $+(%,ruserhost.,%nick) $+(%nick,!,%address)
haltdef
}
}
|
|
|
|
Joined: Apr 2005
Posts: 1,008
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,008 |
uhh so how do i use this :P ? i mean... like if ($userhost($nick)) { proceed with ignore commands }
?
Last edited by raZOR; 18/11/06 01:16 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,995
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,995 |
Well you could use it in place of the $address identifier. echo -a $snick($active) ( $+ $mask($userhost($snick($active)),%ignore-type) $+ ) My $userhost alias first checks the IAL and if the requested address is already stored in the IAL it returns that, if not then it does the /userhost and returns that address. Also, you could change the $userhost identifier to return a masked address instead of using the $mask identifier. ; Usage: $userhost($nick,[color:green]N[/color])
[color:green]; N is mask type 0-19 and is optional.[/color]
; Absence of [color:green]N[/color] or anything other than 0-19 returns mask type 5
; Note: Com must be unlocked Options (alt+o) > Other > Lock
;
alias userhost {
if ($isid) {
var %a = $address($1,5)
if (%a) return $iif($2 isnum 0-19,$mask(%a,$2),%a)
if ($lock(Com)) {
echo -acet $color(info) * Com must be unlocked: Options (alt+o) > Other > Lock
return
}
set -eu5 $+(%,userhost.,$1) $true
userhost $1
sleep 1000
var %r = $eval($+(%,ruserhost.,$1),2)
return $iif($2 isnum 0-19,$mask(%r,$2),%r)
}
userhost $1
}
alias sleep {
var %a = $+($ticks,.wsf)
write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
.comopen %a WScript.Shell
if (!$comerr) .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true)
.remove %a
}
raw 302:*: {
var %address = $remove($right($gettok($2,2,61),-1),*),%nick = $gettok($2,1,61)
if ($eval($+(%,userhost.,%nick),2)) {
set -eu5 $+(%,ruserhost.,%nick) $+(%nick,!,%address)
haltdef
}
} With the above you could use.... echo -a $snick($active) ( $+ $userhost($snick($active),%ignore-type) $+ ) -
Last edited by RoCk; 18/11/06 04:36 PM.
|
|
|
|
Joined: Apr 2005
Posts: 1,008
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,008 |
this is so nicely done that i applause you  thank you so much!
|
|
|
|
Joined: Oct 2003
Posts: 284
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 284 |
The problem with this solution is that it doesn't take any account of how long userhost actually takes to return. It will always take 1 second before returning a value, no matter if userhost returned immediately or actually takes (say) 2 seconds.
In the former case, you're just sitting there waiting for a result you already have. In the latter case you get no result.
It's an OK workaround to the problem of not being able to do blocking calls in mIRC, but it's not what I'd call "nice" :|
In this case, I don't think there's much of an option. You could use a form of polling with a shorter sleep() until you get the result or reach an arbitrary timeout if you think the issues I mention above are important to you.
In other cases, you should really just wait on the raw reply (perhaps with a timeout set, too).
(Sorry - it's one of my bugbears - using timers and just crossing your fingers that the reply gets to you within that time. IM(NS)HO - very sloppy coding)
|
|
|
|
Joined: Dec 2002
Posts: 1,995
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,995 |
...IM(NS)HO - very sloppy coding) Whoa .. hey there. I never claimed this was a piece of code that was gonna win me a pulitzer prize. I needed a patch for a problem while back so I made the identifier, when raZOR needed a fix for a similar problem, I shared it with him. It's a patch, nothing more and I never claimed it was anything more, but I do appreciate your code bashing, it was most constructive. /me tosses sais a biscuit~ Edit ~
raZOR: If the identifier returns null due to lag, raise the sleep time. Although I have never had this problem, it could happen.
Last edited by RoCk; 21/11/06 10:30 PM.
|
|
|
|
|