In Search of Anti-Zombie, and Car God Mode at Trader Zones.. using AGN

wow fast response time ! :) thanks all works fine for me again weapons cant fire zeds delete no one else on for me to test backpacks
.. still cant get rid of those damn ai tho lol tried that earlier post still not working ...wait was it not working for the same reason the rest wasnt i had it after the zed part ... i have no idea where to put this in to make it work and not break stuff again either.. blaa
I figured something out and learned something new lol. The reason it broke was that the zombie part I added in was continuously running so it never got any further into the script. I've changed it to [] spawn now and it will run independently so as to not hang up the script from completely.
 
The zombie script could have caused the ai portion not to start either.

so to fix the ai portion you would need to change from my pastebin earlier and make it look like this:

Code:
if ( AGN_safeZone_Players_DZAI ) then
        {
            _remove_ai = [] spawn {
                while {!canBuild} do
                {
                        _entity_array_dzai = (getPos player) nearEntities ["CAManBase",110];
                        {
                                // this is just the variable I saw in that cleanup... no idea if its correct...
                                if (_x getVariable ["groupSize",0]) then {
                                        deletevehicle _x;
                                };
                        } forEach _entity_array_dzai;
                        sleep 4;
                };
            };
        };
 
Last edited:
bah none of the above worked tried all three ways separately, once with what you posted above , tried changing the delete line to the one from dzai and tried with without the { } around it none of them worked. thanks for keeping at it though and helping really appreciate it !
 
so I just found out that even though all of the messages are coming up, saying the players are in a safe zone, etc etc.. they can still kill other players and shoot their weapons. Any ideas? I believe Im using the original script too, not the edited AGN.

OK so after some testing.. it seems that the god mode is working but players can still shoot and do damage from inside the trader zone. However, I can't.... Im thinking that maybe the antihack is goofing it up somehow?

Edit- just an antihack issue, disregard.
 
Last edited:
PHP:
if (_x getVariable ["groupSize",0]) then {
                                        deletevehicle _x;
                                };
That can't work, "if" needs a boolean condition, but the variable groupsize is scalar/numeric.
PHP:
if (!isNil {_x getVariable "groupSize"}) then {
                                        deletevehicle _x;
                                };
 
