Safe Bases - Almost Complete

greetings, sorry TorZar, i had no time to answer your pm last dayz -.-
can you explain what is happening when you veh leaves the trigger, still no damage handling and allowdamage false ?
is this triggered on local or server side ?
 
greetings, sorry TorZar, i had no time to answer your pm last dayz -.-
can you explain what is happening when you veh leaves the trigger, still no damage handling and allowdamage false ?
is this triggered on local or server side ?

Ahh, no ty for coming here and responding..

The damage is turned off once ENTERING the trigger as hoped for, on EXIT it seems to do nothing at all.. still takes no damage. It is all run from the mission pbo. Here are a few examples that i've tried with no luck:

Code:
_BaseTrigger1 setTriggerStatements["{_x isKindOf 'AllVehicles'} count thisList > 0","{_x removeEventHandler ['Killed', 0]; _x removeEventHandler ['HandleDamage', 0]; _x allowDamage false;} foreach thisList;","{_this spawn vehicle_handleDamage; ; _this spawn vehicle_handleKilled; _x allowDamage true;} foreach thisList;"]; //FAIL

Code:
_BaseTrigger1 setTriggerStatements["{_x iskindof 'LandVehicle' || _x isKindOf 'Air'} count thislist > 0","_this removeEventHandler ['Killed', 0]; _this removeEventHandler ['HandleDamage', 0]; _this allowDamage false;","_this addEventHandler ['Killed', { _this call vehicle_handleKilled }]; _this addEventHandler ['HandleDamage', { _this call vehicle_handleDamage }]; _this allowDamage true;"]; //FAIL

Code:
_BaseTrigger1 setTriggerStatements["{_x iskindof 'LandVehicle' || _x isKindOf 'air'} count thislist > 0","_this removeEventHandler ['Killed', 0]; _this removeEventHandler ['HandleDamage', 0]; _this allowDamage false;","_x addEventHandler ['Killed', { _x call vehicle_handleKilled }]; _x addEventHandler ['HandleDamage', { _x call vehicle_handleDamage }]; _this allowDamage true;"]; //FAIL

Code:
_BaseTrigger1 setTriggerStatements["{_x iskindof 'LandVehicle' || _x isKindOf 'Air'} count thislist > 0","_this removeEventHandler ['Killed', 0]; _this removeEventHandler ['HandleDamage', 0]; _this allowDamage false;","{_x setVariable["vehicle_handleDamage","\z\addons\dayz_code\compile\vehicle_handleDamage.sqf",true]; _x setVariable["vehicle_handleKilled","\z\addons\dayz_code\compile\vehicle_handleKilled.sqf",true];} forEach thisList; _this allowDamage true;"]; //FAIL

I'm just trying random things at this point.. not sure how to properly set the damage handler back.
 
ooo.. wait a sec.. it was still taking NO damage at all.. so theres no way to tell if the damage handlers are even being set as the allowDamage isn't even turned off correctly.. So, not even Arma's default way of allowing it to accept damage.. (where it all gets repaired after exiting/entering the vehicle) Thats telling me maybe i'm issuing "_this allowDamage true; incorrectly? And also realized I probably shouldn't use "thisList" on the exit? as it would just execute on the individual object exiting and there wouldn't be a "list"?
 
as i know allowdamge command works only locally, you need to run this on all machines (clients/server) and the eventhandlers have to add from the server
mybe you have to add some public var eventhandlers
 
Still workin on this here and there. Just getting a couple other projects outa the way

Just to let you know, I've already built the safe zone in Panthera(Not an easy task, with so many hills and slopes and Arma engine being finicky at its best). The server is currently closed as I add the finishing touches.

US 947 DayZ Private Hive
173.192.200.117:3204

If you want access pm me for the password.
 
Just to let you know, I've already built the safe zone in Panthera(Not an easy task, with so many hills and slopes and Arma engine being finicky at its best). The server is currently closed as I add the finishing touches.

US 947 DayZ Private Hive
173.192.200.117:3204

If you want access pm me for the password.

Did you manage to enable safe zones by humanity levels or just overall immunity for anyone in that location?
 
i tested it with this code :
Code:
_args = _this;
 
if(!isNull _args) then {
    _args setVehicleInit "this allowDamage true";
    processInitCommands;
};

and runs great for veh's and players
 
