Respawning objects?
#1

How can i get objects to respawn after they're been destroyed?

For instance.

A barrel gets blown up, then a few mins later it respawns in the same place.

I dont want to auto spawn a barrel every so often on a timer, because i dont want then all piled on eachother.

Just 1 barrel, and if its there, nothing happens, if its been destroyed another one is spawned in its place.

How can i do this?
Reply
#2

Quote:
Originally Posted by Outbreak
I dont want to auto spawn a barrel every so often on a timer, because i dont want then all piled on eachother.
Why not use DestroyObject first ?
Reply
#3

ah yeah, that would work. Destroy then create every so often, thanks
Reply
#4

I got this working, destroying and re-creating every minute. It worked perfectly fine on my home test server..

I uploaded it to my rented server and restarted it.

It seemed fine but then when one person joined, it would not let anyone else join, all it would say is Connected to Network, Loading Game...

If two actually managed to get in the server it would restart in a very short time.

Also when i checked the CPU usage it was around 0 - 4%

Then it jumped to 99 - 101%

here the code, its crappy i know, i couldn't really figure how to do it more efficient, so that it would run smooth and not drain the CPU.

pawn Код:
new ATMmachine[11];

stock ATMSpawner()
{
ATMmachine[0] = CreateStreamedObject(2942, 2003.497, -2352.371, 13.19, 0, 0, -90);
ATMmachine[1] = CreateStreamedObject(2942, 2003.683, -2280.22, 13.19, 0, 0, -90);
ATMmachine[2] = CreateStreamedObject(2942, -1974.457, 169.655, 27.287, 0, 0, -540);
ATMmachine[3] = CreateStreamedObject(2942, -2715.579, 210.804, 3.971, 0, 0, -630);
ATMmachine[4] = CreateStreamedObject(2942, -2453.688, 754.936, 34.815, 0, 0, -720);
ATMmachine[5] = CreateStreamedObject(2942, -1427.802, 2591.614, 55.479, 0, 0, -180);
ATMmachine[6] = CreateStreamedObject(2942, -180.7, 1036.35, 19.41, 0, 0, -90);
ATMmachine[7] = CreateStreamedObject(2942, -856.526, 1528.602, 22.23, 0, 0, -270);
ATMmachine[8] = CreateStreamedObject(2942, 147.777, -1865.438, 3.416, 0, 0, -270);
ATMmachine[9] = CreateStreamedObject(2942, 2334.29, 58.78, 26.127, 0, 0, -270);
ATMmachine[10] = CreateStreamedObject(2942,2000.658,1525.084,14.243,0.0,0.0,-180.000);
return 1;
}

stock ATMDestroyer()
{
    DestroyStreamedObject(ATMmachine[0]);
    DestroyStreamedObject(ATMmachine[1]);
    DestroyStreamedObject(ATMmachine[2]);
    DestroyStreamedObject(ATMmachine[3]);
    DestroyStreamedObject(ATMmachine[4]);
    DestroyStreamedObject(ATMmachine[5]);
    DestroyStreamedObject(ATMmachine[6]);
    DestroyStreamedObject(ATMmachine[7]);
    DestroyStreamedObject(ATMmachine[8]);
    DestroyStreamedObject(ATMmachine[9]);
    DestroyStreamedObject(ATMmachine[10]);
    return 1;
}
   

forward ATM_Update();
public ATM_Update()
{
    ATMDestroyer();
    ATMSpawner();
}
I've got a timer in OnGamemodeInit

pawn Код:
SetTimer("ATM_Update", 60000, 1);

I know this is a pretty crap code, so how could i get it working better?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)