Jump to content

Donnovan

Member
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by Donnovan

  1. Mike, you is right.

    Added two lines based on your post, those lines have a //MIKE POST comment at the end.

    Those two lines are untested, i can't test it now, my wife awaits me.

    WORK TO DO:

    - Make it compatible with Gebriel Safe Zones and Admin Tools so unlocking vehicles in safe does not remove its invunerability set by Gebriel or Admin Tools.

  2. *** UPDATED WITH A MAJOR BUG FIX IN THE DATE 2014-10-06 1:10 PM

    *** This update will fix the Repair Vehicle working always in all cases

    *** without the need of vehicle parts, wheell, glass, motor or tools

    *** The only file that changed was the file lock_god.sqf.

    Hi,

    Here is My Locked Vehicles with God Mode.

    FEATURES:

    - The Vehicles survives Kamikaze attack!

    - The God Mode not expires when the player exit the server!

    - Can be easily upgraded to plot proximity god mode or anything else!

    - Initial locked Vehicles have God Mode!

    INSTALLATION!

    1) LOCK_GOD.SQF

    Create a file with the name lock_god.sqf, with the content bellow, and put it into a folder called custom inside your mission folder.

    if (isServer) then {
    	"cad_pvar_set_veh" addPublicVariableEventHandler {
    		private ["_veh","_godOn"];
    		_veh = _this select 1 select 0;
    		_godOn = _this select 1 select 1;
    		if (_godOn) then {
    			_veh allowDamage false;
    			_veh RemoveAllEventHandlers "handleDamage";
    			_veh addEventHandler ["handleDamage",{0}];
    		} else {
    			_veh allowDamage true;
    			_veh RemoveAllEventHandlers "handleDamage";
    			_veh addEventHandler ["handleDamage",{_this call vehicle_handleDamage;}];
    		};
    	};
    };
    
    local_lockUnlock = {
    	private ["_vehicle","_status"];
    	_vehicle = _this select 0;
    	_status = _this select 1;
    
    	if (local _vehicle || isServer) then {
    		if(_status) then {
    			_vehicle setVehicleLock "LOCKED";
    			if (count (crew _vehicle) == 0) then{ //MIKE POST
    				_vehicle allowDamage false;
    				_vehicle RemoveAllEventHandlers "handleDamage";
    				_vehicle addEventHandler ["handleDamage",{0}];
    				cad_pvar_set_veh = [_vehicle,true];
    				publicVariableServer "cad_pvar_set_veh";
    			}; //MIKE POST
    
    		} else {
    			_vehicle setVehicleLock "UNLOCKED";
    			_vehicle allowDamage true;
    			_vehicle RemoveAllEventHandlers "handleDamage";
    			_vehicle addEventHandler ["handleDamage",{_this call vehicle_handleDamage;}];
    			cad_pvar_set_veh = [_vehicle,false];
    			publicVariableServer "cad_pvar_set_veh";
    		};
    	};
    };
    2)INIT.SQF

    Open your init.sqf (located in your mission folder) and search for that line:

    call compile preprocessFileLineNumbers "z\addons\dayz_code\init\compiles.sqf";	//Compile regular functions
    If you don't find it, search for the line:

    call compile preprocessFileLineNumbers "dayz_code\init\compiles.sqf";	//Compile regular functions
    Bellow it, add the line:

    call compile preprocessFileLineNumbers "custom\lock_god.sqf";
    3) SYSTEM/SERVER_MONITOR.SQF:

    Now, to make initial locked vehicles invunerable until unlocked, you must modify the server_monitor.sqf server file, located in dayz_server/system/server_monitor.sqf:

    Change that:

    if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {
    	_object setvehiclelock "locked";
    };
    
    To that:

    if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then {
    	_object setvehiclelock "locked";
    	//LOCK GOD BEGIN
    	_object allowDamage false;
    	_object RemoveAllEventHandlers "handleDamage";
    	_object addEventHandler ["handleDamage",{0}];						
    	//LOCK GOD END
    };
    
    4) BATTLEYE EXCESSION:

    You need to liberate the public variable cad_pvar_set_veh in BattlEye.

    END

    It's done!

    I have done tests with players of my server. But feel free to make your tests so we have sure everything is ok!

  3. BetterDeadThanZed,

    Have you tried the new code?

    About the FPS decrease along time:

    I noticed the fps decrease along time even with the server not running Joelma's Time Control. So this decrease over time must be something related to the engine/mod/game.

    There is a decrease in fps, yes, but the decrease over time is not Joelma's Time Control fault.

  4. Hi

    This code add a event handler to a vehicle, this event handler is trigered when someone enters the vehicle, and then a message is send to the entering player.

    _vehicle addEventHandler ["GetIn",{
          _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear!","PLAIN DOWN",5] call RE;
    }];
    You can see it uses the RE (remote execution) function to send the message. A simple titleText "Warning: This vehicle will disappear!" would show the text on the player that generated the event handler, and not the player that entered the vehicle.

    But now, i want not to play a message on the entering player screen, i want to play a sound.

    Anyone can help on that?

    Thankyou!

  5. This may be the error correction generating a bigger error in the correction process.

    With the new code (post #61), error at connection will be 0 or near zero, so the error correction process will do it well.

    The error correction process is intended to fix small sync errors and not the initial error that may be of many hours.

  6. This fast forward/backward time happens only when the player firstly conect to the server, and it remains from 0 to 30 seconds?

    This is the client gaining server sync. If so, it's a matter to make this initial sync instantly and not along 30 seconds.

    What do you think?

    To make the initial sync instantly you need to change some code in time_control.sqf:

    Change that:

    		if (isNil "donn_speed") then {
    			donn_speed = ((_this select 1) select 1);
    			[donn_speed*donn_multi] call changeCycles;
    			donn_skipExit = false;
    		} else {
    			if (((_this select 1) select 1) != donn_speed) then {
    				donn_speed = ((_this select 1) select 1);
    				[donn_speed*donn_multi] call changeCycles;
    				donn_skipExit = true;
    			};
    		};
    to that:

    		if (isNil "donn_speed") then {
                            setDate _dateSer; //NEW LINE 1!
                            _date_diff = 0; //NEW LINE 2!
    			donn_speed = ((_this select 1) select 1);
    			[donn_speed*donn_multi] call changeCycles;
    			donn_skipExit = false;
    		} else {
    			if (((_this select 1) select 1) != donn_speed) then {
    				donn_speed = ((_this select 1) select 1);
    				[donn_speed*donn_multi] call changeCycles;
    				donn_skipExit = true;
    			};
    		};
  7. I can't make tests now, i'm with my girlfriend, sorry...  :)

     

    When i got home, at the night of monday, i will make tests.

     

    1 - Until that, you can, may be, check if you have added the server side code.

    2 - Check for rpt errors on the client side, and may be server side too.

    3 - Since your test server runs it ok, try to have at least 2 players at your test server and see if you two are in sync (spectate the other player and ask hin to put the crosshair in the sun/moon, then see if his crosshair is really at the sun/moon, or just compare watchs, like you did before).

     

    I don't believe the code healthy is dependant on player number, so if you run it ok on your test server, i believe it is ok. Just sync tests remains, this is why i askyou to have at least 2 players and check sync.

  8. NEW VERSION OF TIME_CONTROL.SQF (V.3)

    //===========================================
    // Time share: 50% day, 30% dusk, 20% night.
    //===========================================
    private ["_multi","_maxFPS","_overcast","_fog"];
    
    // General Settings
    _multi = 2; 		// 1 for a 4 hours day, 4/3 for a 3 hours day, 2 a for a 2 hours day.
    _maxFPS = true; 	// true = remove clouds and set cycles to minimum for maximum fps.
                            // true require disabled dynamic weather effects.
    
    // increase clouds smoothness and possibily decrease fps
    _xtraSmooth = 1.0; 	// Try values from 1.0 to 1.5 - Powerfull value.
    
    // Static weather, if you have disabled dynamic weather effects.
    _overcast = 0.25; 	// set overcast, from 0 to 1. If _maxFPS = true, it will be 0.
    _fog = 0; 		// set fog, from 0 to 1. 0 - no fog, 1 - full fog.
    
    if (_maxFPS && !isNil "drn_fnc_DynamicWeather_SetWeatherLocal") then {
    	drn_fnc_DynamicWeather_SetWeatherLocal = {};
    };
    if (isNil "drn_fnc_DynamicWeather_SetWeatherLocal" || _maxFPS) then {
    	if (_maxFPS) then {0 setOvercast 0;} else {0 setOvercast _overcast;};
    	0 setFog _fog;
    	setWind [0.3, 0.4, true];
    };
    donn_skipFix = 0;
    donn_multi=_multi;
    donn_maxFPS=_maxFPS;
    if (_maxFPS) then {donn_xs = 1.0;} else {donn_xs = _xtraSmooth;};
    if (!isServer) then {
    	"cad_pvar_server_date" addPublicVariableEventHandler {_this call donn_setdate;};
    	changeCycles = {
    		private ["_col","_cya","_speed"]; _speed = _this select 0;
    		_cya = [[5,13],[5,15],[5,18],[5,21],[5,23],[5,30],[5,40],[5,45],[5,50]];
    		_col = 1; if (donn_maxFPS) then {_col = 0;};
    		switch true do {
    			case (_speed <=   4.0): {donn_cycles = (_cya select 0 select _col)+((ceil((_cya select 0 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=   6.7): {donn_cycles = (_cya select 1 select _col)+((ceil((_cya select 1 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=   8.9): {donn_cycles = (_cya select 2 select _col)+((ceil((_cya select 2 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=  13.4): {donn_cycles = (_cya select 3 select _col)+((ceil((_cya select 3 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=  20.0): {donn_cycles = (_cya select 4 select _col)+((ceil((_cya select 4 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=  40.0): {donn_cycles = (_cya select 5 select _col)+((ceil((_cya select 5 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <=  80.0): {donn_cycles = (_cya select 6 select _col)+((ceil((_cya select 6 select _col)*(donn_xs-1))) min 10)};
    			case (_speed <= 160.0): {donn_cycles = (_cya select 7 select _col)+((ceil((_cya select 7 select _col)*(donn_xs-1))) min 10)};
    			case (_speed >  160.0): {donn_cycles = (_cya select 8 select _col)+((ceil((_cya select 8 select _col)*(donn_xs-1))) min 10)};
    		};
    	};
    	donn_setdate = {
    		private ["_maxError","_sendTime","_dateSer","_dateCli","_date_diff"];
    		
    		if (isNil "drn_fnc_DynamicWeather_SetWeatherLocal") then {
    			if (_maxFPS) then {15 setOvercast 0;} else {15 setOvercast _overcast;};
    			15 setFog _fog;
    			setWind [0.3, 0.4, true];
    		};
    		
    		_dateSer = ((_this select 1) select 0);
    		_dateCli = date;
    		_date_diff = (
    			((_dateSer select 0) - (_dateCli select 0))*12*31*24 +
    			((_dateSer select 1) - (_dateCli select 1))*31*24 +
    			((_dateSer select 2) - (_dateCli select 2))*24 +
    			((_dateSer select 3) - (_dateCli select 3)) +
    			((_dateSer select 4) - (_dateCli select 4))/60
    		);
    		diag_log format ["DATE DIFFERENCE: %1", _date_diff*60];
    		if (isNil "donn_speed") then {
    			donn_speed = ((_this select 1) select 1);
    			[donn_speed*donn_multi] call changeCycles;
    			donn_skipExit = false;
    		} else {
    			if (((_this select 1) select 1) != donn_speed) then {
    				donn_speed = ((_this select 1) select 1);
    				[donn_speed*donn_multi] call changeCycles;
    				donn_skipExit = true;
    			};
    		};
    		_sendTime = 30;
    		donn_skipFix = (_date_diff*3600)/(donn_cycles*_sendTime);
    	};
    };
    waitUntil {!isNil "donn_speed" && !isNil "donn_skipExit"};
    if (isServer) then {donn_cycles = 5;};
    [] spawn {
    	while {true} do {
    		private ["_speed","_cycleTime","_timePixel","_skipTime","_tickTimeLenAvg","_tickTimeInitial","_tickTime","_tickTimeLenLast"];
    		_speed = donn_speed*donn_multi;
    		_cycleTime = 1/donn_cycles;
    		_timePixel = 0;
    		_skipTime = 0;
    		_tickTimeLenAvg = _cycleTime;
    		_tickTimeInitial = diag_tickTime;
    		_tickTime = _tickTimeInitial;
    		donn_skipExit=false;
    		while {!donn_skipExit} do {
    			skipTime ((_timePixel+donn_skipFix)/3600);
    			_skipTime=_skipTime+_timePixel;
    			_tickTimeLenLast=diag_tickTime-_tickTime;
    			_tickTimeLenAvg=(_tickTimeLenAvg*3+_tickTimeLenLast)/4;
    			sleep (_cycleTime*2-_tickTimeLenAvg);
    			_tickTime=_tickTime+_tickTimeLenLast;
    			_timePixel=(_speed-1)*(_tickTime-_tickTimeInitial)-_skipTime;
    		};
    	};
    };
×
×
  • Create New...