"or" condition?
#1

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

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

well i am level 4 but it wont work :S
Reply
#4

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

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

It will check the or since the first check failed.
Reply
#7

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

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

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

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)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)