mIRC Homepage
Posted By: NoPleX !request script - 26/09/04 01:52 PM
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.
    }
  }
}
Posted By: sparta Re: !request script - 26/09/04 02:10 PM
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
Posted By: NoPleX Re: !request script - 26/09/04 02:12 PM
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
Posted By: Zyzzyx26 Re: !request script - 26/09/04 02:19 PM
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?
Posted By: NoPleX Re: !request script - 26/09/04 02:20 PM
okay then what is $calc used for? I need it to check the amount of users on the channel it joins
Posted By: Zyzzyx26 Re: !request script - 26/09/04 02:24 PM
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
Posted By: NoPleX Re: !request script - 26/09/04 02:27 PM
The channel i need to count from is the one it joins $3 so is it just

($nick($chan,$3) < 5) then?
Posted By: LocutusofBorg Re: !request script - 26/09/04 02:28 PM
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....

Posted By: Zyzzyx26 Re: !request script - 26/09/04 02:35 PM
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.
Posted By: sparta Re: !request script - 26/09/04 02:35 PM
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
Posted By: NoPleX Re: !request script - 26/09/04 02:41 PM
Workes fine smile

Thanks guys
Posted By: LocutusofBorg Re: !request script - 26/09/04 02:42 PM
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.
Posted By: Zyzzyx26 Re: !request script - 26/09/04 02:43 PM
That is very true, I forgot :P
Posted By: NoPleX Re: !request script - 26/09/04 03:00 PM
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
Posted By: sparta Re: !request script - 26/09/04 03:05 PM
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
Posted By: NoPleX Re: !request script - 26/09/04 03:11 PM
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
Posted By: sparta Re: !request script - 26/09/04 03:29 PM
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..
Posted By: NoPleX Re: !request script - 26/09/04 03:37 PM
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
}
Posted By: sparta Re: !request script - 26/09/04 03:46 PM
shure.. but no need to have more then one value for all events..
Posted By: NoPleX Re: !request script - 26/09/04 04:57 PM
But you said before that i needed to change some?
Posted By: sparta Re: !request script - 26/09/04 04:58 PM
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..
Posted By: NoPleX Re: !request script - 26/09/04 05:02 PM
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?
Posted By: sparta Re: !request script - 26/09/04 05:29 PM
why dont u just try it? then u notice if its any problem
Posted By: NoPleX Re: !request script - 26/09/04 05:43 PM
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.
Posted By: tidy_trax Re: !request script - 26/09/04 05:46 PM
There is no $nick in raw events.
Posted By: Danthemandoo Re: !request script - 26/09/04 05:49 PM
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)
Posted By: LocutusofBorg Re: !request script - 26/09/04 05:54 PM
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.
Posted By: NoPleX Re: !request script - 26/09/04 06:29 PM
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
Posted By: LocutusofBorg Re: !request script - 26/09/04 06:47 PM
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)
  }
}
Posted By: NoPleX Re: !request script - 26/09/04 06:51 PM
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
Posted By: NoPleX Re: !request script - 26/09/04 07:08 PM
Okay now it works. But now we have the old /hop /join /j problem back. crazy
Posted By: sparta Re: !request script - 26/09/04 07:47 PM
if ($1 == /hop) %% (%var == 2) { set %var 1 }
Posted By: LocutusofBorg Re: !request script - 27/09/04 05:28 AM
Have someone triger the script. See if the variable still exists after awhile. it shouldn't.
© mIRC Discussion Forums