OR (||) and (&&) problem
#1

Hello

I have been testing something and found out something wierd

If I use this:
PHP код:
if(PlayerInfo[playerid][AdminLevel] < && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
I Have to be just LEVEL 5 "OR" RCON ADMIN

If I use this:
PHP код:
if(PlayerInfo[playerid][AdminLevel] < || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
I Have to be just LEVEL 5 "AND" RCON ADMIN

Isnt that wierd?


And on the wiki:



&&------------- and ------------- if (Left && Right)
||-------------- or ------------- if (Left || Right)
Reply
#2

so what you want to do?
Reply
#3

I am testing it

They are switched..
Is it a bug.....?
Reply
#4

It's not weird you can't understand what your code means, you typed if 5 is more than player's level the player is not addmin this is why both printed the same thing
Reply
#5

This is correct:
pawn Код:
if(PlayerInfo[playerid][AdminLevel] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin");
The error appears if you aren't admin level 5 AND you aren't RCON admin. So if you have admin level 5 but you aren't RCON you won't receive that error.
Reply
#6

Read everything
I sad that in the start
But it works switched
In that case U sad you have to be LEVEL 5 OR RCON ADMIN
Thats wierd.-....
Reply
#7

Quote:
Originally Posted by kalanerik99
Посмотреть сообщение
Hello

I have been testing something and found out something wierd

If I use this:
PHP код:
if(PlayerInfo[playerid][AdminLevel] < && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
I Have to be just LEVEL 5 "OR" RCON ADMIN

If I use this:
PHP код:
if(PlayerInfo[playerid][AdminLevel] < || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
I Have to be just LEVEL 5 "AND" RCON ADMIN

Isnt that wierd?


And on the wiki:



&&------------- and ------------- if (Left && Right)
||-------------- or ------------- if (Left || Right)
I wouldn't say it is a bug in any way, let me tell you what it means with words.

PHP код:
if(PlayerInfo[playerid][AdminLevel] < && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
If your level is below five and isplayeradmin gave me zero I am telling you that you are not an admin.

PHP код:
if(PlayerInfo[playerid][AdminLevel] < || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You arent admin"); 
If your level is below five or isplayeradmin gave me zero I am telling you that you are not an admin.

It makes perfect sense, at least for me.
Reply
#8

Yeaaaaa but it works switched!!!!!!

Read everything and looak at my code completely
Reply
#9

Are you even listening? Or works the same way like before, the reason it is switched is because you are checking for the negative side of it, not the positive. if it was like:

if(PlayerInfo[playerid][AdminLevel] >= 5 || IsPlayerAdmin(playerid))
{
//Do your code
}
else return SendClientMessage(playerid, -1, "You are not an admin my friend.");

It would still work the same way.
Reply
#10

Hmmm ok

I will come back....
Bye for now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)