SA-MP Forums Archive
Adding Explosive Barrels? - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Adding Explosive Barrels? (/showthread.php?tid=112698)



Adding Explosive Barrels? - DJDhan - 09.12.2009

Yo
So i was adding explosive barrels to my server map :P and realised they don't respawn back after being hit
I used CreateObject so there is no respawn time
Any solution??


Re: Adding Explosive Barrels? - dice7 - 09.12.2009

pawn Код:
new barrel = CreateObject();
SetTimer("BarrelRespawn", 60000, true);

forward BarrelRespawn();
public BarrelRespawn()
{
  DestroyObject(barrel);
  barrel = CreateObject();
}



Re: Adding Explosive Barrels? - DJDhan - 09.12.2009

Dude I have like 50 barrels .....how can do that easier?


Re: Adding Explosive Barrels? - Sergei - 09.12.2009

I would do that with foreach in such case.

pawn Код:
Itter_Create(Barrier,MAX_BARRIERS);

Itter_Add(Barrier,CreateObject(...));


SetTimer("BarRespawn",60000,true);
public BarRespawn()
{
  foreach(Barrier,x)
  {
    DestroyObject(x);
    Itter_Remove(Barrier,x);
    Itter_Add(Barrier,CreateObject(...));
  }
  return;
}



Re: Adding Explosive Barrels? - dice7 - 09.12.2009

Quote:
Originally Posted by DJDhan
Dude I have like 50 barrels .....how can do that easier?
By thinking a little and not waiting to copy everything you see

pawn Код:
new barrel[50];
barrel[0] = CreateObject();
// ...
barrel[49] = CreateObject();
//no there is no faster/better way

SetTimer("BarrelRespawn", 60000, true);

forward BarrelRespawn();
public BarrelRespawn()
{
  //loop start here
  DestroyObject(barrel[index]); //or whatever you'll use in the loop
  barrel[index] = CreateObject();
  //loop end here
}



Re: Adding Explosive Barrels? - DJDhan - 10.12.2009

I was not waiting to copy everything dice7
I guess i gotta do it one by one.