mIRC Homepage
Posted By: AmBassdor Echo variable, counting viewers - 06/04/15 09:08 PM
Hello!

I want to greet random guest but to avoid spam I wanna greet every x join. How to make this?

And how to print some global variable and /inc -rease it?
Becouse

set %joined 0
on *:JOIN:#: { /inc %joins }
on *:JOIN:#: { /splay d:/a.wav } (just for tests)
on *:JOIN:#: { .msg $chan hello $nick u are %joins on channel}

do not work as I thought
Posted By: Newbie Re: Echo variable, counting viewers - 06/04/15 10:56 PM
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.

Code:

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.
© mIRC Discussion Forums