IF or SWITCH?
#1

Hi everyone. I want to ask you what is better to use.

In callback OnPlayerSpawn i have random spawn function which detect position by Team

pawn Code:
if (Team == T_MEDIC)
    {
        SetPlayerPosEx(playerid, MedicPos[Pos][0], MedicPos[Pos][1], MedicPos[Pos][2], MedicPos[Pos][3]);
    }
    else if (Team == T_FARMER)
    {
    ....
should i use switch, or if ?
pawn Code:
switch(Team)
{
    case T_MEDIC: SetPlayerPosEx(playerid, MedicPos[Pos][0], MedicPos[Pos][1], MedicPos[Pos][2], MedicPos[Pos][3]);
    case T_FARMER: ....
Reply
#2

how many cases do u have
Reply
#3

I use switch only in large parts. If it's a part with 2 lines, if this, else I will use if/else statement.
Reply
#4

Mostly "switch" is faster then "if/else" statements, but you can't use it everywhere.
Reply
#5

Yes this is so large... so i'll use switch thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)