Jump to content
Sign in to follow this  
tavtavtav

Automatic Eject Script

Recommended Posts

Is there a script or addon that makes it so that when a plane has reached 100% damage instead of turning into a ball of fire it automatically ejects the player or the player survives so that a whole new avenue of play is possible after getting stranded in enemy territory. I say 100% because if a missile hits , depending on your hull strength left you just get destroyed instead of only a small percentage.

Also can it be tied to the player so that if i get in a new plane in happens again. (otherwise i'd just have to respawn the plane at base)

Share this post


Link to post
Share on other sites

Hi.... This little script will make you invincible once inside a vehicle and then when the vehicle can no longer move you will be ejected and your ability to take damage restored.

I've called the script "test.sqf"...you can call it whatever you want.

Create a file in your mission folder called "test.sqf"... add the following lines to the file.

while {true} do {
if (vehicle player != player) then {
	player allowdamage false;
	if (not (canmove vehicle player)) then {
		UnAssignVehicle player;
		player action ["EJECT", vehicle player];
		player allowdamage true;
	};
};
sleep 1;
};

In your players init add this:-

nul = [this] execVM "test.sqf";

If your player starts off in a vehicle add it to the vehicles init. It still works.

If you don't want to be invincible while in the vehicle remove the two (2) lines with player allowdamage.

Share this post


Link to post
Share on other sites

Thankyou this is actually perfect i was thinking exactly along the lines of this. many thanks.

---------- Post added at 04:46 PM ---------- Previous post was at 04:14 PM ----------

oh man its not working.. :(

Share this post


Link to post
Share on other sites

Dont want to hijack this thread but is there a way to make a player invincible when in a heli and for a while after he gets out i.e time to get away from the helli explosion.

Looking for if a pilot gets shot down he will suvive so has to get back from enemy lines !

@ tavtavtva the above does work ok it ejects me when i get hit by an AA pod ?!

Edited by psvialli

Share this post


Link to post
Share on other sites

@tavtavtav..... it should work because I tested it in a helicopter and got ejected when the vehicle was hit and could no longer fly!

@psvialli.... maybe something like this....change the sleep to whatever you need.

while {true} do {
if (vehicle player != player) then {
	player allowdamage false;
	if (not (canmove vehicle player)) then {
		UnAssignVehicle player;
		player action ["EJECT", vehicle player];
                       [b][color="Red"]waituntil {getpos player select 2 < 1};
                       sleep 5;[/color][/b]
		player allowdamage true;
	};
};
sleep 1;
};

Share this post


Link to post
Share on other sites

Go ahead I don't mind you hijacking it can help me. I'm going to try it in a helicopter since I only did it in a harrier and a lightning II which are both fixed wing. am I right to put the code in notepad and save as test.sqf?

Seems almost that there is underlining code that auto kills when damage 1 on vehicle but it works for others so there probably isn't.

I'm trying the code as a trigger

With everything from player action as the on act.

Thanks for the help so far :D I can't test it till about 19 hours from now sadly.

Edited by tavtavtav

Share this post


Link to post
Share on other sites

I just tested with a Harrier and a C-130 and it didn't work. Hmmm.... will have to do some fiddling and get back! ...maybe add an EventHandler to deal with damage.

Share this post


Link to post
Share on other sites

cly_autoeject.sqf

/*
Auto eject script by Celery
Player automatically ejects when his plane is destroyed.
Execute in init script with execVM "cly_autoeject.sqf";
*/

while {true} do {
_vehicle=vehicle player;
if (_vehicle isKindOf "Plane") then {
	player allowDamage false;
	_vehicle addEventHandler [
		"HandleDamage",
		{
			_vehicle=_this select 0;
			_damage=_this select 2;
			if (_this select 1=="" and _damage>0.9 and !isNull player) then {
				if (player in _vehicle) then {
					if (_this select 3 in [_vehicle,player]) then {
						player allowDamage true;
						player setDamage 1;
					} else {
						player action ["Eject",_vehicle];
					};
				};
			};
			_damage;
		}
	];
	waitUntil {sleep 0.1;_vehicle!=vehicle player};
	sleep 0.5;
	player allowDamage true;
	_vehicle removeEventHandler ["HandleDamage",0];
};
sleep 0.5;
};

Execute in init script with execVM "cly_autoeject.sqf";

Edited by Celery

Share this post


Link to post
Share on other sites

trying it now.

---------- Post added at 11:42 PM ---------- Previous post was at 11:32 PM ----------

type script expected nothing :/

Share this post


Link to post
Share on other sites

Execute in init script (init.sqs/init.sqf) with execVM "cly_autoeject.sqf";

Share this post


Link to post
Share on other sites

Ok thanks I'll try in the morning . And if you have time for future reference can you tell me how the yuppie scripts work please? Unless its to long complicated and time consuming.

Share this post


Link to post
Share on other sites

Back! :)

I see Celery posted a good script there... but was working on this so thought I might as well get it on here.

This script will keep you alive (invincible) in any vehicle. Once the vehicle is destroyed you will be ejected.

If you end up in chute you will stay invincible until 5 seconds after you reach the ground.

If you are in a ground vehicle....you will stay invincible for 5 seconds after you are ejected.

superdriver.sqf

/*

superdriver.sqf - twirly 11th Sept 2011
Execute from init.sqf or players init
Execute with: nul = [] execVM "superdriver.sqf";
Works with any vehicle and not limited to the driver/pilot

*/
private ["_veh"];

TWIRL_SuperDrvrEHset = false;

while {true} do {
if (vehicle player != player) then {
	_veh = vehicle player;
	if (not TWIRL_SuperDrvrEHset) then {
		//hint "EH added";
		//sleep 1;
		vehicle player addEventHandler
			["Hit",{nul = [_this select 0]
				spawn {
					private ["_veh"];
					_veh = _this select 0;
					if (not (canmove _veh) or not (alive _veh) and (vehicle player) != player) then {
						_veh removeAllEventHandlers "Hit";
						player action ["EJECT", _veh];
					};
				};
			}
		];
		player addEventHandler ["handleDamage", {false}];
		titleText ["Invincibility ON","plain down"];
		TWIRL_SuperDrvrEHset = true;
	};
} else {
	if (vehicle player == player and TWIRL_SuperDrvrEHset) then {
		waituntil {getpos player select 2 < 1};
		sleep 5;
		player addEventHandler ["handleDamage", {true}];
		_veh removeAllEventHandlers "Hit";
		titleText ["Invincibility OFF","plain down"];
		TWIRL_SuperDrvrEHset = false;
	};
};
sleep 1;
};

Execute from init.sqf or players init with:-

nul = [] execVM "superdriver.sqf";

EDIT: Code updated.

Edited by twirly
Updated code

Share this post


Link to post
Share on other sites

I just get errors running it from init.sqf with nul = [] "superdriver.sqf";

Using nul = execvm "superdriver.sqf"; with no problem.

Handy script, thanks :)

