optimize - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: optimize (
/showthread.php?tid=658075)
optimize -
KinderClans - 22.08.2018
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])
Re: optimize -
GospodinX - 22.08.2018
This?
Код:
for(new i=1; i<10; i++)
{
if(vehicleid == CarRentLs[i])
{
//your code
}
}
Re: optimize -
Lokii - 22.08.2018
PHP код:
if(CarRentLs[1] >= vehicleid <= CarRentLs[9])
Re: optimize -
KinderClans - 22.08.2018
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?
Re: optimize -
Sew_Sumi - 24.08.2018
Means you didn't define the RentCarLabel array as 3dtext, or as the wrong 3dtext/text3d.
Re: optimize -
SyS - 24.08.2018
http://wiki.c2.com/?PrematureOptimization
Re: optimize -
Shinja - 24.08.2018
PHP код:
Attach3DTextLabelToVehicle(RentCarLabel[i] , CarRentLs[i], 0.0, 0.0, 2.0);
RentCarLabel must be defined as Text3D