ItsMods

Full Version: If with 2 conditions?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
how is the command to execute a part of an Program only if 2 conditions are true?
My idea was
Code:
if( level.var1 == 1 and level.var2 == 1 )
{
self iprintlnbold("TEST OK!!!");
}

The Error-Massage (from GScyntax) is:
Code:
358: Error 1: Parser: ) expected, Identifier found instead
In Black ops the Error-Massage is:
Code:
Server Script Compile Error
Bad Syntax

do you know, how it works?
Code:
if( level.var1 == 1 && level.var2 == 1 )
{
self iprintlnbold("TEST OK!!!");
}

change 'and' to '&&'
(10-28-2011, 18:52)Se7en Wrote: [ -> ]
Code:
if( level.var1 == 1 && level.var2 == 1 )
{
self iprintlnbold("TEST OK!!!");
}

change 'and' to '&&'

Thank you Big Grin
Code:
No syntax Errors detected
&&
||
You could take a look at this tutorial: http://wiki.modsrepository.com/index.php...troduction

It helped me a bit when I was new Tongue
But its COD 4 ?
(10-28-2011, 19:05)gumpo03 Wrote: [ -> ]But its COD 4 ?

It's the same scripting language, there's a few differences, but just few big changes such as the "foreach" function doesn't exist in BO anymore.
(10-28-2011, 19:07)Rendflex Wrote: [ -> ]
(10-28-2011, 19:05)gumpo03 Wrote: [ -> ]But its COD 4 ?

It's the same scripting language, there's a few differences, but just few big changes such as the "foreach" function doesn't exist in BO anymore.

foreach also didn't exist in cod4 so that's not problem Smile
(10-28-2011, 18:56)AZUMIKKEL Wrote: [ -> ]&&
||

|| = or,
he shouldn't use that
Some engines/languages also use &| which means and/or, which is kind of confusing.

Because in those languages, if you use

Code:
if(A == 2 && B == 4)
return true;

It would only go through if both of them are correct (like in COD)

but
Code:
if(A == 2 || B == 4)

would only go through if only ONE of them are correct.




Of course, this is irrelevant to COD, but the more you know.