SA-MP Forums Archive
difference between < and > in if(pinfo[playerid][Adminlevel] - 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)
+--- Thread: difference between < and > in if(pinfo[playerid][Adminlevel] (/showthread.php?tid=417558)



difference between < and > in if(pinfo[playerid][Adminlevel] - Goldino - 21.02.2013

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!


Re: difference between < and > in if(pinfo[playerid][Adminlevel] - Scenario - 21.02.2013

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.


Re: difference between < and > in if(pinfo[playerid][Adminlevel] - Goldino - 21.02.2013

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.


Re: difference between < and > in if(pinfo[playerid][Adminlevel] - Scenario - 21.02.2013

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



Re: difference between < and > in if(pinfo[playerid][Adminlevel] - Goldino - 21.02.2013

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


Re: difference between < and > in if(pinfo[playerid][Adminlevel] - Vince - 21.02.2013

Gosh. This is like third grade math.


Re: difference between < and > in if(pinfo[playerid][Adminlevel] - JamesS - 21.02.2013

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