FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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.
|
|
07-13-2012, 04:32 PM |
|
Omyn
Junior Member
Posts: 13
Threads: 2
Joined: Jul 2012
Reputation:
0
|
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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
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.
if(GetEntitiesCollide("stone_med01_brown_1", "ScriptArea_2") == true && GetEntitiesCollide("stone_med01_brown_2", "ScriptArea_2") == true)
|
|
07-13-2012, 06:59 PM |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Double if(GetEntitiesCollide - Problem
YYYYES i understand it now! And it also works ^_^ You guys are so brilliant
Trying is the first step to success.
|
|
07-13-2012, 07:22 PM |
|
|