Home   Help Search Login Register  

Author Topic: Respawning in different locations  (Read 2113 times)

0 Members and 1 Guest are viewing this topic.

Offline Joiner

  • Members
  • *
Respawning in different locations
« on: 26 Nov 2009, 12:06:57 »
Hi everyone!
I'm making an MP mission in which the attacking side captures enemy territories and then respawns in each newly captured area. For this purpose, I use "moving" respawn points (via markers). However, the attacking side has a helicopter that supports the attacks, and after the attacking side captures one of the enemy areas, all the players of this side will respawn in that zone, including the pilots of the helicopter. What I need to do is to make it possible to respawn the pilots on the main base, where the helicopter is, while the others must respawin in the newly captured areas. Is it possible to do that? Any example will be appreciated.
Also, is it possible to have players respawned in vehicles? E.g. players respawn in a heli in the cargo place and then make a HALO.
Thanks in advance!

Offline Fincuan

  • Members
  • *
Re: Respawning in different locations
« Reply #1 on: 26 Nov 2009, 16:15:24 »
What you could do is to respawn everyone at plaze xyz, somewhere remote where they won't affect the mission OR somewhere where most of them would respawn anyway, then setPos them to the correct location once they've spawned.

Ie. you'd put this to the pilots' init-lines:
Code: [Select]
if (local this) then
{
this addEventHandler ["Killed",{_this spawn "myRespawn.sqf"}];
};

myRespawn.sqf
Code: [Select]
if (local (_this select 0)) then
{
if (baseRespawn) then
{
waitUntil {alive player};
player setPos somePosition;
}
else
{
//whatever should happen if they don't spawn at base
};
};
just set the variable "baseRespawn" to true or false based on where you want the pilots to respawn.
« Last Edit: 26 Nov 2009, 16:17:57 by Fincuan »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Respawning in different locations
« Reply #2 on: 26 Nov 2009, 17:02:54 »
Norrins revive script can respawn you in many locations and its fairly simple to implement.
Xbox Rocks

Offline Joiner

  • Members
  • *
Re: Respawning in different locations
« Reply #3 on: 26 Nov 2009, 19:38:17 »
I did as you sugested, but it looks like the script does't work... I use the following:
Code: [Select]
if (local (_this select 0)) then
{
if (baseRespawn) then
{
waitUntil {alive player};
player setPos (getPos h1);
}
else
{

};
};

h1 is the name of an object. What is supposed to be instead of baseRespawn?
« Last Edit: 26 Nov 2009, 21:14:04 by Joiner »

Offline Fincuan

  • Members
  • *
Re: Respawning in different locations
« Reply #4 on: 26 Nov 2009, 21:15:42 »
true or false. If it's true they respawn at base, if it's false they won't.

Offline Joiner

  • Members
  • *
Re: Respawning in different locations
« Reply #5 on: 26 Nov 2009, 21:51:39 »
Thanks, but the script still doesn't work. The pilots appear on the base along with the other players.
I used (baseRespawn = false) and (baseRespawn = true) - didn't help. Maybe because I use the F2 template (former BAS f)?   :dunno:

Offline Fincuan

  • Members
  • *
Re: Respawning in different locations
« Reply #6 on: 26 Nov 2009, 22:35:17 »
What exactly did you use? Post the exact code please. Also that snippet only works for human players.

Offline Joiner

  • Members
  • *
Re: Respawning in different locations
« Reply #7 on: 27 Nov 2009, 10:33:55 »
In the Init field of each pilot I entered the following:
Code: [Select]
if (local this) then
{
this addEventHandler ["Killed",{_this spawn "PilotRespawn.sqf"}];
};
Then I created the PilotRespawn.sqf file with the following code:
Code: [Select]
if (local (_this select 0)) then
{
if (baseRespawn = true) then
{
waitUntil {alive player};
player setPos (getPos h1);
}
else
{

};
};
in which h1 is the name of an object. Then when previewing the mission I, being a pilot, killed myself and I was respawned at the main base, not at the place where the h1 object is.

Offline Fincuan

  • Members
  • *
Re: Respawning in different locations
« Reply #8 on: 27 Nov 2009, 13:46:41 »
:)

like this:
Code: [Select]
baseRespawn = true;
if(baseRespawn) then
...

You must set it to true or false before the if-statement checks it, not inside the if. Of course you'd want to move the baseRespawn = true; to for example init.sqf, so that it doesn't get re-set to true every time a pilot respawns. Then whenever during the mission you want the pilots to stop respawning at the base you run this somewhere, for example a trigger: baseRespawn = false;

Offline Joiner

  • Members
  • *
Re: Respawning in different locations
« Reply #9 on: 27 Nov 2009, 21:33:05 »
Thanks a lot for your help, but it doesn't work for some reason...  :confused:
I'll try using Norrins revive script.