Jump to content

HOW TO: Vehicles indestructible within plot area


BigEgg

Recommended Posts

Allright guys ive tested this and it does not seem to work as it should b, since players can still get vehicles to tow and release them inside of the vehicles and they will explode.(also you can use tanks to blow shit up) instead im using a kinda different solution that does not exits the script but does add a eventhandler to the object so its invulnarable.(hows this word written corectly?)

the code:

/*
        Created exclusively for ArmA2:OA - DayZMod.
        Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
*/

/***********************************************************
ASSIGN DAMAGE TO A UNIT.
Called by "HandleDamage" vehicle Event Handler
or by "PVCDZ_veh_SH" PV
or by zombie_attack

- Function fnc_veh_handleDam
- [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam;
- return : updated damage for that part
broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local.
************************************************************/
private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"];

_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
if (((locked _unit && (count(crew _unit)) == 0) && (count(_unit nearEntities["Plastic_Pole_EP1_DZ", 100]) > 0))) then {
_unit addEventHandler ["HandleDamage", {false}];
_unit enableSimulation false;
}else{



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

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

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

		PVDZ_veh_Save = [_unit,"damage",false,_totalDmg];
		if (!isServer) then {
			publicVariableServer "PVDZ_veh_Save";
		} else {
			PVDZ_veh_Save call server_updateObject;
		};
	};
} else {
	//if ( (count _this > 5) AND {(_this select 5)}) then {
		// vehicle is not local to this client, ask the client which vehicle is local to set damage
		//_this resize 5; // delete "broadcast" boolean
		PVDZ_send = [_unit,"VehHandleDam",_this];
		publicVariableServer "PVDZ_send";
	//};
};

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

would be kinda nice if you could mention this somewhere in your original post :) @BigEgg coz i don´t want to start a different topic just because of this

Link to comment
Share on other sites

I've tried this but it does not work for me.

 

 

  Reveal hidden contents

What I try is that vehicles closed by the map, within safe zone and plot area are not damaged, But I always have to get in the vehicle for this to happen.(i check safezones and change the path)

Link to comment
Share on other sites

  On 4/10/2017 at 8:59 AM, S4M said:

I've tried this but it does not work for me.

 

 

  Reveal hidden contents

What I try is that vehicles closed by the map, within safe zone and plot area are not damaged, But I always have to get in the vehicle for this to happen.(i check safezones and change the path)

Expand  
_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
if (((locked _unit && (count(crew _unit)) == 0))) then {
_unit addEventHandler ["HandleDamage", {false}];
_unit enableSimulation false;
}else{
_unit addEventHandler ["HandleDamage", {true}];
_unit enableSimulation true;

};

u could try this.

it should make all the vehicles indestructible if they are locked.

@S4M

Link to comment
Share on other sites

These are my files on this subject :

veh_handleDam:

  Reveal hidden contents

local_lockUnlock:

  Reveal hidden contents

SafeZones:

  Reveal hidden contents

 

Link to comment
Share on other sites

u don´t need the lock/unlock.sqf if u use my veh_damagehandler.

also there should be nothing wrong with the safezones

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 4/10/2017 at 10:34 AM, Cherdenko said:

u don´t need the lock/unlock.sqf if u use my veh_damagehandler.

also there should be nothing wrong with the safezones

  Reveal hidden contents

 

Expand  

I did this and the same thing happens to me, I have to get in the driver's seat to take effect :sad:I'm sorry for my English

Link to comment
Share on other sites

Look this is

  Reveal hidden contents

 

Link to comment
Share on other sites


if (isServer) then {
    diag_log "Loading custom server compiles";    
};

if (!isDedicated) then {
    diag_log "Loading custom client compiles";
    
    fnc_usec_selfactions = compile preprocessFileLineNumbers "dayz_code\compile\fn_selfActions.sqf";
    player_humanityMorph = compile preprocessFileLineNumbers "dayz_code\compile\player_humanityMorph.sqf"; // This line can be removed when Epoch 1.0.6.2 comes out.
    compile preprocessFileLineNumbers "overwrites\click_actions\init.sqf";
    
    //cold
    player_temp_calculation = compile preprocessFileLineNumbers "custom\fn_temperatur.sqf";

};
    fnc_veh_handleDam = compile preprocessFileLineNumbers "custom\veh_handleDam.sqf"; //belongs here not in the section above

 

Link to comment
Share on other sites

You shouldn't need to add an eventhandler to the object. The script merely checks to see if the vehicle is near a plot and if it's locked and the vehicle has no crew, and if it finds that, it just exits the damage applying script. Don't see how adding a damage handler changes anything.

