SA-MP Forums Archive
help with foreach! - 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: help with foreach! (/showthread.php?tid=554653)



help with foreach! - danish007 - 04.01.2015

hello, im using for each functions in my command /vehicle.
i want to ask that should i use Iter_SafeRemove(.. .. ..) when vehicle destroy?
if yes can anyone tell me why?

i create car like..
Код:
Iter_Add(NormalVeh,CreateVehicle(veh, X+3, Y, Z, angle, -1, -1, -1));



Re: help with foreach! - danish007 - 04.01.2015

but when i use iter_add(vehiclecode then itercount gets ++ and on destroy vehicles it doesnt get --
so thats why i thought to use iter_SafeRemove. to decrease count for vehicles.

[EDIT]: and i made 2 more types of vehicles. adminvehicles and donator vehicles.
sometimes it get mixed.
when i spawn donator vehicle. it becomes admin vehicle. on enter in vehicle it says to me admin vehicle. even i spawned by using donator vehicle spawn command


Re: help with foreach! - danish007 - 04.01.2015

i have to use Iter_Remove in a loop? (Foreach Loop)?
and i used like this

under OnVehicleDeath

if(Iter_Contains(AdminVeh, vehicleid))Iter_Remove(AdminVeh, vehicleid);

it will work fine?

[EDIT]: Please read my Reply again i've edited something again!


Re: help with foreach! - danish007 - 04.01.2015

can you read my replies again?


Re: help with foreach! - Lordzy - 04.01.2015

That should work, even if you haven't used Iter_Contains, Iter_Remove removes values only if they're found.


Re: help with foreach! - danish007 - 04.01.2015

so Iter_Remove will decrease number of vehicles from given iterator like? we use AnyVariable--;