Jump to content

Script Locked Vehicles No Damage?


Shiz

Recommended Posts

this is my custom vehicle_handleDamage.sqf. try this...

/***********************************************************
ASSIGN DAMAGE TO A UNIT
- Function Vehicle_HandleDamage
- [unit, selectionName, damage, source, projectile] call Vehicle_HandleDamage;
************************************************************/
private["_unit","_selection","_strH","_total","_damage","_needUpdate"];

_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;

if (locked _unit) exitWith {}; //<--add this line

if (_selection != "") then {
	_strH = "hit_" + _selection;
	} else {
        	_strH = "totalDmg";
	};

if (_total >= 0.98) then {
        _total = 1.0;
	};

if (local _unit) then {
	if ( _total>0 ) then {
	
        	_unit setVariable [_strH,_total,true];
		_unit setHit [_selection, _total];

			if (isServer) then {
				[_unit, "damage"] call server_updateObject;
			} else {
				PVDZE_veh_Update = [_unit,"damage"];
				publicVariableServer "PVDZE_veh_Update";
			};
		};
} else {
	// vehicle is not local to this client, ask the client which vehicle is local to set damage
	/* PVS/PVC - Skaronator */
	PVDZE_send = [_unit,"VehHandleDam",_this];
	publicVariableServer "PVDZE_send";
	};

// all "HandleDamage event" functions should return the effective damage that the engine will record for that part
_total
Link to comment
Share on other sites

 

this is my custom vehicle_handleDamage.sqf. try this...

/***********************************************************
ASSIGN DAMAGE TO A UNIT
- Function Vehicle_HandleDamage
- [unit, selectionName, damage, source, projectile] call Vehicle_HandleDamage;
************************************************************/
private["_unit","_selection","_strH","_total","_damage","_needUpdate"];

_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;

if (locked _unit) exitWith {}; //<--add this line

if (_selection != "") then {
	_strH = "hit_" + _selection;
	} else {
        	_strH = "totalDmg";
	};

if (_total >= 0.98) then {
        _total = 1.0;
	};

if (local _unit) then {
	if ( _total>0 ) then {
	
        	_unit setVariable [_strH,_total,true];
		_unit setHit [_selection, _total];

			if (isServer) then {
				[_unit, "damage"] call server_updateObject;
			} else {
				PVDZE_veh_Update = [_unit,"damage"];
				publicVariableServer "PVDZE_veh_Update";
			};
		};
} else {
	// vehicle is not local to this client, ask the client which vehicle is local to set damage
	/* PVS/PVC - Skaronator */
	PVDZE_send = [_unit,"VehHandleDam",_this];
	publicVariableServer "PVDZE_send";
	};

// all "HandleDamage event" functions should return the effective damage that the engine will record for that part
_total

 

If you change line 12 to

if (locked _unit && (count (crew _unit)) == 0) exitWith {};

it will stop players from being able to abuse the script.  Basically, this just checks if the vehicle has any players in it and if it does, regardless of whether it is locked or not, it will take damage.  Unmanned locked vehicles will still take no damage.

Link to comment
Share on other sites

If you change line 12 to

if (locked _unit && (count (crew _unit)) == 0) exitWith {};

it will stop players from being able to abuse the script.  Basically, this just checks if the vehicle has any players in it and if it does, regardless of whether it is locked or not, it will take damage.  Unmanned locked vehicles will still take no damage.

can you help me, how do i add this to safe zone traders? so if they are in safe, the car wont take any damage

Link to comment
Share on other sites

 

Maybe something like this. This won't allow you to lock the vehicle if there is someone inside. Untested.

 

local_lockUnlock.sqf

private ["_vehicle","_status"];
_vehicle = _this select 0;
_status = _this select 1;

if (local _vehicle) then {
	if(_status) then {
	if (count crew _vehicle == 0) then {
		_vehicle setVehicleLock "LOCKED";
		_vehicle removeAllEventHandlers "handleDamage";
		_vehicle addEventHandler ["handleDamage", {false}];
                _vehicle enableSimulation false;
		_vehicle allowDamage false;
		titleText ["LOCKED! Can not be damaged!","PLAIN DOWN"]; titleFadeOut 4;
	} else {
		titleText ["You can't lock while there is someone inside!","PLAIN DOWN"]; titleFadeOut 4;
		};
	} else {
		_vehicle setVehicleLock "UNLOCKED";
		_vehicle removeAllEventHandlers "handleDamage";
                _vehicle addEventHandler ["handleDamage", {true}];
                _vehicle enableSimulation true;
		_vehicle allowDamage true;
		vehicle_handleDamage = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleDamage.sqf";
		titleText ["UNLOCKED!","PLAIN DOWN"]; titleFadeOut 4;
		};
	};

 

Where do i have to place this?

I have infistar and want to use this skript.

Thanks!

Link to comment
Share on other sites

Do what FreakingFred said in post #33. Get vehicle_handleDamage.sqf from dayz_code and call it from compiles.sqf.

Ok thanks. i´m not sure what i am going to use.

In Epoch 1.0.5 it will be possible to show which player made what damage to this vehicle.

Or maybe it is a good idea to use this costum vehicle damage handler.

i think i am going to ask the players on my server, what they are thinking is the best.

Thank you all anyway!!!

Link to comment
Share on other sites

 

Not sure if this is the proper way to do it but I just added a few lines to the local_lockUnlock.sqf

 

This seems to work for me....

 

private ["_vehicle","_status"];
_vehicle = _this select 0;
_status = _this select 1;
 
if (local _vehicle) then {
if(_status) then {
_vehicle setVehicleLock "LOCKED";
_vehicle setVariable ["R3F_LOG_disabled",true,true];
_vehicle allowDamage false;
_vehicle enableSimulation false;
} else {
_vehicle setVehicleLock "UNLOCKED";
_vehicle setVariable ["R3F_LOG_disabled",false,true];
_vehicle allowDamage true;
 _vehicle enableSimulation true;
};
};

 

is there something wrong with this way ???  It works....

 

could anyone tell why I shouldn't do it this way  ??

Link to comment
Share on other sites

Hey, maybe also add a time, so that players can´t just lock there vehicles if they are getting into combat.
Would it help to simply insert a sleep 1800 seconds  (30 mins) ?
Where would i have to insert it ?

I want the vehicle to be locked but invincible after 30 minutes after the lock.

Thanks 
Exo

Link to comment
Share on other sites

Could someone help me ? I would like to use this but i want the vehicle to be indestructable after 30 minutes. So the owner locks the vehicle and 30 minutes later its indestructable. 
Where do i have to insert the sleep ? Want to use the script from post #33

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Calamity I tried using the code you posted... not working for me did you make anymore changes to it after your post to get it working? As of right now when i add it in im getting the unlock option on vehicle but its not unlocking and vics are still able to be destroyed.

Link to comment
Share on other sites

  • 2 weeks later...

Is there anyway to make LOCKED vehicles invincible only near a plot pole? Any help would be appreciated.. I have seen servers like this and it would be helpful for my private server at work, since my co-workers have an obsession with suicide bombing my locked vehicles lol.

 

I'm also interested in this instead of them being invincible across the map. have a check for a plot pole with in so many meters. code after line 12..?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
×
×
  • Create New...