SA-MP Forums Archive
MAX_VEHICLES - 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: MAX_VEHICLES (/showthread.php?tid=628243)



MAX_VEHICLES - SpaceRP - 07.02.2017

he would like to transfer MAX_VEHICLES
in GetVehiclePoolSizebut who loop best-optimized

Код:
for(new i = 0; i <= GetVehiclePoolSize(); i++)

for(new i = 0, j = GetVehiclePoolSize(); i <= j; i++)

for(new i = GetVehiclePoolSize(); i > 0; i--)



Re: MAX_VEHICLES - Jefff - 08.02.2017

Last, one variable 'i' and one usage GetVehiclePoolSize


Re: MAX_VEHICLES - SpaceRP - 08.02.2017

Код:
for(new i = GetVehiclePoolSize(); i > 0; i--)
why this code?


Re: MAX_VEHICLES - DRIFT_HUNTER - 08.02.2017

Because GetVehiclePoolSize function is called only once, its returned value is saved into pawn's VM memory. That should be faster than always calling a function that will be passing a value from some other place in memory. Basically there is less code abstraction (probably not best way to explain it but my mind is empty atm.)