Does This Need Else If?
#9

Using switch is indeed the best thing here. But to answer the else-question: Else is a good thing to use here, as it can safe you 50% of the conditions and so optimizes the code a lot:

pawn Код:
stock UpdateRank(playerid)
{
    new string[128];
    if(PInfo[playerid][Owner] == 1) return format(pRank[playerid],128,"Server Owner");
    if(PInfo[playerid][Level] < 500) return format(pRank[playerid],128,"Administrator");
    if(PInfo[playerid][Missionspassed] >= 0 && PInfo[playerid][Missionspassed] < 10) return format(pRank[playerid],128,"New Trucker");
    else if(/*PInfo[playerid][Missionspassed] >= 10 && */PInfo[playerid][Missionspassed] < 25) return format(pRank[playerid],128,"Trucker");
    else if(/*PInfo[playerid][Missionspassed] >= 25 && */PInfo[playerid][Missionspassed] < 45) return format(pRank[playerid],128,"Advancing Trucker");
    // first condition is already checked, so not needed
    // ...
}
Reply


Messages In This Thread
Does This Need Else If? - by Shockey HD - 30.08.2011, 18:09
Re: Does This Need Else If? - by FireCat - 30.08.2011, 18:10
Re: Does This Need Else If? - by Kingunit - 30.08.2011, 18:12
Re : Does This Need Else If? - by Naruto_Emilio - 30.08.2011, 18:12
Re: Does This Need Else If? - by AndreT - 30.08.2011, 18:42
Re: Does This Need Else If? - by Kar - 30.08.2011, 18:44
Re: Does This Need Else If? - by Vince - 30.08.2011, 18:51
Re: Does This Need Else If? - by [L3th4l] - 30.08.2011, 18:59
Re: Does This Need Else If? - by Mauzen - 30.08.2011, 20:10
Re: Does This Need Else If? - by AndreT - 30.08.2011, 21:26

Forum Jump:


Users browsing this thread: 1 Guest(s)