respawning objects
#5

In OnGameModeInit or where you create the objects the first time, use an array to store their ids like this:

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"
}
Then you can use the ids in the timer to recreate all the objects:

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(...);
    ...
}
Reply


Messages In This Thread
respawning objects - by Face9000 - 26.09.2010, 13:13
Re: respawning objects - by Libra_PL - 26.09.2010, 13:50
Re: respawning objects - by Mauzen - 26.09.2010, 14:03
Re: respawning objects - by Face9000 - 26.09.2010, 14:58
Re: respawning objects - by Mauzen - 26.09.2010, 15:06
Re: respawning objects - by 3ventic - 26.09.2010, 15:07
Re: respawning objects - by Face9000 - 26.09.2010, 15:23
Re: respawning objects - by Cameltoe - 26.09.2010, 15:28
Re: respawning objects - by Mauzen - 26.09.2010, 15:29
Re: respawning objects - by Face9000 - 26.09.2010, 15:48

Forum Jump:


Users browsing this thread: 1 Guest(s)