mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#98744 - 26/09/04 02:52 PM !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98745 - 26/09/04 03:10 PM Re: !request script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#98746 - 26/09/04 03:12 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98747 - 26/09/04 03:19 PM Re: !request script
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
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?


Edited by Zyzzyx26 (26/09/04 03:22 PM)
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#98748 - 26/09/04 03:20 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98749 - 26/09/04 03:24 PM Re: !request script
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
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

Top
#98750 - 26/09/04 03:27 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98751 - 26/09/04 03:28 PM Re: !request script
LocutusofBorg Offline
Hoopy frood

Registered: 23/03/03
Posts: 1271
Loc: Sunnydale, CA
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

Top
#98752 - 26/09/04 03:35 PM Re: !request script
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
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.


Edited by Zyzzyx26 (26/09/04 03:38 PM)
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#98753 - 26/09/04 03:35 PM Re: !request script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#98754 - 26/09/04 03:41 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
Workes fine smile

Thanks guys
_________________________
if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX

Top
#98755 - 26/09/04 03:42 PM Re: !request script
LocutusofBorg Offline
Hoopy frood

Registered: 23/03/03
Posts: 1271
Loc: Sunnydale, CA
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

Top
#98756 - 26/09/04 03:43 PM Re: !request script
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
That is very true, I forgot :P
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#98757 - 26/09/04 04:00 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98758 - 26/09/04 04:05 PM Re: !request script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#98759 - 26/09/04 04:11 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98760 - 26/09/04 04:29 PM Re: !request script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#98761 - 26/09/04 04:37 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
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

Top
#98762 - 26/09/04 04:46 PM Re: !request script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#98763 - 26/09/04 05:57 PM Re: !request script
NoPleX Offline
Vogon poet

Registered: 29/05/04
Posts: 132
Loc: Hirtshals Denmark
But you said before that i needed to change some?
_________________________
if ($me != geek) { $life is $false }
else { $life is $true }
NoPleX

Top
Page 1 of 2 1 2 >