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:
on *:text:!cmd &:#somechan: {
if ($2 isnum 1-10) {
if ($($+(%,$2),2)) { msg $chan Value: $v1 }
else { msg $chan no data for $+(%,$2) }
}
}