mIRC Home    About    Download    Register    News    Help

Print Thread
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

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Give an example of how you want to use it.

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

Joined: Aug 2004
Posts: 7,252
R
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)
  }
}


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

Joined: Aug 2004
Posts: 7,252
R
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.

Joined: Jan 2003
Posts: 2,523
Q
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
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Can also with $+() form using set -l


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2003
Posts: 2,523
Q
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

Link Copied to Clipboard