SA-MP Forums Archive
Order in "if" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Order in "if" (/showthread.php?tid=462743)



Order in "if" - dusk - 08.09.2013

Hello, i have a question.

If my if has 2 conditions (&&) will the second part of it will even be evaluated if the first part is false?


I came up with this when one part had only a "==" in it, and the other was a function with a pretty big loop in it.


Re: Order in "if" - JimmyCh - 08.09.2013

From what I understand, you mean something like:
pawn Код:
if(case 1 is false && case 2 is true)
{
}
No, the second part will not be evaluated, this checks if both are true.

You need to do the following:
pawn Код:
if(case 1 || case 2)
{
}
This will check if one of the cases is true.

Or you can do two "if"s, like the following:
pawn Код:
if(case 1)
{
}
else if(case 2)
{
}
Good luck.