mIRC Homepage
Posted By: LairSpirit $nick(#channel,0) ?? - 19/02/04 01:49 AM
Im relatively new to scripting and wanted to create a script that returned the most amount of users online in a particular channel and record the time of it. I think the following is logically correct but I dont think it is evaluating "$nick(#channel,0)" because I have tried echoing it and it wouldn't work then either. What I have is:

/highset if($nick(#channel,0) > %highestPeeps) {/set %highestPeeps $nick(#channel,0) | /set %highestPeepTime $fulldate}

I initiated %highestPeeps with 1. Im using mIRC version 6.1.
I moved everything out of remote into alias thinkin it might work better.

Any ideas?

Posted By: Cheech Re: $nick(#channel,0) ?? - 19/02/04 03:08 AM
Code:
  
alias highset {
  if ($nick($active,0) > %highestPeeps) {
    /set %highestPeeps $nick($active,0) | /set %highestPeepTime $fulldate
  }


%highestPeeps 30
%highestPeepTime Wed Feb 18 21:04:52 2004

$active refers to the channel inwhich you type /highset
when adding a /something to a remote file you need to code it as
alias whatever { which is = to /whatever
if you want you can add a variable to return the channel which you were in such as
set %highpeepschannel $active
hope that helps smile
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 19/02/04 03:40 AM
What you posted made no visible difference frown

Thanks for replying with a suggestion. Its not setting the %highestPeepTime variable either.

I'm sure it's something simple...
Posted By: MIMP Re: $nick(#channel,0) ?? - 19/02/04 03:47 AM
Quote:
/highset if($nick(#channel,0) > %highestPeeps) {/set %highestPeeps $nick(#channel,0) | /set %highestPeepTime $fulldate}


I think spacing is your issue:

/highset if ($nick(#channel,0) > %hightestPeeps) { set %highestPeeps $nick(#channel,0) | set %highestPeepsTime $fulldate }

You need to have spaces after {'s and |'s and before }'s.
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 19/02/04 07:51 AM
Spacing helped me out with displaying what I had initialised the %highestPeepTime, but it still isnt setting the new values on join.

I've tried this:
/nicks echo $nick(#channel,0)

and nothing happens. I think this is where my problem is, but according to help, I've written it correctly.

Thanks for the heads up on where to put spaces smile
Posted By: Iori Re: $nick(#channel,0) ?? - 19/02/04 07:59 AM
Code:
on *:join:[color:blue]#channel[/color]:{
  if ($nick(#,0) > %highestPeeps) { set %highestPeeps $nick(#,0) | set %highestPeepTime $fulldate }  
}
Change #channel to whatever channel you want this for.
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 19/02/04 08:52 AM
Thanks, looked like it was going to work but it didnt frown

Ive checked my variables spelling, gone through it. I can call the varialbles in another alias and have the messaged to channel, I just cant get the initial if statement evaluated and the variables set.

Could it be the server preventing that particular command?

Does $nick(#channel,0) work for anyone else?
Posted By: Iori Re: $nick(#channel,0) ?? - 19/02/04 09:05 AM
The #channel in $nick(#channel,0) needs to be the real #channelname or "#" ("$chan") if it is called from an event/ or command.
Type in channel window //echo -a $nick(#,0) <- needs two //'s to evaluate the $nick() identifier.
Also //set -s %HighestPeeps $nick(#,0) <- the -s switch will 'show' you if and what the var was set to.

If the %highestPeeps var isn't set, you can set it with /set %highestPeeps 0
Here also is (slightly) different code which has a check fo rth evar not being present
Code:
on *:join:[color:blue]#channel[/color]:{
  if ($nick(#,0) &gt; %highestPeeps) || (!%highestPeeps) { set %highestPeeps $nick(#,0) | set %highestPeepTime $fulldate }  
}
And again the #channel should be changed to whatever channel you want this for.
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 19/02/04 12:39 PM
I just don't understand. If I type
//echo -a $nick(#,0)
it works. If I type
//set -s %HighestPeeps $nick(#,0)
it works. If I dont use the -a and -s switches (having specific a channel where # is) it doesnt work.
I've done what you said and used my channel, where you told me to. Ill paste exactly what I have in my script folder so you can point out what Im doing wrong.
Code:
 on *:join:#whitetower:{ if ($nick(#,0) &gt; %highestPeeps) || (!%highestPeeps) { set %highestPeeps $nick(#,0) | set %highestPeepTime $fulldate } }
 

Spaces dont copy across too well, I have it spaced as directed earlier too. It's just not assigning the new variables on join frown
If Im truly that inept Ill put this on a back burner and move on with something else and stop wasting your time.
Posted By: TonyTheTiger Re: $nick(#channel,0) ?? - 19/02/04 12:51 PM
Quote:
If I dont use the -a and -s switches (having specific a channel where # is) it doesnt work.


That's because if the first parameter after the /echo command
is a number, it's seen as specifying a color.

So if there are four users on #mIRC and you do this ...
//echo $nick(#mIRC,0) users are on #mIRC right now!!
.. it will turn out like this ..
users are on #mIRC right now!!
Posted By: Iori Re: $nick(#channel,0) ?? - 19/02/04 09:47 PM
Try typing /remote on and see if the join works then.
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 20/02/04 01:29 AM
Nope frown

Nothing I do or change seems to make a different. Thanks for your help if its not a bug then it's me.

If I come back to it and succeed Ill make sure to post the result here for everyone else as frustrated as me.
Posted By: MIMP Re: $nick(#channel,0) ?? - 20/02/04 02:04 AM
I tested the following code in #mIRC with version 6.1 and it seems to work fine. It's the same code you posted before just moved to more than one line. You may need to double check that you do not have another on join event interfering with this.

Code:
on *:join:#mIRC:{
  if ($nick(#,0) &gt; %highestPeeps) || (!%highestPeeps) {
    set -s %highestPeeps $nick(#,0) 
    set -s %highestPeepTime $fulldate
} }

Code:
* Set %highestPeeps to 52
-
* Set %highestPeepTime to Thu Feb 19 18:58:51 2004
-
* Set %highestPeeps to 53
-
* Set %highestPeepTime to Thu Feb 19 19:01:57 2004
-
* Set %highestPeeps to 54
-
* Set %highestPeepTime to Thu Feb 19 19:02:10 2004
Posted By: LairSpirit Re: $nick(#channel,0) ?? - 20/02/04 02:25 AM
You're a champ!! smile

The only difference I saw was the use of the -s switch with set. I don't know if thats what the whole trouble was but Im so elated it's finally working!!

Thanks everyone for helping me through this one smile
Posted By: MIMP Re: $nick(#channel,0) ?? - 20/02/04 02:32 AM
No, all -s does is shows the output when the variable is set. You can remove it, I just had it in there for debugging. Glad to hear it works. cool
Posted By: Zyzzyx26 Re: $nick(#channel,0) ?? - 21/04/04 11:48 PM
I did a search and found this threat. I have kind of the same problem.. i have this:
Code:
on me:*:JOIN:#: {
    var %i = 1
    while (%i &lt;= $nick(#,0)) {
      .msg Zyzzyx26 7- $nick(#,%i).pnick
      inc %i
    }
} 


This is for my bot.. i want that whenever it joins a channel he /msgs me telling the users on it. The code seems fine to me, but the $nick(#,0) is being set as 1, no matter how many users the channel actually has!

I tryed typing //echo $nick(#,0) and it returned the correct number of users, but when the bot joins it only returns 1.
(i've also tried the script in a new .mrc file, but nothing..)

Please help wink

Thanks,
Zyzzy. smile
Posted By: Collective Re: $nick(#channel,0) ?? - 21/04/04 11:58 PM
When on JOIN fires for you joining a channel you have not yet recieved the names list, try it on raw 366 instead.
Posted By: Zyzzyx26 Re: $nick(#channel,0) ?? - 22/04/04 09:02 PM
raw 366 or raw 353? Because i have this
Code:
raw *:*: echo 4 -s $numeric $1-
and it echos:

353 <nick> = #channel <nicks in the channel>

while the 366 returns 366 <nick> #channel End of /NAMES list

And how do i use it? smile

Thanks, Zyzzy.
Posted By: Collective Re: $nick(#channel,0) ?? - 22/04/04 10:09 PM
Raw 366 is triggered when the names list has been recieved, only when it has will $nick(#channel,0) return the correct amount of people.

Code:
raw 366:*:{
  echo -a $nick($2,0)
}


In raw 366 $2 is the channel name.
Posted By: Zyzzyx26 Re: $nick(#channel,0) ?? - 23/04/04 02:45 PM
Oic.. smile The $nick($2,0) identifier works, it returns the number of nicks in the channel.. but now i've got another little issue smirk

Neither $nick($2,%i) nor $nick(#,%i) is working on the while part:
Code:
raw 366:*:{
  var %names = $nick($2,0)
  var %i = 1
  while (%i &lt;= %names) {
    .msg Zyzzyx26 -  [color:blue]$nick(#,%i)[/color] or [color:blue]$nick($2,%i)[/color] 
    inc %i
  }
} 


Why? :P

Thanks, Zyzzy.
Posted By: Collective Re: $nick(#channel,0) ?? - 23/04/04 04:45 PM
It works fine for me:

[17:44:24] <Collective> - or Nick1
[17:44:24] <Collective> - or Nick2
[17:44:24] <Collective> - or Nick3
[17:44:24] <Collective> - or Collective
Posted By: Zyzzyx26 Re: $nick(#channel,0) ?? - 23/04/04 11:07 PM
*duh* :P I was missing some brackets when i pasted it...

Thanks for the help! laugh
Posted By: Iori Re: $nick(#channel,0) ?? - 24/04/04 10:59 AM
Just out of curiosity, why /msg the nicks to yourself?
Code:
raw 366:*:{
  var %i = 1
  while $nick($2,%i) { [color:blue]echo -a[/color] $ifmatch | inc %i }
}
Posted By: Zyzzyx26 Re: $nick(#channel,0) ?? - 24/04/04 03:30 PM
This script isnt for me, but for my bot... so when it joins it msgs me and tells the ppl in the chan smile
© mIRC Discussion Forums