SA-MP Forums Archive
Compare three variables? - 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: Compare three variables? (/showthread.php?tid=409639)



Compare three variables? - Mado - 22.01.2013

Hi,

In an if statement you can do something like:
if(Variable1 == Variable2)
{
blabla
}

But is this also posible with three variables, something like:
if(variable1 == variable2 == variable3)

?


Re: Compare three variables? - PaulDinam - 22.01.2013

if(variable1 == variable2 && variable2 == variable3)
this should work because if var1 = to var2, it checks if var2 equals to var3///


Re: Compare three variables? - MP2 - 22.01.2013

Why would you want to do that? It's exactly the same as doing if(variable1 == variable3)



Perhaps you mean 'is variable 1 equal to variable 2 OR variable 3'? In which case:

if(var1 == var2 || var1 == var3)


Re: Compare three variables? - Threshold - 22.01.2013

Nah he had it right... he's trying to check if all three variables are equal.

EDIT: Yes Paul... I was talking about you when I said 'he got it right'...


Re: Compare three variables? - PaulDinam - 22.01.2013

if(variable1 == variable2 && variable2 == variable3)
...