Link to comment
Share on other sites

  On 4/11/2017 at 6:51 PM, BigEgg said:

You shouldn't need to add an eventhandler to the object. The script merely checks to see if the vehicle is near a plot and if it's locked and the vehicle has no crew, and if it finds that, it just exits the damage applying script. Don't see how adding a damage handler changes anything.

Expand  

well it seemed to work on my server so i posted it,

as  player(very creative players i have to admit that) towed a bus and untowed it in other vehicles and they exploded.

thats why i created this new way

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

So I'm having this issue, Locked vehicles no matter where they are on the map even outside plots, as long as no one gets in them are Auto-healing anytime they take damage. I tested by shooting a locked ural with a DMR and as I shot the tires they keep healing. How do I fix this so Only vehicles on plot have god like the script says? Here is my veh_handledamage.sqf

private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg","_state"];

//***Zupa Config ****//

_godmodeVechilesEverywhere = false; // Godmode on all locked vehicles
_onlyLockedVehicles = true; //Plotarea: Godmode for Only locked vehicles (true) or locked and unlocked(false)
_onlyVehicleWithoutGear = true; // Only godmode on vehicles that hold no gear.
_safeZoneGodVehicle = false; // Godmode vehicles in safezones. (or specific zone's)
_donatorsPlots = false; // True = only godmode vehicles for donaters in the list, False = godmode for every guy.
_plotDonators = ["0"]; // PUID's of poeple who donated for plotpole

// Chernarus safezone area's - change these to other coordinates for other maps. ( You can also add specific locations on the map.
_safezones = [
    [[11806.7,12688.7],50,"Air"],
    [[1606.6443,7803.5156],50,"Bandit"],
    [[4063.4226,11664.19],50,"Bash"],
    [[11397.4,5513.73],20,"Msta"],
    [[11447.472,11364.504],50,"Klen"],
    [[4762.63,6267.55],50,"Pog"] // [[x,y],distance,"just name"]
];
//***END Config ****//
_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
if (((locked _unit && (count(crew _unit)) == 0) && (count(_unit nearEntities["Plastic_Pole_EP1_DZ", DZE_PlotPole select 0]) > 0))) exitWith {};
_state = true;
_HPBefore = -1;

if (_selection != "") then {
_strH = "hit_" + _selection;
_HPBefore = [_unit,_strH] call object_getHit;


    _totalDmg = false;
} else {
_strH = "totalDmg";
_totalDmg = true;
_HPBefore = getDammage _unit;

};

if(_total > _HPBefore)then{

if((locked _unit && _godmodeVechilesEverywhere  && (count (crew _unit)) < 1))then{_state = false;
};

if(_state)then{
if(_safeZoneGodVehicle )then{
{if ((_unit distance (_x select 0)) < (_x select 1)) then {_state = false;
};} forEach _safezones;
};
};

if(_state)then{
_gearCount = 0;
if(_onlyVehicleWithoutGear)then{
};
_plots = nearestObjects [_unit, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];    
if((count(_plots) > 0))then{        
    _thePlot = _plots select 0;
    _plotOwner = _thePlot getVariable ["ownerPUID",0];
if ( (_gearCount == 0) &&(locked _unit || !(_onlyLockedVehicles) ) && (count (crew _unit)) < 1 && (  !(_donatorsPlots) || (_plotOwner in _plotDonators))) then {_state = false;

};
};
};

}; //fix
if(_state)then{


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


if (local _unit) then {
if (_total > 0) then {


        if (!_totalDmg) then {
_unit setVariable [_strH, _total, true];
        };
_unit setHit [_selection, _total];


        PVDZ_veh_Save = [_unit,"damage",false,_totalDmg];
if (isServer) then {

            publicVariableServer "PVDZ_veh_Save";
} else {
PVDZ_veh_Save call server_updateObject;

};
};
} else {
// vehicle is not local to this client, ask the client which vehicle is local to set damage
/* PVS/PVC - Skaronator */
PVDZ_send = [_unit,"VehHandleDam",_this];
publicVariableServer "PVDZ_send";
};


}else{
_total = _HPBefore;
};
// 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

  • 4 months later...
  On 8/5/2018 at 11:17 AM, mrjamesyboii said:

Where would I find my veh_handleDam.sqf?

(It's not where you listed in the instructions)

Expand  

Here you go https://www.dropbox.com/s/fpxx895kcpg0aam/veh_handleDam.sqf?dl=0

You needed to go into your @dayz_epoch folder > addons and unpbo dayz_code. When fetching files this will normally be the place to go

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Advertisement
  • Discord

×
×
  • Create New...