difference between < and > in if(pinfo[playerid][Adminlevel]
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)