optimize
#1

I'm sure there is a better way to optimize this code:

pawn Код:
if(vehicleid == CarRentLs[1] || vehicleid == CarRentLs[2] || vehicleid == CarRentLs[3] || vehicleid == CarRentLs[4] || vehicleid == CarRentLs[5] || vehicleid == CarRentLs[6] || vehicleid == CarRentLs[7] || vehicleid == CarRentLs[8] || vehicleid == CarRentLs[9])
Reply
#2

This?
Код:
for(new i=1; i<10; i++)
{
	if(vehicleid == CarRentLs[i])
	{
	    //your code
	}
}
Reply
#3

PHP код:
if(CarRentLs[1] >= vehicleid <= CarRentLs[9]) 
Reply
#4

Thank you everyone. I'm trying to attach a 3dTextLabel to this vehicles i created:

pawn Код:
for(new i = 0; i < sizeof(CarRentLs); i++)
    {
        new nrinmatric[50];
        format(nrinmatric, sizeof(nrinmatric), "{FF0033}RNT - 0%d", i);
        SetVehicleNumberPlate(CarRentLs[i], nrinmatric);
        SetVehicleToRespawn(CarRentLs[i]);
        RentCarLabel[i] = Create3DTextLabel( "Rental Car", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1);
        Attach3DTextLabelToVehicle(RentCarLabel[CarRentLs] , vehicle_id, 0.0, 0.0, 2.0);
    }
Getting tag mismatch, what's wrong?
Reply
#5

Means you didn't define the RentCarLabel array as 3dtext, or as the wrong 3dtext/text3d.
Reply
#6

http://wiki.c2.com/?PrematureOptimization
Reply
#7

PHP код:
Attach3DTextLabelToVehicle(RentCarLabel[i] , CarRentLs[i], 0.00.02.0); 
RentCarLabel must be defined as Text3D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)