Jump to content
Cryptdik

Respawn in new vehicle

Recommended Posts

Trying to make it so you respawn in a jet. I have this in the player's init and a marker called "respawnmarker1".

this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 10000, "FLY"]; this moveInDriver jet1;}]

 

This doesn't cause anything to happen on respawn, though.

Share this post


Link to post
Share on other sites
this addEventhandler ["respawn", 
{
 params ["_unit"];
 jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 10000, "FLY"];
 _unit moveInDriver jet1;
}];

 

Share this post


Link to post
Share on other sites
this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 20, "FLY"]; (_this select 0) moveInDriver jet1;}];

 

Share this post


Link to post
Share on other sites

As stated here, _this isn't an object but an array with [your new controlled object, your previous object]. You have to "extract" the data from _this.

Share this post


Link to post
Share on other sites
3 hours ago, zgmrvn said:

As stated here, _this isn't an object but an array with [your new controlled object, your previous object]. You have to "extract" the data from _this.

for the event handler, sure. I guess if the player was defined outside of the event handler then _this would work as long as there were no other parameters passed correct?

Share this post


Link to post
Share on other sites
6 minutes ago, Midnighters said:

for the event handler, sure. I guess if the player was defined outside of the event handler then _this would work as long as there were no other parameters passed correct?

Not exactly. EH passes default parameters. So, an array for _this, anyway.

Share this post


Link to post
Share on other sites
1 minute ago, pierremgi said:

Not exactly. EH passes default parameters. So, an array for _this, anyway.

Right, i mean outside the eh

_this addEventHandler["Respawn",{(event handler params are valid here}]; (not out here) 

 

  • Like 1

Share this post


Link to post
Share on other sites

Ah ok. In a player's init field, you must refer to this (global variable) not to _this, which is a local one, not acceptable in this context.

But you can do: this spawn {_unit = _this; <any code with _unit>} . Not useful for an EH, but for any code with scheduled sequence like sleep, waitUntil...

Share this post


Link to post
Share on other sites
1 minute ago, pierremgi said:

Ah ok. In a player's init field, you must refer to this (global variable) not to _this, which is a local one, not acceptable in this context.

Right, okay. Thanks for the info. Didn't realize this was a init field, personally I stray away from that.

Share this post


Link to post
Share on other sites
7 hours ago, pierremgi said:

Ah ok. In a player's init field, you must refer to this (global variable) not to _this, which is a local one, not acceptable in this context.

But you can do: this spawn {_unit = _this; <any code with _unit>} . Not useful for an EH, but for any code with scheduled sequence like sleep, waitUntil...

Does this mean I should simply name the player unit player1 and use "player1 moveinDriver jet1"? That way it doesn't get hung up on the _this or whatever.

Meaning:

player1 addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 10000, "FLY"]; player1 moveInDriver jet1;}]

 

Edit: Nope, this for some reason makes it so that my normally working Respawn Point module doesn't work so it points your map at the bottom left corner of the map.

Share this post


Link to post
Share on other sites

Update: I have it working, but with a problem. I now have this

:

Respawn Point Module - only respawn so player is forced to spawn there, set to Infantry so they can spawn.

 

player1 init: 

this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 20, "FLY"]}];

 

Trigger that encompasses spawn area set to BLUFOR PRESENT

condition: this && isNil "myVariable"

onact: player1 moveinDriver jet1; myVariable = true

ondeact: 0 = [] spawn {sleep 1; myVariable = nil}

 

This way I should be able to make the same set up for each of 1-4 players, but the problem is that you spawn, see where you are on the ground, then after a second it places you in a plane. I want to get around this by masking it with a black screen fade in, how would I do this.

 

Edit: I have this now in the trigger onAct

titleText ["", "BLACK IN", 1.5]; player1 moveinDriver jet1;  myVariable = true

but it still shows the players first spawn position (you're standing at the spot outside of the vehicle) and THEN does a black screen fade in to the jet :(

Share this post


Link to post
Share on other sites

Read the last Seafood post. It works perfectly. You don't need any trigger. Just a workable "respawn_something" marker (or respawn module), the respawn attributes on "custom position", and the (_this select 0) in EH to be sure you're selecting the new player and not the corpse!

just add the isServer condition:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawnmarker1", [], 1000, "FLY"]; (_this select 0) moveInDriver jet1}]}

 

  • Like 1

Share this post


Link to post
Share on other sites

I made this:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawn_west1", [], 1000, "FLY"]; (_this select 0) moveInDriver jet1}]}

And made an Empty marker called "respawn_west1"

 

It spawns me on the ground and the plane spawns empty :(

Share this post


Link to post
Share on other sites
5 minutes ago, Cryptdik said:

I made this:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawn_west1", [], 1000, "FLY"]; (_this select 0) moveInDriver jet1}]}

And made an Empty marker called "respawn_west1"

 

It spawns me on the ground and the plane spawns empty :(

*facepalm* because respawn_west1 is going to be still picked up by the respawn system, doesn't matter what number is after it.

rename it.

Share this post


Link to post
Share on other sites
26 minutes ago, Midnighters said:

*facepalm* because respawn_west1 is going to be still picked up by the respawn system, doesn't matter what number is after it.

rename it.

Did that on purpose, since I need a place to spawn to initially since respawn is set to "Select Respawn Position" or whatever so I can have multiple spawn points to choose from that do this same thing.

I tried making a second marker named planemarker1 as well so you respawn at the respawn_west marker and then it should create the vehicle at planemarker1.

I still spawn outside of the plane so it's a problem with "(_this select 0) moveInDriver jet1" i think. Is it not selecting the player properly?

 

It reads this now:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "planemarker1", [], 1000, "FLY"]; _vel1 = velocity jet1; jet1 setDir 45; jet1 setVelocity _vel1; (_this select 0) moveInDriver jet1}]}

Share this post


Link to post
Share on other sites
2 hours ago, Cryptdik said:

I made this:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawn_west1", [], 1000, "FLY"]; (_this select 0) moveInDriver jet1}]}

And made an Empty marker called "respawn_west1"

 

It spawns me on the ground and the plane spawns empty :(

That work for me. But I used it in vanilla and nothing more than the player and the marker.

If this same code doesn't work for you, there is probably something which interfere with the scheduler and/or the EH. Too much scripts?

So try this version, always in init field of the unit:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawn_west1", [], 1000, "FLY"]; (_this select 0) spawn {waitUntil {!isNull jet1}; _this moveInDriver jet1} }]}

 

  • Like 1

Share this post


Link to post
Share on other sites
47 minutes ago, pierremgi said:

That work for me. But I used it in vanilla and nothing more than the player and the marker.

If this same code doesn't work for you, there is probably something which interfere with the scheduler and/or the EH. Too much scripts?

So try this version, always in init field of the unit:

if (isServer) then {this addEventhandler ["respawn", {jet1 = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "respawn_west1", [], 1000, "FLY"]; (_this select 0) spawn {waitUntil {!isNull jet1}; _this moveInDriver jet1} }]}

 

Awesome that works perfectly. Weirdly though I was doing this on an empty mission just to test it with no mods or anything. Thanks!!

Share this post


Link to post
Share on other sites
1 hour ago, Cryptdik said:

Awesome that works perfectly. Weirdly though I was doing this on an empty mission just to test it with no mods or anything. Thanks!!

Yep sometime objects/units have a little delay to "spawn" and be completed. Same for group creation with BIS_fnc_spawnGroup. On "heavy" environment units will spawn visibly separately (you can see that) and furthermore, they will acquire their side (specified by the function) with another small delay.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×