SetTimerEx..."i"
#4

This is the simplest way returning can be explained and people usually use returning this way.
A function, when It's called, always returns, lets say, a status code to the main program, so the main program knows what's currently going on.
pawn Код:
main()
{
    new number = GetRandomNumber();
    printf("Our random number is %d", number);
   
    if (IsSunOutside()) OR (IsSunOutside() == 1) OR (IsSunOutside() == true)
    {
        printf("It's also sunny");
    }
}

GetRandomNumber()
{
    new rand = random(5); //a random number from 0 to 4
    return rand; //returning the random number to the main program, so it can use it in the printf
}

IsSunOutside()
{
    if (time > 08:00 && time < 20:00) return 1; //returning either 1 or 0 to the main program, so it knows if its sunny or not
    else return 0;
}
Note that 'unconventional' functions also return values. For example, SetPlayerHealth return 1, if it successfully set the players health, else it returns 0.
pawn Код:
if (SetPlayerHealth(playerid, health))
{
  //player is connected and the health is set
}
Reply


Messages In This Thread
SetTimerEx..."i" - by Assyria - 26.04.2010, 12:24
Re: SetTimerEx..."i" - by Jay_ - 26.04.2010, 12:26
Re: SetTimerEx..."i" - by Assyria - 26.04.2010, 12:40
Re: SetTimerEx..."i" - by dice7 - 26.04.2010, 13:00

Forum Jump:


Users browsing this thread: 2 Guest(s)