26.09.2010, 15:06
In OnGameModeInit or where you create the objects the first time, use an array to store their ids like this:
Then you can use the ids in the timer to recreate all the objects:
pawn Код:
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"
}
pawn Код:
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(...);
...
}