Detecting a /v car.
#9

I've never spawned many vehicles and it was something I never knew about valid vehicles 1-1999. I thought it was up to 2000.

But it can still be used as:
pawn Код:
new bool:VehiclesByVCommand[MAX_VEHICLES - 1];

// In your /v command use:
VehiclesByVCommand[vehicleid - 1] = true;
and the worst part of the above is:
pawn Код:
for (new vid; vid < MAX_VEHICLES; vid++)
Your server has 4 vehicles only (an example) and you loop 2000 times. It seems bad, isn't it? The best solution would be an iterator (foreach) for the created vehicles and it will loop through ONLY the valid (those which exist) vehicles.

I'm not saying that the code is bad, this is how it would be used by the most users but optimizations (even small ones) are always good - atleast for me.
Reply


Messages In This Thread
Detecting a /v car. - by DaniceMcHarley - 06.01.2014, 15:42
Re: Detecting a /v car. - by PowerPC603 - 06.01.2014, 16:01
Re: Detecting a /v car. - by sammp - 06.01.2014, 16:05
Re: Detecting a /v car. - by sammp - 06.01.2014, 16:24
Re: Detecting a /v car. - by Patrick - 06.01.2014, 16:29
Re: Detecting a /v car. - by Konstantinos - 06.01.2014, 16:34
Re: Detecting a /v car. - by DaniceMcHarley - 06.01.2014, 17:39
Re: Detecting a /v car. - by PowerPC603 - 07.01.2014, 12:58
Re: Detecting a /v car. - by Konstantinos - 07.01.2014, 15:08
Re: Detecting a /v car. - by PowerPC603 - 07.01.2014, 15:19

Forum Jump:


Users browsing this thread: 1 Guest(s)