mIRC Homepage
Posted By: AaronL no reaction on space - enter - 23/10/05 02:46 PM
Hi all.
Hope someone can help me out here

When a player (trivia) geives a space and hits enter the question is answered. Since that isn't what i want, the bot most { return } on space - enter.

this is the code sofar.
Code:
 
alias -l cryptos.control {
  if ($strip($2-) == %cryptos.answer) || ($strip($2-) == %cryptos.goodaswell) {
    if ($chr(124) isin $nick) { return }
    write-score
 


i try'd this
Code:
if ($strip($2-) == $chr(160)) || ($strip($2-) == $chr(32)) { return }

But that dowsn't work.
What do i wrong, or what can i do to prevent space - enter.

thnxs in advange
Aaron
Posted By: FiberOPtics Re: no reaction on space - enter - 23/10/05 02:49 PM
When an on text even with matchtext * triggers on space - ctrl+enter, $0 will be 0 so you can check for that.

Btw no one can send a space with "space + enter", it does nothing. It needs to be ctrl+enter.

If they send a hard space (0160 on some fonts), then you simply do a check for if ($1- == $chr(160))

You could combine both in a regex like:

on $*:text:/[^ \240]/:#channel: ...

or

on $*:text:/(?!\240)\S/:#channel: ...

The above codes allows for $chr(160) only if there is atleast 1 other character that is neither a space or $chr(160). I assume this is what you want.
Posted By: AaronL Re: no reaction on space - enter - 23/10/05 03:13 PM
thnxs FiberOptics.

they use space CTRL+enter. Problem is that i don't know how to make the bot react on that. so help is appriciated smile

greetz
Aaron
Posted By: FiberOPtics Re: no reaction on space - enter - 23/10/05 03:16 PM
I already gave you the code, look carefully.

If you use that as on text event, you don't even need to worry for checking, as i't won't trigger the event if they message either a "ctrl+enter - space" or "$chr(160)" That is, still in the assumption that those two are allowed if there is atleast 1 character that is neither, which you still haven't confirmed.
Posted By: AaronL Re: no reaction on space - enter - 23/10/05 03:34 PM
sorry my fault. didn't look well enough. now i have this..

Code:
on $*:text:/[^ \240]/:#bank: { if (%loopspel != ON) { if ($strip($1-) == !start) || ($strip($1-) == !trivia) { cryptos.on } } }


still doesn't work

greetz
Aaron.
Posted By: FiberOPtics Re: no reaction on space - enter - 23/10/05 03:40 PM
Define "it still doesn't work".

It has nothing to do with the regex if your code doesn't work, the error is somewhere on your side, as that regex works fine. Btw, you do know that it won't have any effect if you have an on text event in the same script file above it with matchtext *, right? As that one will consume all on text.

Your original question has been answered, we can't help you further with your script, as it's something specific on your side.

Note that the regex matchtext was only added in mIRC 6.1, and that there was a fix for it in 6.15
Posted By: Sigh Re: no reaction on space - enter - 23/10/05 03:41 PM
Try using:

Code:
on $*:text:/^(?![ \240]$)/:#bank:{


Edit: actually the others should also do, this one just checks if ($1- = $chr(32)) || ($1- = $chr(160))
Posted By: FiberOPtics Re: no reaction on space - enter - 23/10/05 03:47 PM
Indeed, it has nothing to do with the regex. If the other ones didn't work, neither will that one. It's a problem on his side which we can't help with.
Posted By: DaveC Re: no reaction on space - enter - 23/10/05 07:54 PM
You migth look here

if ($strip($2-) == %cryptos.answer) || ($strip($2-) == %cryptos.goodaswell) {

$2- more than likely is nothing and %cryptos.goodaswell more than likely has no value either, so you may be getting a $null == $null true condition.
Posted By: AaronL Re: no reaction on space - enter - 23/10/05 08:41 PM
i'v solved it with
Code:
if ($gettok($2-,1,160) == $true) { return }

and that works fine.

Everyone thanks for the suggestions and help.

Greetz
Aaron
Posted By: DaveC Re: no reaction on space - enter - 24/10/05 08:57 AM
I shudder a bit at that, I just have no idea what might have been passed as $2- that that worked.

However if it does it does smile
© mIRC Discussion Forums