Jump to content

[WIP] Eject Players From Vehicles


Recommended Posts

Hello Epoch Forums! A user in another thread was asking about a way to force someone from your vehicle so I decided to try and work something up. This script waits until a player gets into a vehicle as driver then gives them an option to eject any other player in the vehicle who is not tagged as friendly to them. I labeled this as a WIP because I am still testing it but it seems to be doing the job. The one thing I have noticed is that if you get into a vehicle as driver and another player gets in as passenger, then you later tag each other as friendly, you will still have the option to eject that player from that vehicle only. 

 

You will need a custom variables.sqf and a custom fn_selfactions.sqf for this mod. If you don't have these files and do not know how to use them you can find tutorials on custom files here on the epoch forums. Google is also a great place to learn about custom files.
 

Step 1:
Open your custom variables.sqf and add these three lines:

s_player_driver_eject = -1;

Eject_Array = [];
Player_Vehicle_Crew_Count=0;
 

Step 2:
Open your fn_selfactions.sqf and add the following to the very bottom of the file:

_driver = driver _vehicle;
 
if(_inVehicle && (_driver == player)) then {
_rideAR=nearestObjects[player, ["Ship","Air","LandVehicle"], 25];
_ride=_rideAR select 0;
_player_name = name player;
if((name _ride)!="") then {
_ride setVehicleVarName "CurrentRide"+_player_name;
};
_crew=crew _vehicle;
_crew=_crew-[player];
 
if(Player_Vehicle_Crew_Count != (count _crew)) then {
Player_Vehicle_Crew_Count=(count _crew);
 
if((count Eject_Array)>0) then{
{_ride removeAction _x} forEach Eject_Array;
};
Eject_Array=[];
_eject_text="";
_counter=0;
_crew_name="";
_friendlies = player getVariable ["friendlyTo",[]];
 
{
_crew_name=name _x;
_crewID = _x getVariable["CharacterID","0"];
if(_crewID in _friendlies) then {} else {
_eject_text=format ["Eject %1",_crew_name];
s_player_driver_eject = _vehicle addaction[_eject_text,"custom\eject.sqf",[_x,_ride],0,false,true,"", "(driver _target)==player"];
Eject_Array set[_counter, s_player_driver_eject];
_counter=_counter + 1;
};
 }forEach _crew;
};
 
}else {
{_ride removeAction _x} forEach Eject_Array;
Eject_Array=[];
Player_Vehicle_Crew_Count=0;
};

 

 

 

Step 3:
Create a folder in your mission called custom. Inside that folder create a new file called eject.sqf . Place the following code into that file and save it.

_target= (_this select 3) select 0;
_ride= (_this select 3) select 1;
 
_target action ["eject", _ride];

If you find any bugs or errors please let me know!

Link to comment
Share on other sites

  • 2 weeks later...

soo anyone good enough to make this eject player maybe 250 meter in air and open chute ???

 

like this maybe(probably not)

 

_target= (_this select 3) select 0;
_ride= (_this select 3) select 1;


_target action ["eject", _ride];


player setPosATL [ getPosATL player select 0, (getPosATL player select 1) + 250, getPosATL player select 2];
if (dayzPlayerLogin2 select 2) then
        {
            [player, 250] spawn bis_fnc_halo;
        };
Link to comment
Share on other sites

kinda works but now correctly

now trying

last script ejected both players in air

 

_target= (_this select 3) select 0;
_ride= (_this select 3) select 1;




_target action ["eject", _ride];




player setPosATL [ getPosATL player select 0, (getPosATL player select 1) + 800, getPosATL player select 2];
if (dayzPlayerLogin2 select 2) then
        {
            [_target, 800] spawn bis_fnc_halo;
        };

found this 

https://resources.bisimulations.com/w/index.php?title=setPosATL

 

Link to comment
Share on other sites

I'll test it out on my test server, is there anyway to have this only work in safezones?

You could use the variable already in the safezone trigger and wrap the code in fn_selfActions with

if(inSafeZone==true) then {

 

 

};

 

 

soo anyone good enough to make this eject player maybe 250 meter in air and open chute ???

 

like this maybe(probably not)

 

_target= (_this select 3) select 0;
_ride= (_this select 3) select 1;


_target action ["eject", _ride];


player setPosATL [ getPosATL player select 0, (getPosATL player select 1) + 250, getPosATL player select 2];
if (dayzPlayerLogin2 select 2) then
        {
            [player, 250] spawn bis_fnc_halo;
        };

 

You would want to change player with _target maybe?

Link to comment
Share on other sites

  • 9 months later...
Private["_rideAR","_ride"];
 
_driver = driver _vehicle;
if (isNil "s_player_driver_eject") then
{s_player_driver_eject = -1};
if(_inVehicle && (_driver == player)) then {_rideAR = nearestObjects[player, ["Ship","Air","LandVehicle"], 25];
........
.......
.{{_ride removeAction _x} forEach Eject_Array;
Eject_Array=[];
Player_Vehicle_Crew_Count=0;
player removeAction s_player_driver_eject;
s_player_driver_eject = -1;
};
Link to comment
Share on other sites

  • 2 months later...

tested this today and didn't see any actions sticking around. Can anyone else verify this? The else statement should be stripping all the actions as soon as you get out.

So I tried this, the actions do not stick around when you exit the vehicle, but when you get back in, they are back, even if the other player is no longer in the vehicle...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...