Jump to content
Sign in to follow this  
near_blind_sniper

Move player into vehicle on respawn

Recommended Posts

Hello all.

I'm trying to throw together a script for MP that allows a mission commander to force players in spectator to respawn and be placed in a spawned helicopter that will then deposit them at a location of the commander's choosing. So far I've got everything working except when the player respawns. They spawn on respawn_west marker, but aren't moved to the chopper.

I'm using the "BASE" type respawning, and I've tried using both a respawn event handler and onPlayerRespawn.sqf to no avail. I'm at work so I can't post my code, but I can once I get home if that helps.

Thanks.

EDIT:

Figured it out. The command to respawn was firing before clients computers were aware the server spawned vehicle existed.

Edited by near_blind_sniper

Share this post


Link to post
Share on other sites

player addMPEventHandler ["Respawn", {player moveInDriver car1};];

Something like that, I am not on the PC right now. I suggest you simply google "addEventHandler arma 3", there should be heaps of info. (Especialy on community.bistudio.com )

Share this post


Link to post
Share on other sites
player addMPEventHandler ["Respawn", {player moveInDriver car1};];

Something like that, I am not on the PC right now. I suggest you simply google "addEventHandler arma 3", there should be heaps of info. (Especialy on community.bistudio.com )

Alright, I'll test it later. Thanks :D

Share this post


Link to post
Share on other sites

Hi, I have a related issue.

I want my players to be respawned in veh1 or veh2 or if both vehicles are destroyed at respawn_east marker.

In player's init I have written:

this addEventHandler ["RESPAWN", this execVM "scripts\rspwn.sqf"];

In rspwn.sqf I have written:

hint "START rpswn.sqf";

sleep 0.5;

_unit = _this select 0;

switch (true) do

{

case ( alive veh1 && alive veh2) : {_unit moveInCargo veh1;};

case (!alive veh1 && alive veh2) : {_unit moveInCargo veh2;};

case (!alive veh1 && !alive veh2) : {_unit setPos (getMarkerPos "respawn_east");};

};

_unit addEventHandler ["RESPAWN", this execVM "scripts\rspwn.sqf"];

sleep 2;

hint "END rspwn.sqf";

First thing that confuses me, is that the Eventhandler RESPAWN executes the script straight after mission start.

( I get the first hint, the second one does not show up )

I thought it would fire only after respawn?

Second thing is, that the script probably is pathetically wrong?

Respawn itself is working, I get respawned at respawn_east.

Thanks for a helping hand!

Share this post


Link to post
Share on other sites
Hi, I have a related issue.

I want my players to be respawned in veh1 or veh2 or if both vehicles are destroyed at respawn_east marker.

In player's init I have written:

In rspwn.sqf I have written:

First thing that confuses me, is that the Eventhandler RESPAWN executes the script straight after mission start.

( I get the first hint, the second one does not show up )

I thought it would fire only after respawn?

Second thing is, that the script probably is pathetically wrong?

Respawn itself is working, I get respawned at respawn_east.

Thanks for a helping hand!

init:

player addEventHandler ["RESPAWN", {_this execVM "scripts\rspwn.sqf"}];

rspwn.sqf:

sleep 0.5;


if (alive veh1 && alive veh2) then
{
_vehicleSel = player moveInDriver [veh1, veh2] call BIS_fnc_selectRandom;
}
else
{
player setPos (getMarkerPos "respawn_east");
};


player addEventHandler ["RESPAWN", {_this execVM "scripts\rspwn.sqf"}];

If you want it to be MP compatible, change the code in both scripts

player addEventHandler ["RESPAWN", {_this execVM "scripts\rspwn.sqf"}];

to

player addMPEventHandler ["MPRespawn", {_this execVM "scripts\rspwn.sqf"}];

Hope it helps, ;)

Rawner135

Share this post


Link to post
Share on other sites

Thanks for the response Ranwer.

Tested below code on local dedicated server and it seems to work as wanted.

/*
add to player's init, EventHandler stays attached to player's unit after death/respawn:
this addEventHandler ["RESPAWN",{_this execvm  "scripts\rspwn.sqf"}];
*/

sleep 0.5;
private ["_unit"];
_unit = _this select 0;

switch (true) do 
{
case (alive veh1 &&  veh1 emptyPositions "cargo" > 0) : {_unit moveInCargo veh1;};
case (alive veh2 &&  veh2 emptyPositions "cargo" > 0) : {_unit moveInCargo veh2;};
case (!(veh1 emptyPositions "cargo" > 0) && !(veh2 emptyPositions "cargo" > 0)) : {_unit setPos (getMarkerPos "respawn_east");};
case (!alive veh1 && !alive veh2) : {_unit setPos (getMarkerPos "respawn_east");};
};

Share this post


Link to post
Share on other sites

First thing that confuses me, is that the Eventhandler RESPAWN executes the script straight after mission start.

( I get the first hint, the second one does not show up )

I thought it would fire only after respawn?

You can adjust this behaviour in description.ext (at least I assume this is what's happening... have not tested it myself with an EH just using onPlayerRespawn.sqf)

respawnOnStart = 1;   //Respawn on start. Run respawn script on start.
respawnOnStart = 0;   //Dont respawn on start. Run respawn script on start.
respawnOnStart = -1;  //Dont respawn on start. Don't run respawn script on start.

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
Sign in to follow this  

×