Jump to content

Exploding Heli Protection Script


ScaRR

Recommended Posts

Hey guys,

 

I created this script to deal with the issue where helicopter and vehicles sometimes explode when a player gets into the pilot seat or when the locality changes on the vehicle.

I have been running it on my server and it seems to be working OK and haven't had any noticeable FPS issues. 

 

You can adjust the sleep seconds to your liking but it works for me as it currently stands.

 

OX3_GetInProtect.sqf

/*
	File: OX3_GetInProtect.sqf
	Author: ScaRR
	Date: 2 June 2015
	Description: This script protects helis when a player gets close to a vehicles and the locality changes, at times this can cause a vehicle to explode or when the player 
	gets into the pilot seat.
	This script could possibly be optimised a bit more and needs further testing. 
	
	BE filters:
		
		setvariable.txt
			append !="added_EHProtect" !="GotIn" !="LocalChanged" 
		
		scripts.txt (note, your line numbers might differ
			line 22: append !="_x allowDamage true;" !="_vehicle allowDamage false"
			line 48: append !="_x setDamage 0;"
			if you get kicked for addEventHandler then add
			line 53: !="_x addEventHandler [\"GetIn\", {_this call fn_handleGetIn;}];" !="_x addEventHandler [\"Local\", {_this call fn_handleLocal;}];"
			
	Installation:
		Copy into your scripts folder, add this line to your init.sqf, execVM \"scripts\OX3_GetInProtect.sqf";
	
		
	PLEASE KEEP CREDITS - THEY ARE DUE TO THOSE WHO PUT IN THE EFFORT!	
*/

if(isServer) exitWith {};

fn_handleGetIn = {
	private ["_vehicle","_seat"];
	_vehicle = _this select 0;
	_seat = _this select 1;
	
	if(_seat == "driver")then{
		_vehicle setVariable ["GotIn",true];
		_vehicle allowDamage false;
		diag_log "[OX3] - Vehicle getin handled";
	};
};

fn_handleLocal = {
	private ["_vehicle","_local"];
	
	_vehicle = _this select 0;
	_local = _this select 1;
	_vehicle setVariable ["LocalChanged",true];
	_vehicle allowDamage false;
	diag_log "[OX3] - Vehicle local handled";
	
};

diag_log "[OX3] - Vehicle get in pilot protection";
while {true} do 
{
	
	{	
		if (!(_x getVariable ["added_EHProtect",false])) then {
			_x addEventHandler ["GetIn", {_this call fn_handleGetIn;}];
			_x addEventHandler ["Local", {_this call fn_handleLocal;}];
			_x setVariable ["added_EHProtect",true];
		 };
		
		if( (_x getVariable["GotIn",false])) then{
		 	sleep 3;
			_x allowDamage true;
			_x setVariable ["GotIn",false];
		};
		
		if( (_x getVariable["LocalChanged",false])) then{
		 	sleep 3;
			_x allowDamage true;
			_x setVariable ["LocalChanged",false];
		};
	}forEach vehicles;
	
	uiSleep 5;
};  

 

Installation instructions (also included in the file)

 

BE filters:

        
        setvariable.txt
            append !="added_EHProtect" !="GotIn" !="LocalChanged"
        
        scripts.txt (note, your line numbers might differ
            line 22: append !="_x allowDamage true;" !="_vehicle allowDamage false"
            line 48: append !="_x setDamage 0;"
            if you get kicked for addEventHandler then add
            line 53: !="_x addEventHandler [\"GetIn\", {_this call fn_handleGetIn;}];" !="_x addEventHandler [\"Local\", {_this call fn_handleLocal;}];"
            
    Installation:
        Copy into your scripts folder, add this line to your init.sqf, execVM \"scripts\OX3_GetInProtect.sqf";

 

 

Hope this helps. Please let me know of any issues.  :)

 

EDIT:

I removed the two setdamage lines from the script as they were causing some people BE kicks. They are not really required.

 

 

ScaRR 

Link to comment
Share on other sites

Added to my server, I'll let you know how i get on.

Thank you for taking the time to write and share this ScaRR :)

 

No problem at all. Looking forward to hearing from you  :)

I'll gladly update the script if required. 

Link to comment
Share on other sites

 

Got a wierd script res kick testing this

#20 " [0,1,4,5]) then {


