I don't know what you mean by increasing a global variable. Do you mean increasing it once you get a viewer but decreasing it once they leave? Or do you want a total view counter for the day? Or a total view counter of all times?
I'll write this script assuming you want it a total view counter for that day.
on *:JOIN:#: {
if (!%views) {
hadd -m Viewers $nick 1
msg # Hello $nick you are viewer number $hget(Viewers,0) on this channel.
}
if (%views > 0) {
if ($hget(Viewers,$nick) == 1) {
return
}
else {
hadd Viewers $nick 1
msg # Hello $nick you are viewer number $hget(Viewers,0) on this channel.
}
}
}
Haven't tested this out so hopefully it works first try. When a person joins they are added to a hash table, which gets deleted when you close the program. Please tell me if it works because I can't test it out at the moment.