Efficient Vehicle Looping - 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)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Efficient Vehicle Looping (
/showthread.php?tid=573170)
Re: Efficient Vehicle Looping -
Marricio - 08.05.2015
An easy way to do this is the following, no need for loops or anything:
* Create an area and attach it to the vehicle.
* Set the streamer item EXTRA_ID value to the vehicle id.
* Detect OnPlayerEnterDynamicArea and obtain the EXTRA_ID value from the area id (that would be the vehicle id).
* Create some array or some variable and assign the vehicle ID to it. (Something like PlayerClosestVehicle)
* Detect OnPlayerLeaveDynamicArea, detect if its a vehicle area and remove it from the variable/array you created previously.
However, you would need Incognito's Streamer functions to achieve this.
I currently use this method for everything, and I don't face any lag or RAM usage problems. (If you need an example code for it PM me, I'm not home right now).
Re: Efficient Vehicle Looping -
Pottus - 09.05.2015
Quote:
Originally Posted by Marricio
An easy way to do this is the following, no need for loops or anything:
* Create an area and attach it to the vehicle.
* Set the streamer item EXTRA_ID value to the vehicle id.
* Detect OnPlayerEnterDynamicArea and obtain the EXTRA_ID value from the area id (that would be the vehicle id).
* Create some array or some variable and assign the vehicle ID to it. (Something like PlayerClosestVehicle)
* Detect OnPlayerLeaveDynamicArea, detect if its a vehicle area and remove it from the variable/array you created previously.
However, you would need Incognito's Streamer functions to achieve this.
I currently use this method for everything, and I don't face any lag or RAM usage problems. (If you need an example code for it PM me, I'm not home right now).
|
That is the best way let the streamer do the work by utilizing the EXTRA_ID you have an instant reference of the vehicle id.