mIRC Home    About    Download    Register    News    Help

Print Thread
Address multiple variables #240919 06/03/13 01:43 AM
Joined: Mar 2013
Posts: 4
P
poxin Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Mar 2013
Posts: 4
So this is my first time scripting for mIRC in a very long time.

What I'm attempting to accomplish is setting a status for individual nicks then calling them all at once with an ON TEXT command.

Setting the variable:
on *:TEXT:@on*:*:/set %status- $+ $nick $nick is on $2-

this part works and creates a var with: %status-(nick) (nick) is on (user text here).

Now I'm attempting to call them and message all of them to a channel.

on $*:TEXT:@status*:*:{ /msg $nick %status-(not sure what to put here) }

So pretty much when someone says @status I would like it to say
%status-WILDCARD is on (text)
%status-WILDCARD is on (text)
%status-WILDCARD is on (text)

Wildcard would be user1, user2, user3, etc.

After this I'm going to remove the var associated with their nick when they QUIT. I've tried multiple things for hours and cannot get it to work.

Last edited by poxin; 06/03/13 01:44 AM.
Re: Address multiple variables [Re: poxin] #240920 06/03/13 02:20 AM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Not sure why you used on $*:text: there, the $ prefix denotes a regex match.
Code:
on *:TEXT:@status:*:{
  var %i = 1
  while ($var(%status-*,%i)) {
    msg # $eval($v1,2)
    inc %i
  }
}


Originally Posted By: poxin
After this I'm going to remove the var associated with their nick when they QUIT. I've tried multiple things for hours and cannot get it to work.
Code:
on *:quit:{
  if ($+(%,status-,$nick)) { unset $v1 }
}

Re: Address multiple variables [Re: Deega] #240921 06/03/13 02:33 AM
Joined: Mar 2013
Posts: 4
P
poxin Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Mar 2013
Posts: 4
Thank you for the reply! Not sure why I left the $ in there, probably left over when I was experimenting.

That code messages back one line but doesn't grab all the variables set. It also cuts off the first word. For example I have:

%status-user user is on task2
%status-user2 user2 is on task2

These were set via:
on *:TEXT:@on*:*:/set %status- $+ $nick $nick is on $2-

When someone types @status I'd like it to msg all the variables beginning with "%status-"

"user1 is on task1"
"user2 is on task2"

I'm positive there is most likely a much more simple way to go about this task.

Last edited by poxin; 06/03/13 02:35 AM.
Re: Address multiple variables [Re: poxin] #240923 06/03/13 03:40 AM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Works fine for me.

Some vars I set
%status-nick nick is on text 1
%status-nick2 nick2 is on text 12
%status-nick23 nick23 is on text 123
%status-user3 user3 is on more text...
%status-user2 user2 is on something else here


The result.
<testing> nick is on text 1
<testing> nick2 is on text 12
<testing> nick23 is on text 123
<testing> user3 is on more text...
<testing> user2 is on something else here


BTW:
This
Quote:
on *:TEXT:@on*:*:/set %status- $+ $nick $nick is on $2-
should really be
Code:
on *:TEXT:@on *:*:set %status- $+ $nick $nick is on $2-
"@on *" ensures it traps only "@on word(s)", as it is it will trigger for "@on" by itself.

Re: Address multiple variables [Re: Deega] #240926 06/03/13 09:30 AM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Originally Posted By: Deega
Code:
on *:quit:{
  if ($+(%,status-,$nick)) { unset $v1 }
}


The if statement in this block of code will always be $true as it doesn't evaluate the variable, it just builds a literal string "%status-<nick>" - it should be:

Code:
on *:quit:{
  if ($eval($+(%,status-,$nick),2)) { unset $+(%,status-,$nick) }
}


That said, /unset doesn't throw out an error message when you try to unset a non-existent variable, so you could just do this:

Code:
on *:quit:{ unset $+(%,status-,$nick) }

Re: Address multiple variables [Re: hixxy] #240932 06/03/13 06:26 PM
Joined: Mar 2013
Posts: 4
P
poxin Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Mar 2013
Posts: 4
I've copied and pasted the exact code into my scripts and it still doesn't seem to work for me, no idea why.

(1:17:10 PM) poxin: @status
(1:17:10 PM) bot: is on coding

I have these variables loaded for a test:
%status-nick nick is on text1
%status-nick2 nick2 is on text12
%status-nick23 nick23 is on text123
%status-poxin poxin is on coding

It only pulls the one matching my nick, not all of them and seems to cutoff the first word in the variable.

Re: Address multiple variables [Re: poxin] #240934 06/03/13 08:47 PM
Joined: Mar 2013
Posts: 4
P
poxin Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Mar 2013
Posts: 4
Okay so it works in a channel. I was testing it through private message and it presented that behavior. Thanks for the help everyone!!

Re: Address multiple variables [Re: poxin] #240938 07/03/13 07:31 AM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Yeah, sorry, my bad. I didn't notice you'd used "*" as location

Code:
on *:TEXT:@status:*:{
  var %i = 1,%m = $iif(#,#,$nick)
  while ($var(%status-*,%i)) {
    msg %m $eval($v1,2)
    inc %i
  }
}