Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Double if(GetEntitiesCollide - Problem [SOLVED]
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
Double if(GetEntitiesCollide - Problem [SOLVED]

Hello smart people ^^

I have a problem with my if-statement.
The error is: Expected exrpession value.

My script is:


void OnCollide_3(string &in asParent, string &in asChild, int alState)
{
if(GetEntitiesCollide("stone_med01_brown_1", "ScriptArea_2") == true) && if(GetEntitiesCollide("stone_med01_brown_2", "ScriptArea_2") == true) <-- Points to this line
{
FadeOut(0);
PlaySoundAtEntity("", "explosion_rock_large", "Player", 0.5f, false);
}
}

But what is wrong.. I can't seem to figure it out myself..

Trying is the first step to success.
(This post was last modified: 07-13-2012, 07:23 PM by FlawlessHappiness.)
07-13-2012, 04:32 PM
Find
Omyn Offline
Junior Member

Posts: 13
Threads: 2
Joined: Jul 2012
Reputation: 0
#2
RE: Double if(GetEntitiesCollide - Problem

(07-13-2012, 04:32 PM)beecake Wrote: Hello smart people ^^

I have a problem with my if-statement.
The error is: Expected exrpession value.

My script is:


void OnCollide_3(string &in asParent, string &in asChild, int alState)
{
if(GetEntitiesCollide("stone_med01_brown_1", "ScriptArea_2") == true) && if(GetEntitiesCollide("stone_med01_brown_2", "ScriptArea_2") == true) <-- Points to this line
{
FadeOut(0);
PlaySoundAtEntity("", "explosion_rock_large", "Player", 0.5f, false);
}
}

But what is wrong.. I can't seem to figure it out myself..
I'm no expert in c++ but i think for a multiple condition if statement, you only need one "if" then enclose both conditions wothin the parenthesis seperated by the &&.
07-13-2012, 06:00 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Double if(GetEntitiesCollide - Problem

You are probably right, but the error is still there

Trying is the first step to success.
07-13-2012, 06:55 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Double if(GetEntitiesCollide - Problem

(07-13-2012, 06:55 PM)beecake Wrote: You are probably right, but the error is still there

Omyn is correct. If statements don't return values, so using the logical AND operator on two if statements won't work. You're supposed to place the condition within the if statement's parenthesis. The condition being the statements that can evaluate to either true or false.

PHP Code: (Select All)
if(GetEntitiesCollide("stone_med01_brown_1""ScriptArea_2") == true
&& GetEntitiesCollide("stone_med01_brown_2""ScriptArea_2") == true

Tutorials: From Noob to Pro
07-13-2012, 06:59 PM
Website Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#5
RE: Double if(GetEntitiesCollide - Problem

Here's an example of the double if statement that Frictional Games used for the book puzzle in the archives (it's actually 3, but I removed the last one so you can compare it to yours easier). It's all one line, each part is separated by "(space)&&(space)", and the second part doesn't have the extra pair of parentheses ().
if(GetLocalVarInt("VarSecretBook_1") == 1 && GetLocalVarInt("VarSecretBook_2") == 1

Hope that helped.

I rate it 3 memes.
07-13-2012, 07:05 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Double if(GetEntitiesCollide - Problem

YYYYES i understand it now! And it also works ^_^ You guys are so brilliant Big Grin

Trying is the first step to success.
07-13-2012, 07:22 PM
Find




Users browsing this thread: 1 Guest(s)