SA-MP Forums Archive
Use foreach to respawn 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: Use foreach to respawn vehicles? (/showthread.php?tid=422026)



Use foreach to respawn vehicles? - rangerxxll - 11.03.2013

So I know how to make the command, I'm just wondering if foreach can be used to loop through all vehicles, instead of just players. Is it possible?

pawn Код:
foreach (Vehicle, i)
?


Re: Use foreach to respawn vehicles? - ReneG - 11.03.2013

You'll have to define a new foreach-array. Read the foreach topic.


Re: Use foreach to respawn vehicles? - rangerxxll - 11.03.2013

I've read it.

But I don't quite understand how to define a new array for it. Would you happen to know?


Re: Use foreach to respawn vehicles? - ReneG - 11.03.2013

pawn Код:
new Iterator:vehicles<MAX_VEHICLES>;
You can use y_hooks to hook Create/DestroyVehicle to Iter_Add() or Iter_Remove()


Re: Use foreach to respawn vehicles? - rangerxxll - 11.03.2013

Appreciated. And another quick question (To avoid multiple posts.) to anyone who can help.

How can I use y_hooks to include another mode to my main game mode? I did it before, with something like this.
pawn Код:
#include <gamemode.pwn>
But obviously I have the wrong code here.


Re: Use foreach to respawn vehicles? - ReneG - 11.03.2013

y_hooks has nothing to do with including files.

but I imagine it would be something like

Код:
#include "..\gamemodes\mode.pwn"
I don't remember whether it's forward or back slashes, you might even need to change the file extension to .inc, I'm not too sure.


Re: Use foreach to respawn vehicles? - MP2 - 11.03.2013

.pwn works.


Re: Use foreach to respawn vehicles? - rangerxxll - 12.03.2013

I see. Thank you.