[Tutorial] Booleans and what they can be used for (Checking states, etc)
#2

Not bad, but just pointing out somethings -

It should be -
pawn Код:
new bool:isplayerongodmode[MAX_PLAYERS] = false;

CMD:god(playerid)
{
    if(isplayerongodmode[playerid] == false) //Checking if the 'state' of the player is NOT GOD MODE.
    {
         SetPlayerHealth(playerid, 999); //Setting the player's health to infinity.
         isplayerongodmode[playerid] = true; //Setting the player's mode to 'ON GOD MODE'.
     }
     if(isplayerongodmode == true) //Checking if the 'state' of the player is GOD MODE.
     {
          SendClientMessage(... "You are already on god mode!"); //Sending him the error message.
      }
     return 1;
}
Also, you should show an example of how to use return true; and return false;


pawn Код:
stock bool:IsAdminConnected()
{
    for(new x= 0; x < MAX _PLAYERS; x++)
    {
          if(IsPlayerAdmin(x)) return true;
    }
    return false;
}
and a little more further explain HOW a normal variable differs from a boolean, what's the advantage/disadvantage etc.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)