22.06.2012, 11:07
It depends whether you need the if statement to be processed whether a condition has been found.
It really doesn't matter too much normally, but it's good practice to use else if where possible.
You can find out more and get a much better description than i have given in almost any programming book. Most languages have if else if statements. If you know what "else" means in English you should have a fairly good understanding of what else if does.
pawn Код:
public OnPlayerConnect(playerid)
{
new var = 5;
if( var == 5 )
{
}
if( var == 10 )//this will be processed even if you have already determined that var isn't 10
{
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new var = 5;
if( var == 5 )
{
//because this is executed any following "else if" will not be processed.
}
else if( var == 10 )//this will not be processed if any statement above has been executed
{
}
return 1;
}
You can find out more and get a much better description than i have given in almost any programming book. Most languages have if else if statements. If you know what "else" means in English you should have a fairly good understanding of what else if does.