Hi, this is a tutorial how to use Ternary Operators.
Let's use an example :
new
a = 0;
if ( a == 0 ) {
a = 1;
}
else {
a = 2;
}
Can be shorten to :
new
a;
a = (a == 0) ? 1 : 2;
Let's break it out.
a = (a == 0) ? 1 : 2;
--
( a == 0 ) -> If a == 0
--
? -> Then
--
1 -> Set it to 1. ( No ';' here )
--
: -> Else
--
2; -> Set it to 2. ( Now, there's a ';' here )
--
That was easy!
More examples :
SetPlayerTeam( playerid, ( pro[ playerid ] == true ) ? TEAM_PRO : TEAM_NOOB );
SendClientMessage( playerid, -1, ( pro[ playerid ] == true ) ? ( "You are a pro." ) : ( "Noob." ) );
// ^ you need brackets for strings
Hope I helped.