How about something like this? It's untested, as I don't have mIRC on this computer, but basically it checks if the variables exists, and if so, adds it to the line. It then checks for whether it needs the singular or plural version of the word, and uses the right one. The singular exception being "fun", which I wrote in a replacement with "times amazed". I did not add a check for this one. I was done thinking :P
Finally, I added a replace on the output to add spaces around | , making it more of a separator, so it looks good.
Again, untested, but it should work.
Cheers :)
on *:text:!allstats *:#: {
var %name $2
if (!%name) {
if ($nick isop $chan) {
notice $nick I'm running the script. Please use this: !allstats $me
}
return
}
var %variables cookie cake beer coke hugs lick burger pizza fun rape
var %temp 1
while (%temp <= $numtok(%variables,32)) {
var %thing $gettok(%variables,%temp,32)
if ($eval($+(%,%thing,%name),3) != $null) {
var %displaything $iif(%thing == fun,times amazed,$iif($v1 != 1,$iif($right(%thing,1) == s,%thing,%thing $+ s),$iif($right(%thing,1) == s,$left(%thing,-1),%thing)))
var %output $addtok(%output,$v1 %displaything,124)
}
inc %temp
}
msg $chan Stats for %name $+ : $replace(%output,$chr(124),$+($chr(32),$chr(124),$chr(32)))
}