Jump to content

[Release] Safe zone vehicle management - 1.0.6


Joshyy

Recommended Posts

This will unlock vehicles that are left inside safezones and if they are not taken within 15 minutes it will remove them.

Step 1.

Define your safe zone positions in config Variables or below #include "configVariables"

DZE_SafeZonePosArray = [
[[4064,11665,0],510], // Bash
[[6326,7809,0],510], // Stary
[[11447,11364,0],510], // Klen
[[12944,12766,0],510], // Hero Camp
[[1606,7803,0],510] // Bandit camp
]; 

^^ above are my safezones, you could also add the aircraft dealer if you wish

Step 2.

go to your server_monitor.sqf located in dayz_server\system

find

Spoiler

_serverVehicleCounter set [count _serverVehicleCounter,_type]; 

then find this below it

Spoiler

           } else {
                _object enableSimulation true;
            };

add this directly below that

  

Spoiler

         {
                if (_object distance (_x select 0) < 150) then { // '150' represents the distance from the safezone where it will check the vehicles
                    _object spawn {
                        _this setVehicleLock "UNLOCKED"; //Unlock the vehicle so its free to take
                        _this setVariable ["CharacterID", "0", true]; // Make sure it stays unlocked if someone has taken it
                        _oldPos = getPosATL _this;
                        diag_log (typeOf _this+' was left inside a safezone! POS: '+str(_oldPos));
                        uiSleep 900; // Wait 15 minutes before deleting
                        if (_this distance _oldPos < 150) then { // Check if it has left the safezone
                            [nil, nil, rSpawn, ["Vehicle "+typeOf _this+" has been deleted due to being left in a safezone after a restart."], {systemChat ("(Vehicle Cleanup): "+(_this select 0)+".")}] call RE;
                            _objectID = _this getVariable ["ObjectID","0"];
                            _objectUID = _this getVariable ["ObjectUID","0"];
                            [_objectID,_objectUID,objNull] spawn server_deleteObj; // Delete it from database
                            if !(isNull _this) then {deleteVehicle _this}; // Delete it from map
                        };
                    };
                };
            } forEach DZE_SafeZonePosArray;

 

This is what it should look like