well boo none of this works :( the zeds are deleting though
it really seems like declaring a separate variable should have worked just fine ...
 
Hey guys,

i got this AGN SZ Commander with a self built-in Zed Shield:
(the settings I have left out, due to space)
Code:
//Probs not needed, but meh :)
disableSerialization;

waitUntil {!isNil "dayz_animalCheck"};
if ( AGN_safeZoneMessages ) then { systemChat ( "[AGN] Trader Zone Commander Loaded!" ); };

_inVehicle = objNull;
_inVehicleLast = objNull;

while {true} do {
   
    waitUntil { !canBuild };

    _inSafezoneFinished = false;
    if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Entering Trader Area - God Mode Enabled"); };
    _thePlayer = player;

    if ( AGN_safeZoneGodmode ) then
    {
        player_zombieCheck = {};
        fnc_usec_damageHandler = {};
        _thePlayer removeAllEventHandlers "handleDamage";
        _thePlayer addEventHandler ["handleDamage", {false}];
        _thePlayer allowDamage false;
        _inVehicle allowDamage false;
        _zombies = _basis nearEntities ["zZombie_Base",50];
        _count = count _zombies;
        for "_i" from 0 to (_count -1) do
        {
            _zombie = _zombies select _i;
            deletevehicle _zombie;
        };
       
    };
   
    if ( AGN_safeZone_Players_DisableWeaponFiring ) then
    {
        _EH_Fired = _thePlayer addEventHandler ["Fired", {
            systemChat ("[AGN] You can not fire your weapon in a Trader City Area");
            NearestObject [_this select 0,_this select 4] setPos[0,0,0];
        }];
    };
   
    if ( AGN_safeZone_Players_RemoveZombies ) then
    {
        while {!canBuild} do
        {
            _entity_array = (getPos player) nearEntities ["CAManBase",110];
            {
                if (_x isKindof "zZombie_Base") then {
                    deletevehicle _x;
                };
            } forEach _entity_array;
            sleep 4;
        };
    };
   
    if ( AGN_safeZone_Backpack_EnableAntiBackpack ) then
    {
        AGN_LastPlayerLookedAt = objNull;
        AGN_LastPlayerLookedAtCountDown = 5;
        _antiBackpackThread = [] spawn {
            private [ "_ct","_ip","_ia","_dis"] ;
            while {!canBuild} do
            {
                if ( isNull AGN_LastPlayerLookedAt ) then
                {
                    waitUntil {!isNull cursorTarget};
                    _ct = cursorTarget;
                    _ip = isPlayer _ct;
                    if ( _ip ) then { _ia = alive _ct; _dis = _ct distance player; } else { _ia = false; _dis = 1000; };
                   
                    if ( (_ip && _ia) && (_dis < 6.5) ) then
                    {
                        AGN_LastPlayerLookedAt = _ct;
                    };
                } else {
                    AGN_LastPlayerLookedAtCountDown = AGN_LastPlayerLookedAtCountDown - 1;
                    if ( AGN_LastPlayerLookedAtCountDown < 0 ) then { AGN_LastPlayerLookedAtCountDown = 5; AGN_LastPlayerLookedAt = objNull; };
                    sleep 1;
                };
            };
        };
           
        _antiBackpackThread2 = [] spawn {
            private ["_to","_dis","_inchk","_ip","_ia","_skip","_ct","_iv","_lp","_inv","_ctOwnerID","_friendlies","_if"];
            _ctOwnerID = 0;
            while {!canBuild} do
            {
                _ct = cursorTarget;
                _skip = false;
               
                if ( !isNull (_ct) ) then
                {
                    _to = typeOf _ct;
                    _dis = _ct distance player;
                    _inchk = ["WeaponHolder","ReammoBox"];
                   
                    _lp = false;
                    {
                        if ( (_to isKindOf _x) && (_dis < 10) && AGN_safeZone_Backpack_AllowGearFromLootPiles ) then
                        {
                            _lp = true;
                        };
                    } forEach ( _inchk );

                    _ip = isPlayer _ct;
                    _ia = alive _ct;
                    _iv = _ct isKindOf "AllVehicles";
                    _inv = (vehicle player != player);
                   
                    _if = false;
                    if ( _ip ) then {
                        _ctOwnerID = _ct getVariable["CharacterID","0"];
                        _friendlies    = player getVariable ["friendlyTo",[]];
                        if(_ctOwnerID in _friendlies) then {   
                            if ( AGN_safeZone_Backpack_AllowFriendlyTaggedAccess ) then
                            {
                                _if = true;
                            };
                        };
                    };
                    if ( AGN_safeZoneDebug ) then {
                    hintSilent ( format["AGN Safezone Commander\n\nCursorTarget\n%1\n\nDistance\n%2\n\nLootpile\n%3 [%9]\n\nisPlayer\n%4\n\nAlive\n%5\n\nisVehicle\n%6\n\ninVehicle\n%7\n\nisFriendly\n%8 (%12) [%10]\n\nSkip: %11\n",
                                                _ct, _dis, _lp, _ip, _ia, _iv, _inv, _if, AGN_safeZone_Backpack_AllowGearFromLootPiles, AGN_safeZone_Backpack_AllowFriendlyTaggedAccess, _skip, _ctOwnerID] );
};

                   
                    //Lootpile check
                    if ( _lp ) then {_skip = true;};
                   
                    //Dead body check
                    if ( !(_ia) && AGN_safeZone_Backpack_AllowGearFromDeadPlayers ) then {_skip = true;};
                   
                    //Vehicle check
                    if ( _iv && (_dis < 10) && !(_ip) && AGN_safeZone_Backpack_AllowGearFromVehicles ) then {_skip = true;};
                   
                    //In a vehicle check
                    if ( _inv && AGN_safeZone_Vehicles_AllowGearFromWithinVehicles ) then { _skip = true; };
                   
                    //Is player friendly?
                    if ( _if ) then { _skip = true; };
                };
               
                if( !isNull (FindDisplay 106) && !_skip ) then
                {
                    if ( isNull AGN_LastPlayerLookedAt ) then
                    {
                        (findDisplay 106) closeDisplay 1;
                        waitUntil { isNull (FindDisplay 106) };
                        createGearDialog [(player), 'RscDisplayGear'];
                        if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Anti Backpack Stealing - Redirecting you to your own gear!"); };
                        waitUntil { isNull (FindDisplay 106) };
                    } else {
                        if ( AGN_safeZoneMessages ) then { systemChat (format["[AGN] You cannot open your gear at this time as you have looked at a player in the last 5 seconds."]); };
                        (findDisplay 106) closeDisplay 1;
                        waitUntil { isNull (FindDisplay 106) };
                    };
                };
                if ( _skip && _if ) then {
                    if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] This player is tagged friendly, you have access to this players bag") };
                };
            };
        };
    };
   
    if ( AGN_safeZone_Vehicles_DisableMountedGuns ) then
    {
        while { !canBuild } do
        {
            sleep 0.1;
            if ( !(isNull _inVehicle) && (vehicle player == player) ) then
            {
                _inVehicle removeEventHandler ["Fired", _EH_Fired_Vehicle];
                _inVehicleLast = _inVehicle;
                _inVehicleLast removeEventHandler ["Fired", _EH_Fired_Vehicle];
                _inVehicle = objNull;
            };
           
            if ( vehicle player != player && isNull _inVehicle ) then
            {
                if (AGN_safeZoneMessages) then { systemChat ( "[AGN] No Firing Vehicle Guns Enabled" ); };
                _inVehicle = vehicle player;
                _inVehicleDamage = getDammage _inVehicle;
                _EH_Fired_Vehicle = _inVehicle addEventHandler ["Fired", {
                    systemChat ("[AGN] You can not fire your vehicles weapon in a Trader City Area");
                    NearestObject [_this select 0,_this select 4] setPos[0,0,0];
                }];
            };
        };
    } else {
        waitUntil { canBuild };
    };

    AGN_LastPlayerLookedAt = objNull;
    AGN_LastPlayerLookedAtCountDown = 5;
    terminate _antiBackpackThread;
    terminate _antiBackpackThread2;
    if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Exiting Trader Area - God Mode Disabled"); };
   
    if ( AGN_safeZone_Vehicles_DisableMountedGuns ) then
    {
        if ( !(isNull _inVehicle) ) then
        {
            if ( AGN_safeZoneMessages ) then { systemChat ( "[AGN] No Firing Vehicle Guns Disabled" ); };
            _inVehicle removeEventHandler ["Fired", _EH_Fired_Vehicle];
        };
       
        if ( !(isNull _inVehicleLast) ) then
        {
            if ( AGN_safeZoneMessages ) then { systemChat ( "[AGN] No Firing Vehicle Guns Disabled" ); };
            _inVehicleLast removeEventHandler ["Fired", _EH_Fired_Vehicle];
        };
    };

    if ( AGN_safeZone_Players_DisableWeaponFiring ) then
    {
        _thePlayer removeEventHandler ["Fired", _EH_Fired];
    };
   
    if ( AGN_safeZoneGodmode ) then
    {
        player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf";
        fnc_usec_damageHandler = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageHandler.sqf";
        _thePlayer addEventHandler ["handleDamage", {true}];
        _thePlayer removeAllEventHandlers "handleDamage";
        _thePlayer allowDamage true;
    };
    _inSafezoneFinished = true;
};


