mIRC Homepage
Posted By: krisd help !!! - 01/09/05 08:37 AM
any help is appreciated.

e.g. <nick> dog chased cat.CAT-cat but lost it

here's the remote code for on text trigger

on *:text:*dog*cat*:#pets:{

on above i want to strip text cat.CAT-cat and put it in a variable "animal" to call it in the command using variable "animal".

how do i do that

thanks
Posted By: UOnur Re: help !!! - 01/09/05 09:44 AM
My eng. is very bad,i don't understand you, but i hope this code is right code confused :tongue:

Code:
on ^*:text:*:#pets:echo #pets $+(&lt;,$nick,&gt;) $animal($1-) | haltdef
alias animal {
  var %i = $gettok(%animals,0,44),%m = $strip($1-)
  while (0 &lt; %i) {
    if ($istok(%m,$gettok(%animals,%i,44),) set %m $replace(%m,$gettok(%animals,%i,44),Animal!)
   dec %i
  }
  return %m
}
alias ani.add {
 var %k = %animals
 set %animals $addtok(%k,$1,44)
}
alias ani.del {
  var %k = %animals
  set %animals $remtok(%k,$1,44)
}


to add: /ani.add "animal" (e.g: /ani.add cat )
to del: /anidel "animal" (e.g: /ani.del dog )
Posted By: krisd Re: help !!! - 01/09/05 03:42 PM
thanks for helping much appreciated.

what i want is

<nick> where is cat.dog.buffalo says krisd
<nick> where is mouse.pig.snake says krisd
<nick> where is horse.cow.elephant says krisd

now on text "where" i want to assign the word before "says" to a variable "animal" and use %animal..

words before "says" are in this case
1 cat.dog.buffalo
2.mouse.pig.snake
3. horse.cow.elephant

it could be any word before "says"
thank you.
Posted By: UOnur Re: help !!! - 01/09/05 05:10 PM
is this?
Code:
on *:text:*says*:*:var %k %animals | set %animals $addtok(%k($gettok($1-,$calc($findtok($1-,says,1,32) - 1),32),32)
Posted By: Riamus2 Re: help !!! - 01/09/05 06:28 PM
Try this:

Code:
on *:text:where *:*: {
  if ($istok($1-,says,32)) {
    set %animal $gettok($1-,$calc($findtok($1-,says,32) - 1),32)
  }
}


That will store whatever "word" (anything separated by spaces is a word in this case) is before "says" into %animal. It will set the variable as long as the first word is "where" and if "says" is a word in the sentence.

If you need help doing something with multiple animals, like you showed, after the variable is set, just ask.
Posted By: krisd Re: help !!! - 03/09/05 01:28 AM
thank you works very nicely

but when i use this format

<nick> where is buffalo.dog.cat/cat.dog.buffalo says krisd

it returns the complete string buffalo.dog/cat.dog.buffalo

i want to be able to get the 2nd one i.e. cat.dog.buffalo after /

Also how to get one word after says to put in variable

%seeker

Thank you again
Posted By: UOnur Re: help !!! - 03/09/05 11:03 AM
you can use $gettok() ...

$gettok(buffalo.dog/cat.dog.buffalo,2,47) returns cat.dog.buffalo
Posted By: krisd Re: help !!! - 03/09/05 12:24 PM
need to get it dynamicly like Riamus2 above.

his code works great.

just need the above to complete

Thanks
Posted By: UOnur Re: help !!! - 03/09/05 12:40 PM
Code:
on *:text:where *:*: {
  if ($istok($1-,says,32)) {
    set %animal $gettok($gettok($1-,$calc($findtok($1-,says,32) - 1),32),2,47)
  }
}
Posted By: Riamus2 Re: help !!! - 06/09/05 12:19 AM
And, to get your word after "says":

Code:
on *:text:where *:*: {
  if ($istok($1-,says,32)) {
    set %animal $gettok($gettok($1-,$calc($findtok($1-,says,32) - 1),32),2,47)
    set %seeker $gettok($1-,$calc($findtok($1-,says,32) + 1),32)
  }
}
© mIRC Discussion Forums