SA-MP Forums Archive
if and or ( || ) statement help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: if and or ( || ) statement help (/showthread.php?tid=64893)



if and or ( || ) statement help - StrickenKid - 08.02.2009

i made 3 money pickups and instead of making 3 different if statements i decided to use the or (||) function but it made it so everything that i pickup even if its a health pickup, it it makes it a money pickup

heres the code:
Код:
if(pickupid == moneypickup1 || moneypickup2 || moneypickup3)
{
	GivePlayerMoney(playerid,20000);
	GameTextForPlayer(playerid,"Found $20000!",3000,5);
}
anyone know whats wrong?


Re: if and or ( || ) statement help - Cueball - 08.02.2009

You need to keep comparing the variables to each other, or else the compiler will think you mean one thing, when you really don't.

Do this:
pawn Код:
if(pickupid == moneypickup1 || pickupid == moneypickup2 || pickupid == moneypickup3)
~Cueball~