mIRC Homepage
Posted By: RiMaJoy respond script - 18/04/10 07:16 AM
I use this in my respond script:
Code:
var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $+(%nicklijst,$chr(32),$nick($chan,%nick1))
      } 
      inc %nick1 
    } 


I can't get it so that if %nicklijst is more then 1 name those names are not sepperated by only a space but also with a &($chr38).
Some help would be nice.

another problem....
I'm not good at $regex so here is some code i use:
Code:
 if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si))

Somehow i need to use the name of the bot where the script is located in order to get it to work.
I want this to work too without use the bots name.

Greetings.......
Posted By: DJ_Sol Re: respond script - 18/04/10 08:49 AM
Do you want to use something like $addtok?

var %nicklijst = $addtok(%nicklijst,$+($chr(38),$nick($chan,%nick1)),32)
Posted By: RiMaJoy Re: respond script - 19/04/10 06:55 PM
not working it adds a & on the first name aswell
Posted By: Horstl Re: respond script - 19/04/10 09:50 PM
Why not replace the separating char $chr(32) with a "$chr(38)-and-space" after the loop
Code:
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $addtok(%nicklijst,$v1,32)
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(38),$chr(32)))

Quote:
Somehow i need to use the name of the bot where the script is located in order to get it to work.
I want this to work too without use the bots name.
I don't get this part. Can you please provide an example and show the piece of code that if-condition is a part of?
Posted By: chacha Re: respond script - 19/04/10 10:33 PM
using "isin" isnt a good idea
better to use $istok

bcz if your nick is bam and another is bamboo when u use isin that will confiuse the two nicks
Posted By: RiMaJoy Re: respond script - 20/04/10 03:40 AM
That does the job.
thanks
Posted By: RiMaJoy Re: respond script - 21/04/10 08:05 PM
About the $regex Horstl:

I wanted the bot to respond different if i added me or I in the command like so:
Botname give nick1 and nick 2 a beer and one for me too.

At first I started the code like so because i wanted to be a barbot:
Code:
if (Botname == $strip($1)) { bla bla bla


Now i made it more like a respondbot aswell and so some of the code starts like this as well:
Code:
if (hello isin $strip($1-)) {  bla bla bla 


In the original code the botname was the trigger.
I dropped that part in the new code.
With the new code if i use this command:
Give nick1 and nick 2 a beer and one for me too.
It doesnt respond with the correct respond.
But if i change the command too:
Give nick1 and nick 2 a beer Botname and one for me too.
Then it responds correctly.
It doesn't matter where i put the botname.
My guess is the $regex is doing that.
Here is the code that i use original in full:
Code:
On 1:text:*beer*:#:{
  if (mIRCStats == $strip($1)) { 
    var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($2-)) {  
        var %nicklijst = $addtok(%nicklijst,$v1,32)
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(32),$chr(38),$chr(32)))
    if (%nicklijst) {
      if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si)) { 
        .timer 1 2 $read($scriptdir\drinken\beerme.txt,t) 
      }
      else {
        .timer 1 2 $read($scriptdir\drinken\beerlist.txt,t) 
      }
    }
    else { 
      .timer 1 1 $read($scriptdir\drinken\beer.txt,t) 
    }
  }
}


Here is the code changed a bit:
Code:
On 1:text:*:#:{
  if (Are you happy isin $strip($1-)) {   
    var %nicknum = $nick($chan,0) 
    var %nick1 = 1 
    while (%nicknum >= %nick1) { 
      if ($nick($chan,%nick1) isin $strip($1-)) {  
        var %nicklijst = var %nicklijst = $addtok(%nicklijst,$v1,32) 
      } 
      inc %nick1 
    }
    var %nicklijst = $replace(%nicklijst,$chr(32),$+($chr(32),$chr(38),$chr(32))) 
    if (%nicklijst) {
      if ($regex($1-,/(?<= |^)(?:i|me)(?= |$)/Si)) { 
        .timer 1 2 $read($scriptdir\acts\ruhappyme.txt,t) 
      }
        else {
          .timer 1 2 $read($scriptdir\acts\ruhappylist.txt,t) 
        }
      }
    else { 
      .timer 1 1 $read($scriptdir\acts\ruhappy.txt,t) 
    }
  }
}


Only thing changed is the first if.
It works in the original code because the botname is the trigger.

Hope this helps you help me.
Posted By: Horstl Re: respond script - 22/04/10 09:32 AM
Atm, the line of text has to contain any valid nickname (not necessarily the nick of the bot) because it checks for "if (%nicklijst)" first, and only if %nicklijst contains anything (any nicks) it does the me/I check and proceeds to "ruhappyme.txt" or "ruhappylist.txt" respectively.
Without at least one nickname, it will always read "ruhappy.txt". Do you want it to work for "Are you happy with me" as well (reading ruhappyme.txt)?
Posted By: RiMaJoy Re: respond script - 22/04/10 06:23 PM
thanks Horstl

I'll move the me/i check part at the end as well.
That way it will check both ways.
© mIRC Discussion Forums