Question about if else statements
#4

In your code, there is no "else" statement.
pawn Код:
// Check if the player is connected
if (IsPlayerConnected(playerid))
{
    // The player is connected, now check if he is a cop
    if (IsACop(playerid))
    {
        // Here the player is connected AND he's a cop, now we need to check if he's also an admin
        if (PlayerInfo[playerid][pRank] < 5)
        {
            // Code here to execute: the player is connected, he's a cop AND also is an admin
        }
        else
        {
            // The player is connected, AND he's a cop, but he's not an admin
        }
    }
    else
    {
        // The player is connected, but he's not a cop
    }
}
else
{
    // The player is not connected
}
I hope this will give some insights.

You could also do this:
pawn Код:
// If the player is NOT connected, exit the function
if (IsPlayerConnected(playerid) == 0) return 1;
// Here the player is connected, check if he's a cop now and exit the function if he's NOT a cop
if (IsACop(playerid) == 0) return 1;
// Here the player is connected AND a cop, now check if he's an admin (if not, exit the function)
if (PlayerInfo[playerid][pRank] < 5) return 1;

// Here the player is connected, he's a cop AND he's an admin, so execute the code for your pm system
Reply


Messages In This Thread
Question about if else statements - by K9IsGodly - 12.03.2014, 00:12
Respuesta: Question about if else statements - by angelxeneize - 12.03.2014, 00:24
Respuesta: Question about if else statements - by angelxeneize - 12.03.2014, 00:29
Re: Question about if else statements - by PowerPC603 - 12.03.2014, 00:32
Re: Question about if else statements - by CuervO - 12.03.2014, 00:34
Re: Question about if else statements - by K9IsGodly - 12.03.2014, 00:35
Respuesta: Question about if else statements - by SickAttack - 12.03.2014, 00:37
Re: Question about if else statements - by CuervO - 12.03.2014, 00:38
Re: Question about if else statements - by Pottus - 12.03.2014, 00:39
Respuesta: Question about if else statements - by angelxeneize - 12.03.2014, 00:41

Forum Jump:


Users browsing this thread: 1 Guest(s)