Seems there is only one problem with the Antibagpack stealing,
players can still open BP from not tagged ppl, even if it is set to true.
 
leaving out the other areas you need to edit doesn't help track bugs :p leave out the end of the file not the beginning if there's not enough room or use pastebin
anyways heres mine for comparison
Code:
Private ["_EH_Fired","_ehID","_fix","_inVehicle","_inVehicleLast","_EH_Fired_Vehicle","_inVehicleDamage","_antiBackpackThread","_antiBackpackThread2","AGN_safeZoneGodmode","AGN_safeZoneMessages","AGN_safeZone_Backpack_AllowGearFromLootPiles","AGN_safeZone_Backpack_AllowGearFromVehicles","AGN_safeZone_Backpack_AllowGearFromDeadPlayers","AGN_safeZone_Vehicles_DisableMountedGuns","AGN_safeZone_Players_DisableWeaponFiring","AGN_safeZone_Backpack_EnableAntiBackpack","AGN_safeZone_Vehicles_AllowGearFromWithinVehicles","_anti_zombie","_vehicle","_veh_array","_y","_veh_total"];


//SCRIPT SETTINGS
AGN_safeZoneDebug = false; //Debug notes on screen.
AGN_safeZoneGodmode = true;                                 //Should safezone Godmode be enabled?
AGN_safeZoneMessages = true;                                //Should players get messages when entering and exiting the safe zone?
AGN_safeZone_Backpack_EnableAntiBackpack = true;            //Should players not be able to take from peoples bags?
AGN_safeZone_Backpack_AllowGearFromLootPiles = true;        //Should players be able to loot from loot piles?
AGN_safeZone_Backpack_AllowGearFromVehicles = false;        //Should players be able to loot from a vehicles gear?
AGN_safeZone_Backpack_AllowGearFromDeadPlayers = true;        //Should players be able to loot from a dead players corpse?
AGN_safeZone_Backpack_AllowFriendlyTaggedAccess = true;    //Should players who are tagged friendly be able to access eachothers bags?
AGN_safeZone_Vehicles_DisableMountedGuns = true;            //Should players not be able to shoot bullets/projectiles from mounted guns?
AGN_safeZone_Vehicles_AllowGearFromWithinVehicles = true;    //Should players be able to open the gear screen while they are inside a vehicle?
AGN_safeZone_Players_DisableWeaponFiring = true;            //Should players not be able to shoot bullets/projectiles from their weapon(s)?
AGN_safeZone_Players_RemoveZombies= true;                //Players allowed to delete zombies while in safe zone?

