mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#98744 26/09/04 01:52 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Can anyone tell me what i did wrong?
Code:
on *:text:!request*:#channel:{
  if ($2 == $me) {
    join $3
    if ($calc($nick($chan,0)) < 5) {
      .timer 1 3 msg $nick Request failed. You do not have the required amount of users in channel.
      .timer 1 4 part $3
    }
    elseif ($calc($nick($chan,0)) >= 5) {
      .timer 1 3msg $nick Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
    }
  }
}


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98745 26/09/04 02:10 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I dont know whats the problem.. but i spoted one error..

timer 1 3msg <<-- that wont work..

add a space.. timer 1 3 .. and a tip, use a . infront of the time, then you dont need to see it start and stop every time..

.timer 1 3


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98746 26/09/04 02:12 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Haha blush my bad.. well if the users on the chan is 5 or above it still says "Request failed. You do not have the required amount of users in channel." And parts the channel? confused

btw. There is . infront of timer wink


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98747 26/09/04 02:19 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Why are you using $calc? $nick($chan,0) already gives you the amount of people inside $chan.

[i]Edit: ($nick($chan,0) < 5) --> what channel is this one you want to get the number of users from? The !request channel ($3) or the channel where the !request text occurred?

Last edited by Zyzzyx26; 26/09/04 02:22 PM.

"All we are saying is give peace a chance" -- John Lennon
#98748 26/09/04 02:20 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
okay then what is $calc used for? I need it to check the amount of users on the channel it joins


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98749 26/09/04 02:24 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
I've edit the post, please check it out wink

$calc is used to make mathematics calculations. $calc(2 + 3) = 5; $calc(3^2) = 9 and so on.. You don't need $calc in the $nick() identifier.

Zyzzyx smile


"All we are saying is give peace a chance" -- John Lennon
#98750 26/09/04 02:27 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
The channel i need to count from is the one it joins $3 so is it just

($nick($chan,$3) < 5) then?


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98751 26/09/04 02:28 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Most likely you think the code does something when in fact you missed a step or so. What exactly do you want the code
to do?

Right now, it does the following:
If anyone but you (why would you allow anyone to do that anyway - remember you cannot trigger your own on TEXT events!)
types !request yournick #channelname, the code first checks if yournick matches your current nick. If so, it will join
#channelname (personally I'd add a check to see if $3 is a valid channel name). Then it will check the amount of users in the
channel the text was typed in (NOT the channel you just joined), and if the number is smaller than 5, it will prompt an error
(not 100% sure this will actually work, since there is a $calc identifier used that doesn't actually calculate anything, so why
is it even there). It will then also part the channel the command was typed in.
If the amount of users in the channel the command was typed in is more than 4, you will stay in the channel the command was
typed in.

Now I imagine the whole checking and so is supposed to take place in the channel you just joined. That means most your code needs to be changed, as it fails there.

Based on this assumption, you would need to change your code as follows (change the parts in blue as you see fit)

Code:
[color:green]; wait till anyone but you types !request yournick #channelname[/color]
on *:TEXT:!request*:[color:blue]#channelname[/color]: {
  [color:green]; make sure they typed yournick and a valid channelname[/color]
  [color:green]; if so - join the channel and save the requester's name[/color]
  if ($2 == $me) &amp;&amp; ($left($3,1) == $chr(35)) { join $3 | set $+(%,req,$3) $nick }
}
[color:blue] [/color]
[color:green]; after joining, wait for the /names list to complete, then check users[/color]
raw 366:*: {
  [color:green]; check usercount[/color]
  if ($nick($2,0) &lt; 5) {
    [color:green]; if there's not enough users, inform the requester[/color]
    .msg $eval($+(%,req,$2),2) [color:blue]Request failed. You do not have the required amount of users in channel.[/color]
    [color:green]; and leave[/color]
    .part $2
  }
  [color:green]; otherwise, stay[/color]
  else .msg $eval($+(%,req,$2),2) [color:blue]Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.[/color]
  [color:green]; clean up your mess when you're done ![/color]
  unset $+(%,req,$2)
}


Now this code could potentially get your bot into a lot of channels, which could cause serious problems....



DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98752 26/09/04 02:35 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Hmm. not quite. If the bot (assuming its a bot) has joined the channel between join $3 and the IF statement, then yes. But that is very unlikely, since from the /join to the IF stat. it takes miliseconds Suggestion:
Code:
on *:text:!request*:#channel: if ($2 == $me) { join $3 | set $+(%,request.,$3) $nick }
on me:*:join:#: {
 if ($eval($+(%,request.,$3),2)) {
   var %nick = $ifmatch
    if ($nick($chan,0) &lt; 5) {
      .timer 1 3 msg %nick Request failed. You do not have the required amount of users in channel.
      .timer 1 4 part $chan
    }
    elseif ($nick($chan,0) &gt;= 5) {
      .timer 1 3 msg %nick Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
    }
  unset $+(%,request.,$chan)
  }
}
The above should work. It creates a variable that, when combined with the ON Join, should have the effect you want.

