This piece of code is meant to create a variable when a person joins a channel. Then it is supposed to increase that variable every second that a person remains in the channel. Then it should check to see if that variable reaches 15, which would mean the person has remained in the channel for 15 seconds. If true, it should do a conglomerate of different actions. But that's where the code stops working. The 15-second code is never triggered and I don't know why.
on *:JOIN:*: {
inc -c %timeinchan. $+ $nick
if (%timeinchan. $+ $nick == 15) {
set %tempstats. $+ $nick $read(scores.fil, nr, $lower($nick))
set %temppoints. $+ $nick $gettok(%tempstats. $+ $nick,2,59)
set %newpoints. $+ $nick $calc(%temppoints. $+ $nick + 5)
set %newstats $replace(%tempstats. $+ $nick, %temppoints $+ $nick, %newpoints. $+ $nick)
write -s $+ $nick scorestest.fil %newstats
msg $chan $Nick has been awarded 5 points for staying in the channel for 15 seconds. }
}
Today, I thought of using a while loop as a possible solution. Something like this:
on *:JOIN:*: {
while ($nick ison $chan) && ($nick != $me) {
inc -c %timeinchan. $+ $nick
if (%timeinchan. $+ $nick == 15) {
set %tempstats. $+ $nick $read(scores.fil, nr, $lower($nick))
set %temppoints. $+ $nick $gettok(%tempstats. $+ $nick,2,59)
set %newpoints. $+ $nick $calc(%temppoints. $+ $nick + 5)
set %newstats $replace(%tempstats. $+ $nick, %temppoints $+ $nick, %newpoints. $+ $nick)
write -s $+ $nick scorestest.fil %newstats
msg $chan $Nick has been awarded 5 points for staying in the channel for 15 seconds. }
}
But this doesn't work either. In fact, once someone joins a channel, the script makes mIRC stall, freeze and then crash.
So...
Any suggestions?