difference between < and > in if(pinfo[playerid][Adminlevel]
#1

Hey guys, I was scrolling thru my admin system, checking if I made any mistakes. I found that in some Admin cmd's, I used:

Код:
if(pInfo[playerid][Adminlevel] > 1)
and in some other cmd's, I used:

Код:
if(pInfo[playerid][Adminlevel] < 1)
Well, what is the difference between < and >. Does it affect your CMD? Please reply!
Reply
#2

Doing a command like this:

pawn Код:
CMD:pm(playerid, params[])
{
    new iID, szMessage[80];
    if(sscanf(params, "us[79]", iID, szMessage))
        return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /pm [nick/id] [message]");
    if(iID == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "Invalid nickname/ID.");
    return 1;
}
Is fractionally slower than doing it like this:

pawn Код:
CMD:pm(playerid, params[])
{
    new iID, szMessage[80];
    if(!sscanf(params, "us[79]", iID, szMessage))
    {
        if(iID != INVALID_PLAYER_ID)
        {
            // do shit here
        }
        else // send client message
    }
    else // send client message
    return 1;
}
However, it's a matter of your personal preference when coding.

Some people like to do this:

pawn Код:
if ( sscanf( params, "us[79]", iID, szMessage ) )
While others do it like this:

pawn Код:
if(sscanf(params, "us[79]", iID, szMessage))
Whatever works best for you is how you should code.

EDIT: To answer your question...

< means less than

> means greater than

Like in my two examples above, it depends on how you like to code. I prefer choosing the first way- it looks cleaner IMHO. However, others don't think so.
Reply
#3

so if I make a command for level 5 admins, can it be for admins level 5 and plus, or will it be for admins level 5 and under.
Reply
#4

Two examples of using > and <.

pawn Код:
if(pAdmin[playerid] > 4) // checks if an admin level is GREATER THAN 4 (doesn't work if the admin level is equal to 4, ONLY greater than [so 5, 6, 7, 8, 9, 10, etc])

if(pAdmin[playerid] < 5) // checks if an admin level is LESS THAN 5, for example 4, 3, 2, 1, 0, etc are all LESS THAN 5
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Two examples of using > and <.

pawn Код:
if(pAdmin[playerid] > 4) // checks if an admin level is GREATER THAN 4 (doesn't work if the admin level is equal to 4, ONLY greater than [so 5, 6, 7, 8, 9, 10, etc])

if(pAdmin[playerid] < 5) // checks if an admin level is LESS THAN 5, for example 4, 3, 2, 1, 0, etc are all LESS THAN 5
I see now, thanks so much! +REP
Reply
#6

Gosh. This is like third grade math.
Reply
#7

Is bigger, or either is smaller. < is smaller, > is bigger.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)