Spoiler

        if (_object isKindOf "AllVehicles") then {
            _object setVariable ["CharacterID", _ownerID, true];
            _isAir = _object isKindOf "Air";
            {
                _selection = _x select 0;
                _dam = if (!_isAir && {_selection in dayZ_explosiveParts}) then {(_x select 1) min 0.8;} else {_x select 1;};
                _strH = "hit_" + (_selection);
                _object setHit[_selection,_dam];
                _object setVariable [_strH,_dam,true];
            } foreach _hitpoints;
            [_object,"damage"] call server_updateObject;

            _object setFuel _fuel;
            if (!_isSafeObject) then {
                _DZE_VehObjects set [count _DZE_VehObjects,_object]; 
                _object call fnc_veh_ResetEH;
                if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";};
                _serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
            } else {
                _object enableSimulation true;
            };
            {
                if (_object distance (_x select 0) < 150) then { // '150' represents the distance from the safezone where it will check the vehicles
                    _object spawn {
                        _object setVehicleLock "UNLOCKED"; //Unlock the vehicle so its free to take
                        _object setVariable ["CharacterID", "0", true]; // Make sure it stays unlocked if someone has taken it
                        _oldPos = getPosATL _this;
                        diag_log (typeOf _this+' was left inside a safezone! POS: '+str(_oldPos));
                        uiSleep (60 * 15); // Wait 15 minutes before deleting
                        if (_this distance _oldPos < 150) then { // Check if it has left the safezone
                            [nil, nil, rSpawn, ["Vehicle "+typeOf _this+" has been deleted due to being left in a safezone after a restart."], {systemChat ("(Vehicle Cleanup): "+(_this select 0)+".")}] call RE;
                            _objectID = _this getVariable ["ObjectID","0"];
                            _objectUID = _this getVariable ["ObjectUID","0"];
                            [_objectID,_objectUID,objNull] spawn server_deleteObj; // Delete it from database
                            if !(isNull _this) then {deleteVehicle _this}; // Delete it from map
                        };
                    };
                };
            } forEach DZE_SafeZonePosArray;

If you wish to change the settings e.g the range at which it deletes vehicles, or if you want vehicles to be removed faster or instantly simple edit the "uiSleep (60 * 15);" if you want to remove the 15 minute wait, just remove that line of code or comment it out.

 

Leave a comment if you need any help.

Link to comment
Share on other sites

Getting an error

 

Spoiler

14:21:12 "Lada1_TK_CIV_EP1 was left inside a safezone! POS: [6288.01,7717.99,0.000823975]"
14:21:12 Error in expression <elect 0) < 140) then {
_object spawn {
_object setVehicleLock "UNLOCKED";
_obj>
14:21:12   Error position: <_object setVehicleLock "UNLOCKED";
_obj>
14:21:12   Error Undefined variable in expression: _object
14:21:12 File z\addons\dayz_server\system\server_monitor.sqf, line 270
14:21:12 "car_sedan was left inside a safezone! POS: [6726.81,2565.58,0]"
14:21:12 Error in expression <elect 0) < 140) then {
_object spawn {
_object setVehicleLock "UNLOCKED";
_obj>
14:21:12   Error position: <_object setVehicleLock "UNLOCKED";
_obj>
14:21:12   Error Undefined variable in expression: _object
14:21:12 File z\addons\dayz_server\system\server_monitor.sqf, line 270
14:21:14 "LandRover_CZ_EP1 was left inside a safezone! POS: [6887.62,2532.05,0.00199986]"
14:21:14 Error in expression <elect 0) < 140) then {
_object spawn {
_object setVehicleLock "UNLOCKED";
_obj>
14:21:14   Error position: <_object setVehicleLock "UNLOCKED";
_obj>
14:21:14   Error Undefined variable in expression: _object
14:21:14 File z\addons\dayz_server\system\server_monitor.sqf, line 270
14:21:19 "HIVE: BENCHMARK - Server_monitor.sqf finished streaming 302 objects in 15.157 seconds (unscheduled)"
14:21:19 "CSJ_GyroC was left inside a safezone! POS: [12072.7,12667.3,0]"
14:21:19 Error in expression <elect 0) < 140) then {
_object spawn {
_object setVehicleLock "UNLOCKED";
_obj>
14:21:19   Error position: <_object setVehicleLock "UNLOCKED";
_obj>
14:21:19   Error Undefined variable in expression: _object
14:21:19 File z\addons\dayz_server\system\server_monitor.sqf, line 270

 

 

This is my code, I changed the 150 to 140 but thats it. Ill try the default again and see what happens.

 

Spoiler

{
                if (_object distance (_x select 0) < 140) then { // '150' represents the distance from the safezone where it will check the vehicles
                    _object spawn {
                        _object setVehicleLock "UNLOCKED"; //Unlock the vehicle so its free to take
                        _object setVariable ["CharacterID", "0", true]; // Make sure it stays unlocked if someone has taken it
                        _oldPos = getPosATL _this;
                        diag_log (typeOf _this+' was left inside a safezone! POS: '+str(_oldPos));
                        uiSleep (60 * 10); // Wait 15 minutes before deleting
                        if (_this distance _oldPos < 140) then { // Check if it has left the safezone
                            [nil, nil, rSpawn, ["Vehicle "+typeOf _this+" has been deleted due to being left in a safezone after a restart."], {systemChat ("(Vehicle Cleanup): "+(_this select 0)+".")}] call RE;
                            _objectID = _this getVariable ["ObjectID","0"];
                            _objectUID = _this getVariable ["ObjectUID","0"];
                            [_objectID,_objectUID,objNull] spawn server_deleteObj; // Delete it from database
                            if !(isNull _this) then {deleteVehicle _this}; // Delete it from map
                        };
                    };
                };
            } forEach DZE_SafeZonePosArray;

 

Link to comment
Share on other sites

Still same error with default code. Do I need to put _object or something at the top of the file?

 

Spoiler

15:34:24 Error in expression <elect 0) < 150) then {
_object spawn {
_object setVehicleLock "UNLOCKED";
_obj>
15:34:24   Error position: <_object setVehicleLock "UNLOCKED";
_obj>
15:34:24   Error Undefined variable in expression: _object
15:34:24 File z\addons\dayz_server\system\server_monitor.sqf, line 270

 

Link to comment
Share on other sites

when you spawn a thread you need to reference the object in this case as _this. here is some fixed code. 

 

         {
                if (_object distance (_x select 0) < 150) then { // '150' represents the distance from the safezone where it will check the vehicles
                    _object spawn {
                        _this setVehicleLock "UNLOCKED"; //Unlock the vehicle so its free to take
                        _this setVariable ["CharacterID", "0", true]; // Make sure it stays unlocked if someone has taken it
                        _oldPos = getPosATL _this;
                        diag_log (typeOf _this+' was left inside a safezone! POS: '+str(_oldPos));
                        uiSleep 900; // Wait 15 minutes before deleting
                        if (_this distance _oldPos < 150) then { // Check if it has left the safezone
                            [nil, nil, rSpawn, ["Vehicle "+typeOf _this+" has been deleted due to being left in a safezone after a restart."], {systemChat ("(Vehicle Cleanup): "+(_this select 0)+".")}] call RE;
                            _objectID = _this getVariable ["ObjectID","0"];
                            _objectUID = _this getVariable ["ObjectUID","0"];
                            [_objectID,_objectUID,objNull] spawn server_deleteObj; // Delete it from database
                            if !(isNull _this) then {deleteVehicle _this}; // Delete it from map
                        };
                    };
                };
            } forEach DZE_SafeZonePosArray;

 

Link to comment
Share on other sites

10 hours ago, icomrade said:

when you spawn a thread you need to reference the object in this case as _this. here is some fixed code. 

 


         {
                if (_object distance (_x select 0) < 150) then { // '150' represents the distance from the safezone where it will check the vehicles
                    _object spawn {
                        _this setVehicleLock "UNLOCKED"; //Unlock the vehicle so its free to take
                        _this setVariable ["CharacterID", "0", true]; // Make sure it stays unlocked if someone has taken it
                        _oldPos = getPosATL _this;
                        diag_log (typeOf _this+' was left inside a safezone! POS: '+str(_oldPos));
                        uiSleep 900; // Wait 15 minutes before deleting
                        if (_this distance _oldPos < 150) then { // Check if it has left the safezone
                            [nil, nil, rSpawn, ["Vehicle "+typeOf _this+" has been deleted due to being left in a safezone after a restart."], {systemChat ("(Vehicle Cleanup): "+(_this select 0)+".")}] call RE;
                            _objectID = _this getVariable ["ObjectID","0"];
                            _objectUID = _this getVariable ["ObjectUID","0"];
                            [_objectID,_objectUID,objNull] spawn server_deleteObj; // Delete it from database
                            if !(isNull _this) then {deleteVehicle _this}; // Delete it from map
                        };
                    };
                };
            } forEach DZE_SafeZonePosArray;

 

Thanks, updated OP.

 

I added the unlocking right before posting and didn't even realise :D.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 2 weeks later...
  • 2 weeks later...

I think you guys forget not everyone is so seasoned in scripting and still trying to learn the files. not to be rude but condescending comments don't help. for instance I have a server from survival servers. I cant find "Define your safe zone positions in config Variables or below #include "configVariables"". makes no sense to me. I found a tut from juandayz that doesn't seem to apply. I went to my main root/epoch_dayz/addons/dayz_code and copied that over but it has a lot of the same options as my main files. my root has by default by survival servers EpochConfig.sqf, MainSysConfig.sqf and TraderConfig.sqf being called from the init labled //Epoch Config Variables. I pulled the configvariables.sqf from dayz_code. if I add a call in my init and this file has a lot of the same configurations as those custom files they made, will it break my server? the point is, I'm not looking for an opinion on who is a good or bad server provider. I am not as advanced or good as you guys to have my own server box yet. survival servers has been really good so far but "Define your safe zone positions in config Variables or below #include "configVariables" " makes no sense to me as well as many others. Do I put it in one of those premade files? EpochConfig.sqf, MainSysConfig.sqf or TraderConfig.sqf? Do I pull the configvariables file from dayz_code and just call it from my init? Do I put it in my variables.sqf? Do I install suicide script and just pull the trigger?

 

thanks.

a lot of us rely on your knowledge andmost of us wish e knew as much as yall

Link to comment
Share on other sites

4 minutes ago, Jestertriks said:

I think you guys forget not everyone is so seasoned in scripting and still trying to learn the files. not to be rude but condescending comments don't help. for instance I have a server from survival servers. I cant find "Define your safe zone positions in config Variables or below #include "configVariables"". makes no sense to me. I found a tut from juandayz that doesn't seem to apply. I went to my main root/epoch_dayz/addons/dayz_code and copied that over but it has a lot of the same options as my main files. my root has by default by survival servers EpochConfig.sqf, MainSysConfig.sqf and TraderConfig.sqf being called from the init labled //Epoch Config Variables. I pulled the configvariables.sqf from dayz_code. if I add a call in my init and this file has a lot of the same configurations as those custom files they made, will it break my server? the point is, I'm not looking for an opinion on who is a good or bad server provider. I am not as advanced or good as you guys to have my own server box yet. survival servers has been really good so far but "Define your safe zone positions in config Variables or below #include "configVariables" " makes no sense to me as well as many others. Do I put it in one of those premade files? EpochConfig.sqf, MainSysConfig.sqf or TraderConfig.sqf? Do I pull the configvariables file from dayz_code and just call it from my init? Do I put it in my variables.sqf? Do I install suicide script and just pull the trigger?

 

thanks.

a lot of us rely on your knowledge andmost of us wish e knew as much as yall

this is the one i use personally, and i find you can do much more with it.

nothing against your post joshyy, just a different way to tackle the issue at hand :)

Link to comment
Share on other sites

12 minutes ago, Jestertriks said:

I think you guys forget not everyone is so seasoned in scripting and still trying to learn the files. not to be rude but condescending comments don't help. for instance I have a server from survival servers. I cant find "Define your safe zone positions in config Variables or below #include "configVariables"". makes no sense to me. I found a tut from juandayz that doesn't seem to apply. I went to my main root/epoch_dayz/addons/dayz_code and copied that over but it has a lot of the same options as my main files. my root has by default by survival servers EpochConfig.sqf, MainSysConfig.sqf and TraderConfig.sqf being called from the init labled //Epoch Config Variables. I pulled the configvariables.sqf from dayz_code. if I add a call in my init and this file has a lot of the same configurations as those custom files they made, will it break my server? the point is, I'm not looking for an opinion on who is a good or bad server provider. I am not as advanced or good as you guys to have my own server box yet. survival servers has been really good so far but "Define your safe zone positions in config Variables or below #include "configVariables" " makes no sense to me as well as many others. Do I put it in one of those premade files? EpochConfig.sqf, MainSysConfig.sqf or TraderConfig.sqf? Do I pull the configvariables file from dayz_code and just call it from my init? Do I put it in my variables.sqf? Do I install suicide script and just pull the trigger?

 

thanks.

a lot of us rely on your knowledge andmost of us wish e knew as much as yall

I'm still learning as well. I used to go though gtx before i got my box and they did not have half the files either. What you should be able to do is make a file name it like something customVariables.sqf  in a custom folder

Add this into it

Spoiler

DZE_SafeZonePosArray = [
[[4064,11665,0],510], // Bash
[[6326,7809,0],510], // Stary
[[11447,11364,0],510], // Klen
[[12944,12766,0],510], // Hero Camp
[[1606,7803,0],510] // Bandit camp
]; 

then add in your mission init.sqf

Spoiler

#include "custom\customVariables.sqf" 

Under

Spoiler

enableRadio false;
enableSentences false;

 

Link to comment
Share on other sites

Thank you @Hooty. That's exactly what I was confused about because they created theyre own files. I loved GTX till they took the .dll editing away and limited access to the database. Survival servers are not the greatest with support but eventually they get to answering you. GTX use to answer with-in 1-2 minutes, it was amazing for when the server box went down or I got ddossed or some crap like that. it sucks waiting a day or more for survival servers. I cant wait till I grasp more of the scripting and move on to my own box or rent one from OVH

 

thanks a lot for your time

Link to comment
Share on other sites

Configvariables.sqf is inside the dayz_code.pbo in the @dayz_epoch folder.

Simply copy that file and place it inside your mission folder somewhere.

In your init.sqf, where its says

#include "\z\addons\dayz_code\configVariables.sqf" // Don't remove this line

directly below this put

#include "thefilepathyouputthefile\configVariables.sqf"

You can then comment out the orignal line so it looks like

//#include "\z\addons\dayz_code\configVariables.sqf" // Don't remove this line

 

Once you have done that, you can add the safezone array to the configvariable.sqf file you just made.

 

Link to comment
Share on other sites

Thank you for responding lwbuk. What I'm mainly asking is, if I do what your saying. The configvariables.sqf has most of the configurations: Plot management, snap build, dynamic vehicles, ect.... as the files I have in my root. if I make a call to that file after dragging it over, will it conflict since they will be there twice?

 

Hooty's example was perfect although I went with using thedukes suggestion for I did not know that files would still work with 1.0.6. I used that in my 1.0.5.1 and it worked great

Link to comment
Share on other sites

1 hour ago, Jestertriks said:

Thank you @Hooty. That's exactly what I was confused about because they created theyre own files. I loved GTX till they took the .dll editing away and limited access to the database. Survival servers are not the greatest with support but eventually they get to answering you. GTX use to answer with-in 1-2 minutes, it was amazing for when the server box went down or I got ddossed or some crap like that. it sucks waiting a day or more for survival servers. I cant wait till I grasp more of the scripting and move on to my own box or rent one from OVH

 

thanks a lot for your time

No problem. Happy to help.

Link to comment
Share on other sites

Without knowing exactly how the file structure has been made its hard to say. Youll probably have various calls in your init.sqf to all the different config files, which you could in theroy delete and just use the deafult ones.

HOWEVER.

If the host has gone to trouble of messing with the files that much and creating loads of pointless extra config files, its probably not worth the hassle of changing it around trying to find all the different calls and mentions of these extra files.

I dont know why these hosting compnaies make life so difficult for people, its supposed to be the easlier option.

Link to comment
Share on other sites

Yes. I feel they are just trying to make make it easy to config the server for users. maybe be different from other hosts. that's why Hooty's answer is perfect for a generic file edit that applies to all users. I wasn't sure if it would overwrite the default and work to simply just add that call command.

Link to comment
Share on other sites

@Jestertriks the configvariables in dayz_code folder is some default options. You can copy that file over to mission side in its entirety and change the call in the init to read your new copy OR you can just copy PARTS of that file and add it to your init or as many people like to do and is a good idea if adding a lot of scripts is to have a custom variables file that gets called in your init AFTER the original configvariables from dayz_code.

#include "\z\addons\dayz_code\configVariables.sqf" // Don't remove this line (around line 47 for me) all these variables get loaded into memory

The first item in configVariables.sqf is 
dayz_knifeDulling = false;

Lets assume we want to make this TRUE

We can set this as true by adding the line to the init.sqf 
dayz_knifeDulling =  true;
we must add this line AFTER the default variables are loaded. in my case AFTER line 47. otherwise we set it true and then we load configVariables and that sets it false again.

around line 140 in my init i have
call compile preprocessFileLineNumbers "dayz_code\init\variables.sqf";  // this is my custom variables file. its getting loaded toward the end of the init so anything in here will overwrite configVariables.sqf and anything i have defined in the init before this line.

You can also ADD to variables.

DZE_PlotManagementAdmins = ["1234567890"]; // assume this is in your init

then later in your custom configs...
DZE_PlotManagementAdmins = DZE_PlotManagementAdmins  + someOtherListof_Admins; // the format of this code is wrong cause im an idiot . The goal is to just tell you it can be done lol.

 

Link to comment
Share on other sites

Hey,

got this error in RPT:

16:10:17 Error in expression <enableSimulation true;
};
{
if (_object distance (_x select 0) < 150) then { 
_o>
16:10:17   Error position: <distance (_x select 0) < 150) then { 
_o>
16:10:17   Error distance: Typ Zahl, erwartet Array,Objekt,Location
16:10:17 File z\addons\dayz_server\system\server_monitor.sqf, line 293

 

Link to comment
Share on other sites

  • 1 year later...

Hey guys...
First of all thanks a lot for all the work you are doing, I am learning step by step with all "trial and error" steps but... little by little and with all I read here, I am getting some advances.

So now I have a question for developers, and considering I am a beginner in the area, is there a way (guide, advice, code pre design) to creat something like a "safe zone" but backwards.

Meaning, We want to make Cherno and Electro "PvP areas".  My idea is to mark them in map as the safezones but when you enter you have the announcemente that "you entered a PvP area".  
I would be thankfull for any kind of advice and or suggestion.

Link to comment
Share on other sites

On 4/4/2018 at 10:51 PM, LadyVal said:

Hey guys...
First of all thanks a lot for all the work you are doing, I am learning step by step with all "trial and error" steps but... little by little and with all I read here, I am getting some advances.

So now I have a question for developers, and considering I am a beginner in the area, is there a way (guide, advice, code pre design) to creat something like a "safe zone" but backwards.

Meaning, We want to make Cherno and Electro "PvP areas".  My idea is to mark them in map as the safezones but when you enter you have the announcemente that "you entered a PvP area".  
I would be thankfull for any kind of advice and or suggestion.

If you look into your mission.sqm you can see an area that notifies you when you enter the safezone. You can add 2 more entries and have them for your two PvP areas, just increase the area you are notified. Just be sure to increase the "items=6" to however many you add to the list.
 

Spoiler

 


class Sensors
	{
		items=6;
#define TRGDEF a=100;b=100;activationBy="WEST";repeating=1;interruptable=1;age="UNKNOWN";class Effects{};
		class Item0
		{
			position[]={6325,304,7807};
			TRGDEF
			name="zonestary";
			expCond="(player distance zonestary) < 100;";
			expActiv="[""trader city Stary"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Stary"",true,""leave""] call player_traderCity;";
		};
		class Item1
		{
			position[]={4063,365,11664};
			TRGDEF
			name="zonebash";
			expCond="(player distance zonebash) < 100;";
			expActiv="[""trader city Bash"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Bash"",true,""leave""] call player_traderCity;";
		};
		class Item2
		{
			position[]={11447,317,11364};
			TRGDEF
			name="zoneklen";
			expCond="(player distance zoneklen) < 100;";
			expActiv="[""trader city Klen"",true,""enter""] call player_traderCity;";
			expDesactiv="[""trader city Klen"",true,""leave""] call player_traderCity;";
		};
		class Item3
		{
			position[]={1606,289,7803};
			TRGDEF
			name="zonebandit";
			expCond="(player distance zonebandit) < 100;";
			expActiv="[""Bandit Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Bandit Trader"",false,""leave""] call player_traderCity;";
		};
		class Item4
		{
			position[]={12944,210,12766};
			TRGDEF
			name="zonehero";
			expCond="(player distance zonehero) < 100;";
			expActiv="[""Hero Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Hero Trader"",false,""leave""] call player_traderCity;";
		};
		class Item5
		{
			position[]={12060,158,12638}; 
			TRGDEF
			name="zoneaircraft";
			expCond="(player distance zoneaircraft) < 100;";
			expActiv="[""Aircraft Trader"",false,""enter""] call player_traderCity;";
			expDesactiv="[""Aircraft Trader"",false,""leave""] call player_traderCity;";
		};
	};
};

 

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...