mIRC Homepage
Posted By: spigety using || operators - 27/10/04 07:55 AM
hi, can someone help me with this?

Code:
  if ($nick != %fighter1) || ($nick != %fighter2) {
    /msg %chan_duel $nick $+ , a duel between %fighter1 and %fighter2 is already underway. please wait until it finishes.
    /halt
  } 


this looks pretty strange i'm sure, let me tell you what it is suppose to be doing:

i'm trying to make an rpg script where people can fighter each other, gain levels, etc. that snippet is suppose to stop a different person than the 2 already fighting from sending commands. for some reason it also stops the two that are ALREADY fighting. i have no idea why frown

if you think pasting the whole script will help let me know.
thanks
Posted By: Relinsquish Re: using || operators - 27/10/04 11:35 AM
Code:
If ($Nick != %Fighter1)  &&  ($Nick != %Fighter2) {
msg %Chan_Duel $Nick $+ , a duel between %Fighter1 and %Fighter2 is already underway. Please wait until it finishes.
halt
}

Don't use ||, use &&.
Posted By: Bobbtyisdead Re: using || operators - 27/10/04 11:29 PM
your using a double negitive, think of it this way

a number between 1 and 10 is not 5 or is not 6, that dosent help at all as it can be still 5 or 6, its allways going to be != to one of them
Posted By: spigety Re: using || operators - 28/10/04 04:45 AM
using && doesnt work either, wouldn't it have to be ||?

since the script is basically saying "if steve doesnt equal mike or steve doesnt equal john then tell steve ..."

i must be missing something frown
Posted By: Darwin_Koala Re: using || operators - 28/10/04 06:55 AM
Quote:
if ( ($nick != %fighter1) && ($nick != %fighter2) ) {
/msg %chan_duel $nick $+ , a duel between %fighter1 and %fighter2 is already underway. please wait until it finishes.
/halt }


The use of brackets may clarify .. what I am now saying is:

if NICK is not fighter 1 and if NICK is not fighter 2 then (send the message).

What you had originally was if NICK is not Fighter 1 or NICK is not fighter 2 : in this case if nick was fighter 2 then it was not fighter 1, and the command would still trigger.

I guess it helps if the result you want is written in plain language (using AND and/or OR) - it helps clarify what you want to achieve. && == AND, || == OR .

Cheers,

DK
Posted By: spigety Re: using || operators - 28/10/04 11:53 AM
thanks guys, using && finally got everything to work right.

one of the problems i had was the variables were being unset at the end of the script so they didnt even exist at the time the statement was being executed.
© mIRC Discussion Forums