How can I do object respawn
#1

Hello,
I made a SWAT Training room with cartons targets, but when i destroyed them I need to relog because they disappeared.

How can I made them to respawn?
Please help.

http://imageshack.us/gal.php?id=rpWqkt7U09ypmqnUmePU06g

Thanks
Reply
#2

Quote:
Originally Posted by Jin
Посмотреть сообщение
Hello,
I made a SWAT Training room with cartons targets, but when i destroyed them I need to relog because they disappeared.

How can I made them to respawn?
Please help.

http://imageshack.us/gal.php?id=rpWqkt7U09ypmqnUmePU06g

Thanks
I don't think that the destroyed objects are detected, you can use a timer on OnGameModeInit and destroy all the objects and then respawn them again after any amount of time.

-FalconX
Reply
#3

I'm new can you give me more information
Reply
#4

Quote:
Originally Posted by Jin
Посмотреть сообщение
I'm new can you give me more information
Okay well it's basically simple:-

pawn Код:
new totalobj[TOTALNUMBER_OF_OBJECTS];

public OnGameModeInit()
{
      totalobj[0] = CreateObject();
      totalobj[1] = CreateObject();
      totalobj[2] = CreateObject();
      // rest if the objects

      SetTimer("RespawnAllObj", 60000, 1); // here it keeps on repeating the respawn process on every 60 seconds you can increase the time if you want.
}

forward RespawnAllObj();
public RespawnAllObj() // main function which the timer does. After every 60 seconds this process is repeated.

      for(new i = 0; i < sizeof(totalobj); i ++) // this is a loop which take all the objects from totalobj and destroys.
      {
          DestroyObject(totalobj[i]);
      }
      //Then recreate them, just use the code you used in OnGameModeInit to create them:
      totalobj[0] = CreateObject();
      totalobj[1] = CreateObject();
      totalobj[2] = CreateObject();
      // ... Rest of the objects.
}
I am on phone sorry for any mistake hope this helps you.

Use CreateObject from the following link:-

https://sampwiki.blast.hk/wiki/CreateObject

-FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)