Share this post


Link to post
Share on other sites
I just get errors running it from init.sqf with nul = [] "superdriver.sqf";

Using nul = execvm "superdriver.sqf"; with no problem.

Haha... yeah. I have no idea what I was thinking. I copied and pasted from the comment section at the top of the script which was also "unfinished". Thanks for the heads up.

Post above fixed.

Share this post


Link to post
Share on other sites
cly_autoeject.sqf

/*
Auto eject script by Celery
Player automatically ejects when his plane is destroyed.
Execute in init script with execVM "cly_autoeject.sqf";
*/

while {true} do {
_vehicle=vehicle player;
if (_vehicle isKindOf "Plane") then {
	player allowDamage false;
	_vehicle addEventHandler [
		"HandleDamage",
		{
			_vehicle=_this select 0;
			_damage=_this select 2;
			if (_this select 1=="" and _damage>0.9 and !isNull player) then {
				if (player in _vehicle) then {
					if (_this select 3 in [_vehicle,player]) then {
						player allowDamage true;
						player setDamage 1;
					} else {
						player action ["Eject",_vehicle];
					};
				};
			};
			_damage;
		}
	];
	waitUntil {sleep 0.1;_vehicle!=vehicle player};
	sleep 0.5;
	player allowDamage true;
	_vehicle removeEventHandler ["HandleDamage",0];
};
sleep 0.5;
};

Execute in init script with execVM "cly_autoeject.sqf";

I see you are using isKindOf "Plane" does that work for Heli as well if not what would it be , as looking for it top work on Just heli.

Thanks

Share this post


Link to post
Share on other sites

(_vehicle isKindOf "Plane") -> (_vehicle isKindOf "Plane" or (_vehicle isKindOf "Helicopter" and !(_vehicle isKindOf "ParachuteBase")))

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  

×