mIRC Home    About    Download    Register    News    Help

Print Thread
#101711 27/10/04 07:55 AM
Joined: Oct 2004
Posts: 3
S
spigety Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Oct 2004
Posts: 3
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

#101712 27/10/04 11:35 AM
Joined: Mar 2004
Posts: 175
Vogon poet
Offline
Vogon poet
Joined: Mar 2004
Posts: 175
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 &&.


- Relinsquish
#101713 27/10/04 11:29 PM
Joined: Oct 2004
Posts: 3
B
Self-satisified door
Offline
Self-satisified door
B
Joined: Oct 2004
Posts: 3
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

#101714 28/10/04 04:45 AM
Joined: Oct 2004
Posts: 3
S
spigety Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Oct 2004
Posts: 3
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

#101715 28/10/04 06:55 AM
Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
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


Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
#101716 28/10/04 11:53 AM
Joined: Oct 2004
Posts: 3
S
spigety Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Oct 2004
Posts: 3
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.


Link Copied to Clipboard