Levels
#1

pawn Код:
CMD:kick(playerid,params[])
{
    if((PInfo[playerid][Level] < 1) || (PInfo[playerid][Operator] < 1)) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
    new id;//Creating a variable to store the selected id;
    //new Target;
    //if(Target == playerid) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You cant kick yourself!");
    if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"USAGE: /kick <id>");//Checking if the player has selected an id, other wise it sends him a message. We used the "u" specifier, because he can put a name or an id.
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-4,"That player is not connected!");//Checking if the selected user is connected or not.
    Kick(id);
    SendClientMessage(playerid,-1,"You have kicked the selected user!");
    return 1;
}
Why doesn't this work:
pawn Код:
if((PInfo[playerid][Level] < 1) || (PInfo[playerid][Operator] < 1)) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
it only takes the level but not the operator...
Reply
#2

What do you want it to do?
Currently it checks if your level is under 1 OR operator is under 1. Is this actually what you want?
Reply
#3

Try this:

Код:
CMD:kick(playerid,params[])
{
    new id;
    if(PInfo[playerid][Level] <= 1 || PInfo[playerid][Operator] < =1) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
    //Creating a variable to store the selected id;
    //new Target;
    //if(Target == playerid) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You cant kick yourself!");
    {
	if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"USAGE: /kick <id>");//Checking if the player has selected an id, other wise it sends him a message. We used the "u" specifier, because he can put a name or an id.
    	if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-4,"That player is not connected!");//Checking if the selected user is connected or not.
    	Kick(id);
    	SendClientMessage(playerid,-1,"You have kicked the selected user!");
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by LarzI
Посмотреть сообщение
What do you want it to do?
Currently it checks if your level is under 1 OR operator is under 1. Is this actually what you want?
It currently only checks the level, but i want it to check both so if you are either operator or admin you can use it.
Reply
#5

Then change || to &&.

|| = OR, && = AND.
Reply
#6

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Then change || to &&.

|| = OR, && = AND.
he said...

Quote:
Originally Posted by Biess
Посмотреть сообщение
either operator or admin you can use it.
Try what Zex Tan wrote.
Reply
#7

Quote:
Originally Posted by Mr.Anonymous
Посмотреть сообщение
he said...



Try what Zex Tan wrote.
No. I don't think you get what he needs, really.

He wants to check if the player is NEITHER an admin or a leader, then the command should not fall through.
With the || operators, you will check if EITHER he's not an admin or EITHER he's not a leader, not BOTH. If he'd do this, the command would only fall through if the player was both.
Reply
#8

Now you're getting me confused between NEITHER and EITHER. What Biess wrote up there was pretty much clear. Look...

Quote:
Originally Posted by Biess
Посмотреть сообщение
It currently only checks the level, but i want it to check both so if you are either operator or admin you can use it.
But still you maybe right there. He needs to correct us here.
Reply
#9

Quote:
Originally Posted by Mr.Anonymous
Посмотреть сообщение
Now you're getting me confused between NEITHER and EITHER. What Biess wrote up there was pretty much clear. Look...



But still you maybe right there. He needs to correct us here.
Read what he says:
Quote:

but i want it to check both so if you are either operator or admin you can use it.
The if-statement is there to check if he cannot use it, and then stop the command. You're mixing the two up

Quick example:
pawn Код:
if(( PInfo[ playerid ][ Level ] < 1) || ( PInfo[ playerid ][ Operator ] < 1 ))
//if this check is true - the command should not continue.
Let's translate it (simple/easy): IF the playervar's level-enum is lower than 1 (not admin) OR the playervar's operator-enum is lower than 1 (not operator).

This means that if either one is true, this statement will go through:

admin = false
operator = false
statement = true

admin = false
operator = true
statement = true

admin = true
operator = false
statement = true

admin = true
operator = true
statement = true

If he however want not only operator-admins to do the command, but also single operators and single admins, he would have to deny the command for players who are NEITHER admin OR operator (NOR), that means that he has to check both of them at the same time, and BOTH has to return false, else the command should go through.

Thus leaving us with the code:
pawn Код:
if(( PInfo[ playerid ][ Level ] < 1) && ( PInfo[ playerid ][ Operator ] < 1 ))
Translated: IF the playervar's level-enum is lower than 1 (not admin) AND the playervar's operator-enum is lower than 1 (not operator either)
____________________________________

Do you understand now? I can't really explain it more thouroughly.

If || was NOR, instead of OR, then it would be correct to use ||
Reply
#10

I'm not talking about can use it or cannot use it. I am just talking about ... nevermind. We are going into our own discussion.

Biess: So you mean that if the player is more than level 0, that is 1,2,3..., also if the player has operator level more than 0, that is 1,2,3..., they can use the command? Then I guess it would be:
pawn Код:
if(PInfo[playerid][Level] >= 1 || PInfo[playerid][Operator] >= 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)