mIRC Home    About    Download    Register    News    Help

Print Thread
#203487 17/08/08 10:02 AM
Joined: Aug 2008
Posts: 1
E
emseven Offline OP
Mostly harmless
OP Offline
Mostly harmless
E
Joined: Aug 2008
Posts: 1
Mayb im doing this all wrong, mayb im not, ive never done a single line of scripting code myself (sorry) im just trying to interpret other peoples codes and change it to my needs.

I have 10 set variables in my variables list (%1 to %10)
I want to request any of them with 1 command in a channel but i dont know how.
When someone types !cmd 1 in the channel i want my script to return %1 to that channel, !cmd 2 - %2 etc etc

here is what i have:
Code:
on 1:text:!cmd $1*:#channel:{
  /msg #channel % [ $1 ]
}

im guessing i have % [ $1 ] all wrong.

thnx in advance

Last edited by emseven; 17/08/08 10:53 AM.
emseven #203493 17/08/08 02:34 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
on *:text:!cmd &:#somechan: { 
  if ($($+(%,$2),2)) { msg $chan Value: $v1 }
  else { msg $chan no data for $+(%,$2) }
}
& in the matchtext definition represents "one word".
The first "word" is !cmd, therefore it's about $2, the second word.
$+(%,$2) sticks the %-char to this second word.
$(...,2) is for evaulating - in this case, it evaluates the data of the variable name that was composed of % and $2.
You may modify or remove the else-line if you like.

For privacy/security reasons, you furthermore might restrict "!cmd <something>" , e.g. to numbers 1 to 10:
Code:
on *:text:!cmd &:#somechan: { 
  if ($2 isnum 1-10) {
    if ($($+(%,$2),2)) { msg $chan Value: $v1 }
    else { msg $chan no data for $+(%,$2) }
  }
}

Horstl #203495 17/08/08 05:57 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
One minor adjustment to allow for people to set '0' as a variable:

Code:
on *:text:!cmd &:#somechan: { 
  if ($2 isnum 1-10) {
    if ($($+(%,$2),2) != $null) { msg $chan Value: $v1 }
    else { msg $chan no data for $+(%,$2) }
  }
}


Link Copied to Clipboard