if ({isplayer _x && alive _x} count playableunits == 0) then {
[["endDeath",false],"bis_fnc_endmission"] ca"

 

Hey, that code is not part of this script. It should tell which file it is in.

Link to comment
Share on other sites

Nice share Scarr and thanks for throwing it up in its own thread so others have a chance to see it.

Been about 36 hours and the reports of exploding choppers has virtually disappeared.

Of course when you tell your community to report all chopper explosions when entering there will be a slight influx to alert me of whats going on, but even so it is no where near what it has been in the past, but wasn't too bad in the recent weeks.

So to report, not one case of an exploding chopper was valid, all had other variables like hill and on its side already to PhysX issues.

To Conclude, Scarr FUCKIN A man Thank you very much for this script.

Our community also has sent many thanks as they have tested this out a lot by finding as many choppers as possible the last 36 hours.

Oh I would also like to throw in there that DP is running 74 out of 243 slots are choppers so high chopper numbers are ok with this script, too!

Thanks Mods for moving this to where it will be seen by even more

Link to comment
Share on other sites

Nice share Scarr and thanks for throwing it up in its own thread so others have a chance to see it.

Been about 36 hours and the reports of exploding choppers has virtually disappeared.

Of course when you tell your community to report all chopper explosions when entering there will be a slight influx to alert me of whats going on, but even so it is no where near what it has been in the past, but wasn't too bad in the recent weeks.

So to report, not one case of an exploding chopper was valid, all had other variables like hill and on its side already to PhysX issues.

To Conclude, Scarr FUCKIN A man Thank you very much for this script.

Our community also has sent many thanks as they have tested this out a lot by finding as many choppers as possible the last 36 hours.

Oh I would also like to throw in there that DP is running 74 out of 243 slots are choppers so high chopper numbers are ok with this script, too!

Thanks Mods for moving this to where it will be seen by even more

 

No problem at all. It is all about making it more enjoyable for the players and admins  ;)

 

Thanks for the feedback, much appreciated. 

Link to comment
Share on other sites

Hi, I am very eager to try this, but im still a novice,

 

scripts.txt (note, your line numbers might differ
            line 22: append !="_x allowDamage true;" !="_vehicle allowDamage false"
            line 48: append !="_x setDamage 0;"
            if you get kicked for addEventHandler then add
            line 53: !="_x addEventHandler [\"GetIn\", {_this call fn_handleGetIn;}];" !="_x addEventHandler [\"Local\", {_this call fn_handleLocal;}];"

 

line 22 i assume is - 7 allowDamage

im not sure on line 48 is it 7 SetDamage?

 

Many thanks this script will be a real time saver for admins and for players.

 

Simon

Link to comment
Share on other sites

Hi, I am very eager to try this, but im still a novice,

 

scripts.txt (note, your line numbers might differ

            line 22: append !="_x allowDamage true;" !="_vehicle allowDamage false"

            line 48: append !="_x setDamage 0;"

            if you get kicked for addEventHandler then add

            line 53: !="_x addEventHandler [\"GetIn\", {_this call fn_handleGetIn;}];" !="_x addEventHandler [\"Local\", {_this call fn_handleLocal;}];"

 

line 22 i assume is - 7 allowDamage

im not sure on line 48 is it 7 SetDamage?

 

Many thanks this script will be a real time saver for admins and for players.

 

Simon

 

You are correct, just look for setDamage and allowDamage in your script.txt file and add those to the end of each line. 

Link to comment
Share on other sites

Both or just one? And which one?

 

        if( (_x getVariable["GotIn",false])) then{
             uiSleep 3;
            _x setDamage 0;
            _x allowDamage true;
            _x setVariable ["GotIn",false];
        };
        
        if( (_x getVariable["LocalChanged",false])) then{
             uiSleep 3;
            _x setDamage 0;
            _x allowDamage true;
            _x setVariable ["LocalChanged",false];
        };

Link to comment
Share on other sites

Both or just one? And which one?

 

        if( (_x getVariable["GotIn",false])) then{

             uiSleep 3;

            _x setDamage 0;

            _x allowDamage true;

            _x setVariable ["GotIn",false];

        };

        

        if( (_x getVariable["LocalChanged",false])) then{

             uiSleep 3;

            _x setDamage 0;

            _x allowDamage true;

            _x setVariable ["LocalChanged",false];

        };

 

On both.

Link to comment
Share on other sites

Hey tried it out and it does work to a point, only issue is when it changes from local back to player it sometimes causes the chopper to get damage when they take the pilot seat and also have checked it out on my test server just to make sure none of my other scripts are playing with it and was doing the same there with just your script running, but great job and maybe we can use this in the next epoch dev update if need be, and as always have fun and a great day thank you .

Link to comment
Share on other sites

Hey tried it out and it does work to a point, only issue is when it changes from local back to player it sometimes causes the chopper to get damage when they take the pilot seat and also have checked it out on my test server just to make sure none of my other scripts are playing with it and was doing the same there with just your script running, but great job and maybe we can use this in the next epoch dev update if need be, and as always have fun and a great day thank you .

 

Hey, thanks for the feedback. I will check it out and let you know should I find anything.  :)

Link to comment
Share on other sites

Hi,

Nice script its really going to help server admins :)

 

when i install it i have those kick restriction:

 

Set damage:

 

#0 0.000000 2:436 B_G_Offroad_01_armed_EPOCH
#0 0.000000 2:2273 I_G_Offroad_01_F
#0 0.000000 2:2787 B_MRAP_01_EPOCH

#0 0.000000 2:479 B_G_Offroad_01_armed_EPOCH
#0 0.000000 2:2747 B_MRAP_01_EPOCH
#0 0.000000 2:3203 B_G_Offroad_01_armed_EPOCH
#0 0.000000 2:480 B_Truck_01_transport_EPOCH
#0 0.000000 2:534 I_G_Offroad_01_armed_F
#0 0.000000 2:506 I_G_Offroad_01_armed_F
#0 0.000000 2:862 I_G_Offroad_01_F

 

i add exception for them but still have those kick

 

any idea for this pb ?

 

Thx
 

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
  • Discord

×
×
  • Create New...