Hope this helps smile
Zyzzyx.

Edit: you might also use Raw 366, as LocutusofBorg did. In this case, replace the [i]on me:*:join event for raw 366:*: and, under that same ON Join, replace all $chan for $2's.

Last edited by Zyzzyx26; 26/09/04 02:38 PM.

"All we are saying is give peace a chance" -- John Lennon
#98753 26/09/04 02:35 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
i would add some type of "ignore".. if the bot been in a channel.. and user count is to low, then put that channel as a no no for X amount of time.. else it can be abused by !request many times in a row.. wink but thats me, im maybe a bit paranoid wink


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98754 26/09/04 02:41 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Workes fine smile

Thanks guys


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98755 26/09/04 02:42 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
I'm wondering if you tested it. You MUST use the raw, as in the on JOIN event, you cannot count nicks in the channel using $nick. That doesn't become available until after the /names has been processed.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98756 26/09/04 02:43 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
That is very true, I forgot :P


"All we are saying is give peace a chance" -- John Lennon
#98757 26/09/04 03:00 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Okay now this is what i got:
Code:
on *:TEXT:!request*:#channel:{
  if ($2 == $me) &amp;&amp; ($left($3,1) == $chr(35)) {
    join $3
    set $+(%,req,$3) $nick
  }
}

raw 366:*:{
  [color:red]if ($nick !isop $2) {
    .timer 1 3 part $2
    .timer 1 5 msg $eval($+(%,req,$2),2) You are not opped on channel $2 try again when you have op.[/color]
  }
  elseif ($nick($2,0) &lt; 5) {
    .timer 1 3 .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
    .timer 1 5 .part $2
  }
  else timer 1 3 .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
  unset $+(%,req,$2)
}


I have edit the line with the red color
Now there is just one problem.
When i take the bot myself and type /j #channel it also parts and give this message:

[5:00PM] -> *You* are not opped on channel #pik try again when you have op.

And this when i use /hop:

port80c.se.quakenet.org No such nick


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98758 26/09/04 03:05 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
when you type join u do a input..

on 1:INPUT: {
if ($1 == /join) { set %var 1 }
if ($1 == /hop) { set %var 1 }
if ($1 == /part) { set %var2 }
}

raw 366:*:{
if (%var == 1) { goto end }
the rest of your code here.
:end
}

thats one way to sove it.. mabe you can find bether ones tho, play with that and i think u find a way smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98759 26/09/04 03:11 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
on me:*:INPUT:{
if ($1 == /j) || ($1 == /join) || ($1 == /hop) || ($1 == /part) {
set %var 1
}
}

raw 366:*:{
if (%var == 1) { goto end }
the rest of your code here.
:end
}


you can use that aswell


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98760 26/09/04 03:29 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
you have to change the %var somwhere too.. /part would be one place.. if it's set to 1 all the time, then the addon wont work..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98761 26/09/04 03:37 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Ca´n't you do it like this then?

Code:
on me:*:INPUT:#:{
   if ($1 == /j) { set %var 1 }
   if ($1 == /join) { set %var 2 }
   if ($1 == /hop) { set %var 3 }
   if ($1 == /part) { set %var 4 }
  }
}

raw 366:*:{
  if (%var == 1) || (%var == 2) || (%var == 3) || (%var == 4) { goto end }
rest of code here.
:end
}


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98762 26/09/04 03:46 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
shure.. but no need to have more then one value for all events..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98763 26/09/04 04:57 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
But you said before that i needed to change some?


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98764 26/09/04 04:58 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
if (%var == 1) { echo -a do this }
else echo -a do that

the %var is set to 1 .. then u halted ur script.. but if set to 2, then it shouldent halt..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98765 26/09/04 05:02 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
oh okay... Thanks smile

So now my script looks like this:

Code:
on *:TEXT:!request*:#channel:{
  if ($2 == $me) &amp;&amp; ($left($3,1) == $chr(35)) {
    join $3
    set $+(%,req,$3) $nick
  }
}

on me:*:INPUT:#:{
  if ($1 == /j) || ($1 == /join) || ($1 == /hop) {
    set %var 1
  }
  elseif ($1 == /part) {
    set %var 2
  }
}

