SA-MP Forums Archive
"or" condition? - 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: "or" condition? (/showthread.php?tid=247171)



"or" condition? - THE_KNOWN - 08.04.2011

umm ive seen people using the || as or condition but i doesnt work for me. did i make any mistake?

Код:
	if(admin[playerid]!= 4 || omod[playerid] != id) return SendClientMessage(playerid, red, "You cannot use this command.");
it says i cant use the cmd


Re: "or" condition? - BMUK - 08.04.2011

if(admin[playerid] != 4 || omod[playerid] != id) return SendClientMessage(playerid, red, "You cannot use this command.");

That means you cannot use the command if admin[playerid] does NOT equal 4 or if omod[playerid] does NOT equal id

Only you will know if that is correct or not since it's your script.


Re: "or" condition? - THE_KNOWN - 08.04.2011

well i am level 4 but it wont work :S


Re: "or" condition? - BMUK - 08.04.2011

Maybe it's a problem with omod[playerid] then?

Even if you are level 4, the omod[playerid] can still stop the command being used if you are using ||.


Re: "or" condition? - THE_KNOWN - 08.04.2011

how? sices im lvl 4 i dont think itll even check the OR


Re: "or" condition? - [03]Garsino - 08.04.2011

It will check the or since the first check failed.


Re: "or" condition? - THE_KNOWN - 08.04.2011

any fix for it? coz i tried being level 4 or being omod ort both but all result in the same thing


Re: "or" condition? - THE_KNOWN - 08.04.2011

man ***** i got confused with your explanation... as i see in your code your using &&. isnt that 'and' and wont it require me to be both lvl 4 and a omodder? (omod is org moddifier :P )? i want either a omod or admin lvl 4 to be able to use the command.


Re: "or" condition? - [03]Garsino - 08.04.2011

pawn Код:
if(admin[playerid] != 4 && omod[playerid] != id) return /* error message */
// IF (admin[playerid] DOES NOT EQUAL 4 AND omod[playerid] DOES NOT EQUAL id) then return /* error message */
I belive that is the code you're looking for.


Re: "or" condition? - THE_KNOWN - 08.04.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
if (admin[playerid] == 4 || omod[playerid] == id)
{
    // Do your code.  Now you can see if those conditions are correct much more easilly.
}
else return SendClientMessage(playerid, red, "You cannot use this command.");
this worked thanks a lot *****. but can you give me an explanation why my code didnt work? (coz its just the return and negative (!=) i have)