mIRC Homepage
Posted By: Tzar469 Help with $1-2 - 20/02/08 05:27 AM
I'm making a kill-count script for a deathmatch game. This game is relayed from the server to a channel. I want the triggers to work if it is in the first or second position because I want this to able to be triggered by the relay bot so it can send the data back to the server. I'm puzzled as to why the following only partially works:

Code:
on *:text:!*:#:{
  if (!stats isin $strip($1-2)) {
    if ($2 == !stats) var %nick = $iif($3,$3,$1), %ingame = 1
    elseif ($1 == !stats) var %nick $iif($2,$2,$nick)
    dmsg %nick has killed $calc($hget(playerkills,%nick)) people without dying. 
  }
  elseif (!deaths isin $strip($1-2)) {
    if ($1 == !deaths) var %nick $iif($2,$2,$nick)
    elseif ($2 == !deaths) var %nick $iif($3,$3,$1), %ingame 1
    dmsg %nick has died $calc($hget(playerdeaths,%nick)) times.
  }
}
alias dmsg { msg $chan $iif(%ingame,!fds msg) $1- )


The problem is that the script triggers on !stats and !deaths but not if either of them is $2. It also don't work if the line is colored. How do I fix this?
Posted By: Damsulegna Re: Help with $1-2 - 20/02/08 09:23 AM
Code:
on *:text:!*:#:{


this part is looking for ! in 1st chat.

perhaps using
Code:
on *:text:*:#:{


might help
Posted By: Miguel_A Re: Help with $1-2 - 20/02/08 02:29 PM
Hi

You had two errors.
When working with an alias outsite a event you need to send all the information to that alias.

In this case you have not send the channel. I have created tha variable %Chan and have added to the on text event and addes %Chan to the alias dmsg.

The other small thing was that you have close your alias with a ) and not with the }.

Th rest off the code sounds good... I think it should work fine.

Code:
on *:text:*:#:{
  set %Chan $chan
  if (!stats isin $strip($1-2)) {
    if ($2 == !stats) { 
      var %nick = $iif($3,$3,$1), %ingame = 1
    }
    elseif ($1 == !stats) { 
      var %nick $iif($2,$2,$nick)
    }
    dmsg %nick has killed $calc($hget(playerkills,%nick)) people without dying. 
  }
  elseif (!deaths isin $strip($1-2)) {
    if ($1 == !deaths) { 
      var %nick $iif($2,$2,$nick)
    }
    elseif ($2 == !deaths) { 
      var %nick $iif($3,$3,$1), %ingame 1
    }
    dmsg %nick has died $calc($hget(playerdeaths,%nick)) times.
  }
}

alias dmsg { 
  msg %Chan $iif(%ingame,!fds msg) $1-
  unset %Chan
}
Posted By: qwerty Re: Help with $1-2 - 20/02/08 03:10 PM
Quote:
You had two errors.
When working with an alias outsite a event you need to send all the information to that alias.
Not true. Remote identifiers ($nick, $chan, $address etc) are accessible to aliases called from within the event (and to any child aliases).
Posted By: Miguel_A Re: Help with $1-2 - 20/02/08 04:06 PM
Humm.

Thanks didnĀ“t know that. Next time i will not make the ame mistake.
Posted By: Tzar469 Re: Help with $1-2 - 21/02/08 01:03 AM
Ah, how stupid of me to make that error

Thanks for the help everyone! smile

Edit: I now have the following piece of code:

Code:
alias finddead {
  if ($regex($1-, /(killed \w+)/i)) {
    var %died $remtok($regml(1),killed,1,32)
  }
  return %died
}


It is supposed to return the word after the word "killed" but it doesn't work if the word contains symbols. How do I fix that?
Posted By: Wims Re: Help with $1-2 - 21/02/08 06:47 PM
use :
Code:
alias finddead noop $regex($1-,/killed (.\S+)/i) | return $regml(1)

smile
Posted By: The_JD Re: Help with $1-2 - 21/02/08 09:16 PM
Try escaping the regex with $replacex. The charachters that need escaping are found @ regular-expressions.info smile
© mIRC Discussion Forums