26.09.2010, 13:13
Hi all,how to respawn objects after they are destroyed?
I want a respawn after 1 minute..thanks
I want a respawn after 1 minute..thanks
new objects[NUMBER_OF_YOUR_OBJECTS];
public OnGameModeIni()
{
objects[0] = CreateObject(...);
objects[1] = CreateObject(...);
objects[2] = CreateObject(...);
...
SetTimer("RespawnObjects", 60000, 1); //Creates a repeating 60 seconds timer that calls "RespawnObjects"
}
forward RespawnObjects();
public RespawnObjects()
{
for(new i = 0; i < sizeof(objects); i ++) //This loop destroys all the objects, so there are no double objects
{
DestroyObjects(objects[i]);
}
//Then recreate them, just use the code you used in OnGameModeInit to create them:
objects[0] = CreateObject(...);
objects[1] = CreateObject(...);
objects[2] = CreateObject(...);
...
}