SA-MP Forums Archive
what this || and & and ... ? - 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: what this || and & and ... ? (/showthread.php?tid=431189)



what this || and & and ... ? - morocco - 16.04.2013

Hi guys

i need know somethings about this cmd

and where can i using it


Please guys help me


Re: what this || and & and ... ? - HurtLocker - 16.04.2013

In this case:
pawn Код:
if (condition1 || condition2)
the if statement gets triggered even if 1 of the 2 condition is true while the other is not.


In this case:
pawn Код:
if (condition1 && condition2)
the if statement gets triggered only if both conditions are true.


The necessity of these signs will arrise at its own when you start scripting...


Re: what this || and & and ... ? - Dj_maryo1993 - 16.04.2013

if you mean what i think you mean

you use || when you need to check if 2 or more things are true , and go forward if any is true
EXAMPLE :
This is from my goto comand
pawn Код:
if(PlayerInfo[playerid][AdminLevel] >= 1 ||PlayerInfo[playerid][HelperLevel] >= 1){blabla rest of the stuff}
This will pas if player is an admin OR an helper


The &&(yes , 2 of them ) , just like what it means , and , you use this when you want to check 2 or more things and you want all of them to be true
EXAMPLE

pawn Код:
if(IsACop(killerid) && GetPlayerWantedLevel(playerid)>0){blabla}
This will pass trough if the player is a cop and his wanted lvl is higher than 0


Re : Re: what this || and & and ... ? - morocco - 16.04.2013

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
In this case:
pawn Код:
if (condition1 || condition2)
the if statement gets triggered even if 1 of the 2 condition is true while the other is not.


In this case:
pawn Код:
if (condition1 && condition2)
the if statement gets triggered only if both conditions are true.


The necessity of these signs will arrise at its own when you start scripting...
Quote:
Originally Posted by Dj_maryo1993
Посмотреть сообщение
if you mean what i think you mean

you use || when you need to check if 2 or more things are true , and go forward if any is true
EXAMPLE :
This is from my goto comand
pawn Код:
if(PlayerInfo[playerid][AdminLevel] >= 1 ||PlayerInfo[playerid][HelperLevel] >= 1){blabla rest of the stuff}
This will pas if player is an admin OR an helper


The &&(yes , 2 of them ) , just like what it means , and , you use this when you want to check 2 or more things and you want all of them to be true
EXAMPLE

pawn Код:
if(IsACop(killerid) && GetPlayerWantedLevel(playerid)>0){blabla}
This will pass trough if the player is a cop and his wanted lvl is higher than 0



Guys thanks all

Ok now
|| = or ...


thank you very much



Re: what this || and & and ... ? - [ABK]Antonio - 16.04.2013

https://sampwiki.blast.hk/wiki/Control_Structures


Re : Re: what this || and & and ... ? - morocco - 17.04.2013

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
oh, yeh yeh

Yes man i search for thi

thank you