//Probs not needed, but meh :)
disableSerialization;

waitUntil {!isNil "dayz_animalCheck"};
if ( AGN_safeZoneMessages ) then { systemChat ( "" ); };

_inVehicle = objNull;
_inVehicleLast = objNull;

while {true} do {
  
    waitUntil { !canBuild };

    _inSafezoneFinished = false;
    if ( AGN_safeZoneMessages ) then { systemChat ("Entering Trader Area - God Mode Enabled"); };
    _thePlayer = player;

    if ( AGN_safeZoneGodmode ) then
    {
        player_zombieCheck = {};
        fnc_usec_damageHandler = {};
        _thePlayer removeAllEventHandlers "handleDamage";
        _thePlayer addEventHandler ["handleDamage", {false}];
        _inVehicle allowDamage false;
    };
  
    if ( AGN_safeZone_Players_RemoveZombies ) then
    {
        _anti_zombie = [] spawn {
        private ["_entity_array"];
            while {!canBuild} do
            {
                _entity_array = (getPos player) nearEntities ["CAManBase",110];
                {
                    if (_x isKindof "zZombie_Base") then {
                        deletevehicle _x;
                    };
                } forEach _entity_array;
                sleep 4;
            };
        };
    };
 
guys this was causing issues with the newest versions of infiSTAR. People were still able to shoot inside the zone. InfiSTAR has posted his own safezone, it's in his github. You'll still need an anti zombie script which you can run separately.
 
guys this was causing issues with the newest versions of infiSTAR. People were still able to shoot inside the zone. InfiSTAR has posted his own safezone, it's in his github. You'll still need an anti zombie script which you can run separately.

Any Link?
 
ok heres how DZAI removes some of its AI just need to tie it into Safezones :p

PHP:
_trigger setTriggerStatements ["{isPlayer _x} count thisList > 0;",_trigActStatements, "[thisTrigger] spawn fnc_despawnBandits_dynamic;"];

fnc_despawnBandits_dynamic: deletes the units after a sleep/timeout (called from despawnBandits_dynamicV2.sqf)
 
also while your looking into it any simple way to add a timer to the safe zone effects and a delay before they will be allowed to re-apply to avoid spamming borders of safe zones and using it to get god mode out of traders , and to avoid people camping in traders and not having to fight.
that would make this thing perfect!
 
shouldnt be to hard basically

add new variable and set it to false
add check to see if new variable is true when enter safezone
if not true turn make it true when enter safezone
if true on enter safezone dont turn on godemode in safezone script and message player

add to exit safezone script a sleep timer at end
set new variable back to false after sleep timer

ill post a how to soon just let me test it out :p
 
how about checking if the unit is side east or resistance?
Code:
//DZAI group side assignment function. Detects when East side has too many groups, then switches to Resistance side.
DZAI_getFreeSide = {
    private["_groupSide"];
    _groupSide = (if (({(side _x) == east} count allGroups) <= 140) then {east} else {resistance});
    //diag_log format ["Assigned side %1 to AI group",_groupSide];
   
    _groupSide
};
 
ok this is what i got so far BUT there is one major bug, the sleep timer part "sleeps" the entire script for 2min not just the godmode part, needs to be changed from sleep 120; to a 2min counte/timer

find this line
Code:
AGN_safeZone_Players_DisableWeaponFiring = true;            //Should players not be able to shoot bullets/projectiles from their weapon(s)?
add this under it
Code:
AGN_safeZoneAntispam = true;

find this
Code:
if ( AGN_safeZoneGodmode ) then{

some code in here

};
replace with this
Code:
if ( AGN_safeZoneGodmode ) then
    {
        if (AGN_safeZoneAntispam )then
        {
            if (AGN_enteredSafezone) then{
                if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Antispam Godmode...please wait before re-entering!"); };
            }else{
                if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Antispam - You must wait 2 minutes for god mode to become active once you leave!");};
                player_zombieCheck = {};
                fnc_usec_damageHandler = {};
                _thePlayer removeAllEventHandlers "handleDamage";
                _thePlayer addEventHandler ["handleDamage", {false}];
                _thePlayer allowDamage false;
                AGN_enteredSafezone = true;
            };
        };              
    };

at the end of the file find this
Code:
_inSafezoneFinished = true;

add this ABOVE it
Code:
    //ANTISPAM LEAVING SAFZONE
    if (AGN_safeZoneAntispam )then{
            if (AGN_enteredSafezone) then{
                sleep 120;//PROBLEM cause entire script to sleep for 2 min need to make counter       
                AGN_enteredSafezone = false;
                if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Antispam - You will now be protected when entering trader zones.");};
            };
    };

now this all works great except for the sleep timer bug, hopefully (iam trying to :p) someone can make the timer we need :p
 
Just waiting on epoch 1.0.4.2 client download (at work lol)
and will test new timer, if any scripting gurus out there this is what im testing is this right?
Code:
//ANTISPAM LEAVING SAFZONE
    if (AGN_safeZoneAntispam )then{
            if (AGN_enteredSafezone) then{
                _timer = 1; //SET TIMER DEFAULT
                //Timer Test
                for "_i" from 1 to 120 step 1 do {_timer = (_timer + 1);};
               
                If (_timer >= 120){
                AGN_enteredSafezone = false;
                if ( AGN_safeZoneMessages ) then { systemChat ("[AGN] Antispam - You will now be protected when entering trader zones.");};
                _timer = 1;
                };
               
            };
    };
 
Back
Top