Did you manage to enable safe zones by humanity levels or just overall immunity for anyone in that location?
No, I don't have the same scripting knowledge as TorZar does. I simply built the area where the script will be used. I'm waiting for him to release the script so the safe zone can really be...a safe zone :p
 
i tested it with this code :
Code:
_args = _this;
 
if(!isNull _args) then {
    _args setVehicleInit "this allowDamage true";
    processInitCommands;
};

and runs great for veh's and players


leolilu, thanks for the testing efforts! i'm assuming this is run server side? I'm still attempting when i get a chance to run this strictly client side on each machine. with each creating the triggers for themselves and seein how that goes. also, does the "processInitCommands" not have lingering effects on JIP players? Or would having that lil function inside the trigger still make it specific to the correct situation (a vehicle/player exiting the trigger)
 
yes vehicleInit needs to exec server side, this will send the statement to all clients, also to this clients that connecting after the command has been executed
if _args = (vehicle player) and player is in a veh, _args = veh object, if player not in veh, _args = player object
you need to create the variabletrigger serverside only
for example by adding this in your mission init.sqf:
Code:
if(isServer) then {
[FONT=Consolas]        "triggerDamageOff" addPublicVariableEventHandler {
                    private ["_args"];
                    _args = _this select 1; //_this = the val of "triggerDamageOff"
                    diag_log format["Server: Damage Off for %1",_args];
                 
                    _args setVehicleInit "this allowDamage false";
                    processInitCommands;
                 
        };
        "triggerDamageOn" addPublicVariableEventHandler {
                    private ["_args"];
                    _args = _this select 1; //_this = the val of "triggerDamageOff"
                    diag_log format["Server: Damage On for %1",_args];
                 
                    _args setVehicleInit "this allowDamage true";
                    processInitCommands;
                 
        };  [/FONT]
};
you can trigger the event with:
Code:
triggerDamageOff= vehicle player;
publicVariableServer "triggerDamageOff";
 
i coded this for my server:

Code:
_radius = 100;  //shield range
_enemy_Base = "ColorRed";  //set enemy color
_friendly_Base = "ColorGreen";  //set friendly color
 
// creating array with available shields
_Baseshields = [];
{
    _Baseshields set [count _Baseshields,_x];
   
} forEach (allMissionObjects "Sign_Checkpoint");  //this is my base shield ;)
 
if ((count _Baseshields) < 1) exitwith {};  // no shields = no need to run this script
waitUntil {{!isNull(_x) && ((getPosATL(_x) distance [0,0,0]) > 100)} count _Baseshields == count _Baseshields};
 
{
        _unit = _x;
        _ShieldID = parseNumber(_unit getVariable["ObjectID","0"]);  //get Object ID (located in the Database of my Custom Hive)
        _playerbaseID = player getVariable["BaseID",-1];  //get Player BaseID (located in the Database of my Custom Hive)
        //create local Markers (green = friendly base, red = enemy base)
        _markerName = format["Base_zone_%1",_ShieldID];   
        deleteMarkerLocal _markerName;
    _marker = createMarkerLocal [_markerName, getPosATL _unit];
    _markerName setMarkerShapeLocal "ELLIPSE";
        if (_ShieldID == _playerbaseID) then
        {
            _markerName setMarkerColorLocal _friendly_Base;
        } else {
            _markerName setMarkerColorLocal _enemy_Base;
        };       
       
    _markerName setMarkerSizeLocal [_radius, _radius];
    _markerName setMarkerBrushLocal "Border";
    _markerName setMarkerAlphaLocal 0.5;
       
        _markerName = format["marker_base_desc_%1",_ShieldID];
        deleteMarkerLocal _markerName;
        _pos = getPosATL _unit;
        _pos set [1, (_pos select 1) - (round(_radius / 2))];
    _marker = createMarkerLocal [_markerName, _pos];
    _markerName setMarkerShapeLocal "ICON";
        _markerName setMarkerTypeLocal "mil_dot";
    _markerName setMarkerSizeLocal [1.8,1.8];
        if (_ShieldID == _playerbaseID) then {
            _markerName setMarkerColorLocal _friendly_Base;
            _markerName setMarkerTextLocal "This is Your Base";
        } else {
            _markerName setMarkerColorLocal _enemy_Base;
            _markerName setMarkerTextLocal "This is an Enemy Base";
        };
        _markerName setMarkerAlphaLocal 0.5;
} forEach _Baseshields;
 
