else if and case:
#1

Hello all,

I've been using 'else if's the whole time, until I found out the switch statements make things more efficient. However, I'm a little confused with its usage.

pawn Код:
switch(GetVehicleModel(vehicleid))
{
    //AIRPLANES//
    case 460: //code x1
    case 476: //code x2
    case 511: //code x3
    case 512: //code x4
    case 513: //code x5
}
The code is substantially long, and it occupies 5 times as much space as compared to using else if. Is there a way to do it such that I only need to have just one of it is carried out throughout the 5 cases?

pawn Код:
if(GetVehicleModel(playerid) == 460 || GetVehicleModel(playerid) == 476  || GetVehicleModel(playerid) == 511 || GetVehicleModel(playerid) == 512 || GetVehicleModel(playerid) == 513)
{
    //code x1
}
Thanks
Reply


Messages In This Thread
else if and case: - by BpX - 30.11.2013, 18:11
Re: else if and case: - by Loot - 30.11.2013, 18:17
Re: else if and case: - by J4mmyHD - 30.11.2013, 18:23
Re: else if and case: - by Konstantinos - 30.11.2013, 18:48
Re: else if and case: - by BpX - 01.12.2013, 13:16

Forum Jump:


Users browsing this thread: 4 Guest(s)