How can I do object respawn - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How can I do object respawn (
/showthread.php?tid=321170)
How can I do object respawn -
Jin - 26.02.2012
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
Re: How can I do object respawn -
FalconX - 26.02.2012
Quote:
Originally Posted by Jin
|
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
Re: How can I do object respawn -
Jin - 26.02.2012
I'm new can you give me more information
Re: How can I do object respawn -
FalconX - 26.02.2012
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