what this || and & and ... ?
#1

Hi guys

i need know somethings about this cmd

and where can i using it


Please guys help me
Reply
#2

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...
Reply
#3

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
Reply
#4

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
Reply
#5

https://sampwiki.blast.hk/wiki/Control_Structures
Reply
#6

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

Yes man i search for thi

thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)