// Switch
if (isNil "activateBaseShields") then {
  activateBaseShields = true;
} else {
  activateBaseShields = !activateBaseShields;
};
// one Loop per sec
while {activateBaseShields} do {   
    private["_ShieldID","_unit","_playerbaseID","_positionPlayer","_setNewPos","_isAdmin","_nearShield"];
    _nearShield = (getPosATL vehicle player) nearEntities ["Sign_Checkpoint",_radius];
    if((count _nearShield) > 0) then {
        {
            _unit = _x;
            _ShieldID = parseNumber(_unit getVariable["ObjectID","0"]);  //get Object ID (located in the Database of my Custom Hive)
            _playerbaseID = player getVariable["BaseID",-1];  //get Player BaseID (located in the Database of my Custom Hive)             
            _isAdmin = player getVariable["isAdmin",false];   
           
            if (_isAdmin) exitWith{};  //i'm sure there is no need to explain this ;p
           
            if(_ShieldID == _playerbaseID) exitWith {  //if this is players base disable damage and exit 'forEach _Baseshields'
                if (vehicle player getVariable["allowDamage",true]) then {  //check damage state
                    triggerDamageOff = vehicle player;
                    publicVariable "triggerDamageOff";
                    vehicle player setVariable["allowDamage",false,true];  //set object variable to check damage state
                    cutText ["AllowDamage: " + str(typeOf vehicle player) + " = " + str(vehicle player getVariable "allowDamage"), "PLAIN DOWN"];  //debug hints
                };
            };                   
            _directionto = [_unit, vehicle player] call BIS_fnc_dirTo;  //BIS Function to get the direction to the Object entering the Zone
            if(_directionto < 0) then {_directionto = _directionto + 360};  //negative direction to positive
            _positionPlayer = getposATL vehicle player;
            _setNewPos = [getposATL _unit,_directionto,(_radius + 1),true] call FindPosition;  //Custom Script to find the Position outside the Zone in direction of the entering Object
            _setNewPos set [2,(_positionPlayer select 2)];  //adding height
            //cutText ["Enemy Base: " + str(_ShieldID) + " PlayerBaseID: " + str(_playerbaseID) + " DirectionTo: " + str(_directionto) + " NewPos: " +str(_setNewPos), "PLAIN DOWN"];
            cutText ["The Baseshield of this Enemy Base is stronger then you! >_<", "PLAIN DOWN"];  //Info to player
            vehicle player setPos _setNewPos;  //kick out not allowed player or vehicle the player is in
            // Check for Damage is allowed
            if (!(vehicle player getVariable["allowDamage",false])) then {  //check damage state
                triggerDamageOn = vehicle player;
                publicVariable "triggerDamageOn";
                vehicle player setVariable["allowDamage",true,true];  //set object variable to check damage state
                cutText ["AllowDamage: " + str(typeOf vehicle player) + " = " + str(vehicle player getVariable "allowDamage"), "PLAIN DOWN"];  //debug hints
            };
        }forEach _nearShield;
    }else {
        // allow Damage if player leaves the zone
        if (!(vehicle player getVariable["allowDamage",false])) then {  //check damage state
            triggerDamageOn = vehicle player;
            publicVariable "triggerDamageOn";
            vehicle player setVariable["allowDamage",true,true];  //set object variable to check damage state
            cutText ["AllowDamage: " + str(typeOf vehicle player) + " = " + str(vehicle player getVariable "allowDamage"), "PLAIN DOWN"]; //debug hints
        };
    };       
    sleep 1;
};

but this will run only with my custom dayz server because im storing the baseid in the database
an my server admins can place a 'shield' and can add a player to this 'shield', after that the added player is safe in this shield and can add other players
players that have a wrong baseid cant move into the range (teleport back to setrange + 1 if player rangeto shield object < setrange) and players that can enter the shield will set allowdamage to false (if player is in a vehicle the vehicle will set allowdamage false)
all shield are marked on the map (red circle for anemy and green for friendly)
the above version of the script can be activated or deactivated by admins with permission
this is the client side script, server is running the trigger that i posted some posts above
the user actions for add and remove players are defined in other scripts
i added some commands so it will be easier to understand that script (i hope)
mybe ths is usefull for someone ^^

/Leo
 
Back
Top