[RELEASE] Vehicle Safe Zones by Lunchbox

HisShadowONE

Well-Known Member
We have a (custom version) of AGN safe zones, but I believe this will work with just vanilla Dayz Epoch since the 'canbuild' function is from Epoch. I got ideas on how to write this all over the forums, if you need or want credit, please let me know. I don't remember where portions of code came from. Works perfect on our server (Doubletapdayz: Lunchbox and HisShadow).

Tested with: 1.0.4.2a

How it works:

Vehicle god mode on entrance of a safe zone. Once the player leaves the Safe Zone without the vehicle, god mode on it will turn off and be damageable once again. The player has to at least drive into the safe zone or enter the vehicle at least once to activate the god mode. Once the player and vehicle leaves your designated safe zone, it will deactivate and return to normal.



Limitations:

Player must be logged in for the vehicle god mode to be active.

Player must have at least entered the vehicle once.

Player must remain in the safe zone for the vehicle to remain god moded.

safezonevehicle.sqf

Code:
// Godmode vehicle in safe zones (Lunchbox).
// How it works: When in safezone, vehicle takes no damage. However, When the player
// leaves the safezone with the car in the safezone, the car will take damage.
// This is to prevent abuses with the safezone system.
// Written for Doubletapdayz
if (isNil "canbuild") then {
    canbuild = true;
};
while {true} do {
      
        // Vehicle Godmode on.
    waitUntil { !canbuild };
    waitUntil { player != vehicle player };
    theVehicle = vehicle player;
    theVehicle removeAllEventHandlers "handleDamage";
    theVehicle addEventHandler ["handleDamage", {false}];
    theVehicle allowDamage false;
    fnc_usec_damageVehicle ={};
    vehicle_handleDamage ={};
    vehicle_handleKilled ={};
    // hintSilent "Vehicle godmode ON"; // Uncomment this to help see when it turns on
    waitUntil { canbuild };
    // Vehicle Godmode off.
    theVehicle removeAllEventHandlers "handleDamage";
        theVehicle addEventHandler ["handleDamage", {_this select 2}];
    theVehicle allowDamage true;
    // Call global scripts.
    fnc_usec_damageVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageHandlerVehicle.sqf";
    vehicle_handleDamage = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleDamage.sqf";
    vehicle_handleKilled = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleKilled.sqf";
    // hintSilent "Vehicle godmode OFF"; // Uncomment this to help see when it turns off
};

Place file in the scripts folder, if it doesn't exist in your missions file.

Execute in your isdedicated portion of init.sqf of your missions file:
Code:
[] execVM "scripts\safezonevehicle.sqf";

Should be good to go. It really is that easy.
smile.png


this has worked for us no problem in testing , post any unusual behavior you find , and this can also be used to block most any functions you need in safezones so it can be adapted for knockouts in safe zone arrest and other unwanted functions , we will probably release further versions of those scripts should the original authors take no issue.

ALSO A BIG REMINDER YOU MUST REMAIN IN THE SAFEZONE FOR THE VEHICLE TO BE GODMODED this is intentional behavior as to not allow abuse of safezones to save cars or use as a shield at the edge of the zone for firefights and other sneaky shit players are known for coming up with, and again post any reasonable exploits you come across.
 
Back
Top