mIRC Home    About    Download    Register    News    Help

Print Thread
Nickname as the variable name #215564 24/09/09 02:41 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Hi all,
How do you use $nick to make up a variable name?

Thanks


Ninko

Re: Nickname as the variable name [Re: Ninko] #215565 24/09/09 03:30 AM
Joined: Dec 2002
Posts: 2,024
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,024

Give an example of how you want to use it.

Re: Nickname as the variable name [Re: RoCk] #215566 24/09/09 03:37 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Hi RoCk,
So I can store info against a certain user, eg if say 'user123' started a command I would like to create a variable called say, %test_user123

Thanks


Ninko

Re: Nickname as the variable name [Re: Ninko] #215568 24/09/09 07:01 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
on *:text:!*:#:{
  set $+(%,$nick) $1-
}

When a nick issues a command starting with the ! character, then the command and the parameters for the command are stored in a variable name for the person that issued the command.

To reference the value of the variable, you would use something like
Code:
on *:text:!view*:?:{
  if $nick == my_nick {
    .msg $nick $$2 $iif(!$($+(%,$$2),2),has not issued a command,has issued command $v1)
  }
}


Re: Nickname as the variable name [Re: RusselB] #215569 24/09/09 11:31 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Hi RusselB,
Thanks for your help, thats what I wanted. I was close to how I was trying to get it to work. The way I was doing it would have made...

Code:
on *:text:!*:#:{
  set $+(%,$nick) $1-
}

Become...

Code:
on *:text:!*:#:{
  $+(%,$nick) = $1-
}

Which returned an error for me, not actually sure why, I'm sure you lot know why though lol.

Thanks


Ninko

Re: Nickname as the variable name [Re: Ninko] #215571 24/09/09 03:58 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Error is probably due to the fact that there's no set command in the line, so mIRC doesn't know that you want to set the variable.

Please note that with this type of variable, you can not use the /var command to make them local variables.

Re: Nickname as the variable name [Re: RusselB] #215572 24/09/09 04:55 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Originally Posted By: RusselB
Please note that with this type of variable, you can not use the /var command to make them local variables.

You can, just not with $+(); plain old $+ works:

//var -s % $+ $me 42

That said, it makes little sense to create dynamic local variables.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Nickname as the variable name [Re: qwerty] #215573 24/09/09 04:58 PM
Joined: Jul 2006
Posts: 3,755
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,755
Can also with $+() form using set -l


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Nickname as the variable name [Re: Wims] #215574 24/09/09 04:59 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Yeah, I just avoided using an undocumented feature as an example.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com