SA-MP Forums Archive
What's more efficient, GetVehiclePoolSize or create an iterator ? - 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: What's more efficient, GetVehiclePoolSize or create an iterator ? (/showthread.php?tid=620210)



What's more efficient, GetVehiclePoolSize or create an iterator ? - NeXoR - 27.10.2016

Hey guys, as the title says, what do you think is better to use ?
This:
PHP код:
for(new 0GetVehiclePoolSize(); ji++) 
or
PHP код:
public OnVehicleStreamIn(vehicleidforplayerid)
{
if(!
Iter_Contains(Vehiclesvehicleid)) Iter_Add(Vehiclesvehicleid);
return 
1;
}
foreach(new 
Vehicles



Re: What's more efficient, GetVehiclePoolSize or create an iterator ? - vassilis - 27.10.2016

It's 2 different things. Surely iteration is perfect for a loop but you should consider that you can use it more efficiently on more things than a loop.


Re: What's more efficient, GetVehiclePoolSize or create an iterator ? - NeXoR - 27.10.2016

Quote:
Originally Posted by vassilis
Посмотреть сообщение
It's 2 different things. Surely iteration is perfect for a loop but you should consider that you can use it more efficiently on more things than a loop.
Such as ?


Re: What's more efficient, GetVehiclePoolSize or create an iterator ? - Rdx - 27.10.2016

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
PHP код:
public OnVehicleStreamIn(vehicleidforplayerid)
{
if(!
Iter_Contains(Vehiclesvehicleid)) Iter_Add(Vehiclesvehicleid);
return 
1;
}
foreach(new 
Vehicles
That code is bad, this public is per player.


Re: What's more efficient, GetVehiclePoolSize or create an iterator ? - Kaliber - 27.10.2016

Just use:

PHP код:
for(new GetVehiclePoolSize(); != 0i--)