Forum Jump :

Author Message


Posts: 508
Rank:


Level: Member

Country: se
Location:
Occupation:
Age: 24
In-game name: Oksman

 
#1 Posted at 2012-07-08 22:50        
     
Hello guys stumbled upon a little problem when asked about doing something to a unit when it respawns.
In this case, move into a cargo space of a vehicle.

We'll say we have an MHQ,what I wanted to do was spawn respawns into the MHQ.

What I came up with was naming all my units s1,s2,s3,s4,s5,s6,s7... and I ran this script in the init.sqf

_unit = [s1,s2,s3,s4....];
{null = [_X] execVM "respawntest.sqf]}foreach  _unit;

and this then is the respawntest.sqf
_unit = _this select 0;
_vehicle = _this select 1;

waitUntil {!alive _unit};
waitUntil {alive _unit};
_unit moveincargo _vehicle;
Sleep .1;
null = [_unit,_vehicle] execVM "respawntest.sqf";

Now for some reason that doesn't work. In my eyes it should work considering it uses waituntil, I'm not sure what the problem might be.

Appreciate any help!

Regards Oksman


Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#2 Posted at 2012-07-09 10:49        
     
{null = [_X] execVM "respawntest.sqf]}foreach _unit; // missing "

You would be better assigning a killed eventhandler.
{null=[_x] addeventhandler ["killed",{_this execVM "respawntest.sqf"}]} foreach playableunits;

Also, your vehicle is not defined on the first call to this script.
Or even afterward, if the killed unit is not in a vehicle. Define the _vehicle
_vehicle = whatever_you_named_it_in_the_editor;
You may have to unassign the unit from any possible vehicle first, then assiganasCargo to the new vehicle, then moveInCargo.

Or take a look at this presaveloadout eventhandler script
http://www.armaholic.com/forums.php?m=posts&q=15970
which could be edited to achieve the result you are after
(called from the init.sqf with simply execVM "PreSavedLoadout.sqf";)

....that's all folks....!

Advertisement


Author Message


Posts: 508
Rank:


Level: Member

Country: se
Location:
Occupation:
Age: 24
In-game name: Oksman

 
#3 Posted at 2012-07-09 15:16        
     
Thanks mate, checked it and it was only my typo here on armaholic, the script is basically.

Init
_unit = [s1,s2,s3,s4....];
{null = [_X,vehicle1] execVM "respawntest.sqf"]}foreach _unit;

Respawntest.sqf
_unit = _this select 0;
_vehicle = _this select 1;

hint "Activated";
waitUntil {!alive _unit};
hint "Dead";
waitUntil {alive _unit};
hint "Respawned";
_unit moveincargo _vehicle;
Sleep 10;
null = [_unit,vehicle1] execVM "respawntest.sqf";

Basically this script doesn't even get to hint "Activated". So it's not being activated or something within is broken, I'm not sure of the use of waitUntil as I've never used it before. Changed the script to restart with the fixed vehicle name. Yet this is without luck, so I went into eventhandlers.

This is what I did.

Init of unit
this addeventhandler ["Killed",{null = [this,vehicle1] execVM "respawntest.sqf"}];

The new respawntest.sqf
_unit = _this select 0;
_vehicle = _this select 1;

hint "Activated";
waitUntil {alive _unit};
hint "Respawned";
unassignVehicle _unit;
_unit moveincargo _vehicle;
_unit assignascargo _vehicle;

This also does not work, sadly. I Have no idea what I'm gonna do since in my eyes the script is perfectly fine! Don't get it ^^


Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#4 Posted at 2012-07-09 17:31        
     
Hmmm..I couldn't work out why not either, but this does work.
I just hope it only works on the individual Player and not all players if one is killed.

In your init.sqf
execVM "respawntest.sqf";

player addEventHandler ["Killed",{
player spawn {

_unit = _this;

hint "Activated";
hideBody _unit;
sleep 2;
deleteVehicle _unit;

WaitUntil{alive player};

hint "Respawned";
unassignVehicle player;
player assignascargo vehicle1;
player moveincargo vehicle1;

};
}];

....that's all folks....!

Author Message


Posts: 508
Rank:


Level: Member

Country: se
Location:
Occupation:
Age: 24
In-game name: Oksman

 
#5 Posted at 2012-07-09 22:08        
     
Roger I'll give it a shot

Tested it out and it worked for one player, the main player.
I hosted a client host and with one mate.

I only got it to work for one unit, the other player did not get any hints nor did he spawn inside the vehicle.

After that I tried modifying it and defininng the actualy unit and running it from their own init. This did not work and I believe it's not possible to use variables such as waitUntil{alive _unit}

I don't think it works with that, so I'm still wondering how this is fixed. Doesn't seem like a very tough problem but it sure is a hard nut to crack.

This post was edited by Oksman (2012-07-09 22:51, ago)


Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#6 Posted at 2012-07-10 00:51        
     
The problem is because once the _unit is dead, any reference to it is null.
The waituntil is ok, it's not that anyway. I'll keep working on it....
You could try the same script, but in the init.sqf
{null = [_x] execVM "respawntest.sqf"}foreach PlayableUnits;

....that's all folks....!

Author Message


Posts: 508
Rank:


Level: Member

Country: se
Location:
Occupation:
Age: 24
In-game name: Oksman

 
#7 Posted at 2012-07-10 01:14        
     
Right, appreciated mate.

I'll look further into it as well, definitely something that's not supposed to be hard just became hard :x


Author Message


Posts: 8
Rank:


Level: Member

Country: ch
Location:
Occupation:
Age: 23
In-game name: Dawnthief

 
#8 Posted at 2013-01-29 20:35        
     
Well it's nearly a year since the last post in this thread but I'm just going to ask. I'm sitting in front of my PC, with a mission, in which all players should respawn in a C130J, which is cycling (with a AI as Pilot) over the Objectivs. The players are supposed to jump out when they think, they are close enough. I already tried to use a repeadely trigger with the following:

Condition:
not alive player;

On Act.
TitleCut ["Wait!!!","BLACK OUT",3]

On Dea.
player moveInCargo [c130j,6]; TitleCut ["Let's go","BLACK IN",3]

The problem when I'm in the C130, I can access the Gear, get a Parachute Pack (Mission is with ACE) but I can't jump out. I can click "To Pilot Seat" even if there is a AI Pilot in it.

Well, I would appreciate it, if someone has a soulution for this.

Incoming bullets have the right of way....