*raw 366:*:{
  if (%var == 1) || %var == 2) { goto end }
  elseif ($nick !isop $2) {
    .timer 1 3 part $2
    .timer 1 5 msg $eval($+(%,req,$2),2) You are not opped on channel $2 try again when you have op.
  }
  elseif ($nick($2,0) &lt; 5) {
    .timer 1 3 .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
    .timer 1 5 .part $2
  }
  else timer 1 3 .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
  unset $+(%,req,$2)
  :end
}


Is there anyone there can spot errors?


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98766 26/09/04 05:29 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
why dont u just try it? then u notice if its any problem


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98767 26/09/04 05:43 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Code:
raw 366:*:{
  if (%var == 1) || %var == 2) { goto end }
  [color:red]elseif ($nick !isop $2) {
    .timer 1 3 part $2
    .timer 1 5 msg $eval($+(%,req,$2),2) You are not opped on channel $2 try again when you have op.
  }
  elseif ($nick($2,0) &lt; 5) {
    .timer 1 3 .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
    .timer 1 5 .part $2
  }
  else timer 1 3 .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
  unset $+(%,req,$2)
  :end
}[/color]



Text marked with red doesnt work.


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98768 26/09/04 05:46 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
There is no $nick in raw events.


New username: hixxy
#98769 26/09/04 05:49 PM
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
why not instead of messing around with the RAW, just do a 5 second timer on join to call an alias which uses $nick(#channelname,0)

#98770 26/09/04 05:54 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
because

a] the raw evenm works fine as it was. It does as he asked. He'll just need to modify it a bit, like in the raw event, check if the variable $+(%,req,$2) exists before doing anything else. that should take care of both the /hop and the /join problem

b] timers are notoriously unreliable in all matters that deal with joining channels, services of any kind of automated system that could be lagged, but whose response is absolutely necessary for the script. In such cases, in good scripting, one never uses a timer, but always an event triggered by the response.


Code:
on *:TEXT:!request*:#channelname: {
  if ($2 == $me) &amp;&amp; ($left($3,1) == $chr(35)) { join $3 | set $+(%,req,$3) $nick }
}
 
[color:blue] [/color]
raw 366:*: {
  [color:blue]if ($+(!%,req,$2)) halt[/color]
  [color:red]if ($eval($+(%,req,$2),2) !isop $2) {
    .msg $eval($+(%,req,$2),2) Request failed. You are not opped on channel $2 try again when you have op.
    .part $2
  }[/color]
  elseif ($nick($2,0) &lt; 5) {
    .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
    .part $2
  }
  else .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
  unset $+(%,req,$2)
}


The blue line is added to my original code to prevent the raw event from triggering if you do a /hop or manual /join or any other kind of join that was not triggered by the script. This could still malfunction if you do a join or hop while the script is processing the !request command by a user, but odds of that happening are kinda astronomical.

The part in red is added to check if the requester is an op in the channel.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98771 26/09/04 06:29 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
LocutusofBorg i am using your script. But the:
Code:
  if ($eval($+(%,req,$2),2) !isop $2) {
    .msg $eval($+(%,req,$2),2) Request failed. You are not opped on $2 try again when you have op.
    .part $2
  }
  elseif ($nick($2,0) &lt; 5) {
    .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
    .part $2
  }
  else .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
  unset $+(%,req,$2)
}


That part still seams like it wont trigger confused


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98772 26/09/04 06:47 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
I tested it before posting - it works fine. Just remember YOU cannot trigger it.

Try this tho:

Code:
on *:TEXT:!request*:#channelname: {
  if ($2 == $me) &amp;&amp; ($left($3,1) == $chr(35)) { join $3 | set $+(%,req,$3) $nick }
}
 [color:red] [/color]
raw 366:*: {
  if ($+(%,req,$2)) {
    if ($eval($+(%,req,$2),2) !isop $2) {
      .msg $eval($+(%,req,$2),2) Request failed. You are not opped on channel $2 try again when you have op.
      .part $2
    }
    elseif ($nick($2,0) &lt; 5) {
      .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
      .part $2
    }
    else .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
    unset $+(%,req,$2)
  }
}


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98773 26/09/04 06:51 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Okay. Thats wierd crazy

i got 2 mirc installed. I go to a channel with one of them where im opped but only one user. Then i use !request <botname> #channel and then it joins but doenst part. confused


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98774 26/09/04 07:08 PM
Joined: May 2004
Posts: 132
N
NoPleX Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: May 2004
Posts: 132
Okay now it works. But now we have the old /hop /join /j problem back. crazy


if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX
#98775 26/09/04 07:47 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
if ($1 == /hop) %% (%var == 2) { set %var 1 }


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#98776 27/09/04 05:28 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Have someone triger the script. See if the variable still exists after awhile. it shouldn't.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Page 1 of 2 1 2

Link Copied to Clipboard