Jump to content

[Release] Andre Safe Zones


Donnovan

Recommended Posts

If you like my work, please consider a donation:

btn_donate_LG.gif $USD

btn_donate_LG.gif $EURO

ANDRE SAFE ZONE

. Vehicle Gear Protection (except for players in your group)
. Player Gear Protection (except for players in your group)
. Player Can't Shot
. Player Can't Die
. Turret cant' shot
. Vehicle does not take damage
. Vehicle can't be stolen
. Protected vehicles liberated after some time

INSTALATION

Run the script from the mission file init.sqf with execVM "andre_safezone.sqf";. You must run from the root (not inside a isServer or !isServer or any other condition):

execVM "andre_safezone.sqf"; //exec it on the root on init.sqf

if (isServer) then {
    //code 1...
    //code 2...
    //code 3...
    //DO NOT EXEC IT HERE!
} else {
    //code 4...`
    //code 5...
    //code 6...
    //DO NOT EXEC IT HERE!
};

 
THE SCRIPT: if you use Epoch Anti Hack
 
Ready for Altis. You can change the Konfiguration part to meet the map you is using and/or to add more safe zones.

*Put this file in the root of your mission file, with the name andre_safezone.sqf.

//===============
// KONFIGURATION
//===============

//Altis Safezones
donn_traders = [
	["Altis Trader City 1",[13323,14527,0]],
	["Altis Trader City 2",[6177,16835,0]],
	["Altis Trader City 3",[18460,14259,0]]
];

//====================
// CLIENT SIDE SCRIPT
//====================

if (hasInterface) then {
	//SENSORS
	donn_notSafe = true;
	donn_safeZone_name = "(nothing)";
	{
		_x spawn {
			private ["_dist","_tPos","_tName","_maxVel","_tRad"];
			_tName = _this select 0;
			_tPos = _this select 1;
			_maxVel = 100;
			_tRad = 250;
			waitUntil {sleep 0.25;speed player > 1};
			while {true} do {
				_dist = player distance _tPos;
				while {_dist > 150} do {
					sleep ((((_dist - _tRad)/_maxVel) max 0.25) min 5);
					_dist = player distance  _tPos;
				};
				donn_notSafe = false;
				donn_safeZone_name = _tName;
				systemChat ("You are in safezone city: " + _tName);
				while {_dist < 150} do {
					sleep 0.25;
					_dist = player distance _tPos;
				};
				donn_notSafe = true;
				donn_safeZone_name = "(nenhuma)";
				systemChat ("You leaved safezone city: " + _tName);
			};
		};
	} forEach donn_traders;

	//Safe zone Functions
	donn_avoidGearAccess = {
		_protecting = [];
		_toProtect = donn_pv_protected_veh select 1;
		_toUnprotect = [];
		_protectVersion = donn_pv_protected_veh select 0;
		while {!donn_notSafe} do {
			{
				_x addEventHandler ["ContainerOpened", {
					_veh = _this select 0;
					_player = _this select 1;
					_veh_crew = _veh getVariable ['don_crew', nil];
					if (isNil '_veh_crew') then {_veh_crew = [getPlayerUID _player];};
					_groupUnits = units _player;
					_canAccess = false;
					{
						if (getPlayerUID _x in _veh_crew) then {
							_canAccess = true;
						};
					} forEach _groupUnits;
					if (!_canAccess)then {
						systemChat format ['%1, you cant access this gear.', name _player];
						_player action ["Gear", objNull];
					};
				}];
			} forEach _toProtect;
			{
				_x removeAllEventHandlers "ContainerOpened";
			} forEach _toUnprotect;
			_protecting = _protecting + _toProtect - _toUnprotect;
			waitUntil {sleep 0.2;donn_pv_protected_veh select 0 > _protectVersion};
			_toProtect = (donn_pv_protected_veh select 1) - _protecting;
			_toUnprotect = _protecting - (donn_pv_protected_veh select 1);
		};
		{
			_x removeAllEventHandlers "ContainerOpened";
		} forEach _protecting;
	};
	
	//Safezone
	don_incar = false;
	don_firedEH_1 = nil;
	donn_godMode = false;
	[] spawn {
		private ['_runOneTime','_donn_notSafe','_don_passengers','_don_veh_crew','_don_player_veh','_don_veh_driver'];
		waitUntil {!(isNil 'donn_notSafe')};
		_runOneTime = false;
		_donn_notSafe = donn_notSafe;
		while {true} do {
			waitUntil {!((_donn_notSafe && donn_notSafe) || (!_donn_notSafe && !donn_notSafe)) || !_runOneTime};
			_donn_notSafe = donn_notSafe;
			if (!_donn_notSafe) then {
				//Player God Mode
				player allowDamage false;
				donn_sz_fired = player addEventHandler ['Fired',{deleteVehicle (_this select 6);}];
				donn_godMode = true;
				
				//Protect Player Gear
				donn_pv_protected_veh_add = player;
				publicVariableServer "donn_pv_protected_veh_add";
				
				//Avoid player to access other Gears (turn off is automatic)
				[] spawn donn_avoidGearAccess;
			};
			if (_donn_notSafe && _runOneTime) then {
				//Player God Mode Off
				player allowDamage true;
				player removeEventHandler ["Fired",donn_sz_fired];
				donn_godMode = false;
				
				//Clear Player Gear Protection
				donn_pv_protected_veh_sub = player;
				publicVariableServer "donn_pv_protected_veh_sub";
			};
			if (!_donn_notSafe && don_incar) then {
				
				//Get Info
				_don_player_veh = don_player_veh;
				don_veh_crew = crew _don_player_veh;
				_don_veh_driver = driver _don_player_veh;
				
				if (player == _don_veh_driver) then {
					//Car God Mode
					_don_player_veh allowDamage false;
					_don_player_veh removeAllEventHandlers 'handleDamage';
					_don_player_veh addEventHandler ['handleDamage', {0}];
					_don_player_veh removeAllEventHandlers 'Fired';
					_don_player_veh addEventHandler ['Fired',{deleteVehicle (_this select 6);}];
					
					//Passenger Names
					_don_passengers = '';
					{if (alive _x) then {_don_passengers = _don_passengers + format [' %1',name _x];};} forEach don_veh_crew;
					
					//Passenger PlayerUID
					_don_veh_crew = [];
					{if (alive _x) then {_don_veh_crew = _don_veh_crew + [getPlayerUID _x];};} forEach don_veh_crew;

					//Put info on Vehicle
					_don_player_veh setVariable ['don_ownerity_code', format ['%1_%2', getPlayerUID player, round diag_tickTime], true];
					_don_player_veh setVariable ['don_crew', _don_veh_crew, true];
					_don_player_veh setVariable ['don_passengers', _don_passengers, true];

					//Protect Vehicle Gear
					donn_pv_protected_veh_add = _don_player_veh;
					publicVariable "donn_pv_protected_veh_add";
				};
				
			};
			if (_donn_notSafe && don_incar && _runOneTime) then {
				
				//Get Info
				_don_player_veh = don_player_veh;
				_don_veh_driver = driver _don_player_veh;			
				
				if (player == _don_veh_driver) then {
					//Clear Vehicle Protection Variables
					_don_player_veh setVariable ['don_ownerity_code', nil, true];
					_don_player_veh setVariable ['don_crew', nil, true];
					_don_player_veh setVariable ['don_passengers', nil, true];
				
					//Car God Mode Off
					_don_player_veh allowDamage true;
					_don_player_veh removeAllEventHandlers 'handleDamage';
					_don_player_veh removeAllEventHandlers 'Fired';
					
					//Clear Vehicle Gear Protection
					donn_pv_protected_veh_sub = _don_player_veh;
					publicVariableServer "donn_pv_protected_veh_sub";
				};
			};
			_runOneTime = true;
		};
	};
	[] spawn {
		private ['_don_veh_crew','_wait_time','_last_mark','_max_time'];
		while {true} do {
			_max_time = 480;
			waitUntil {sleep 0.0625; vehicle player != player};
			don_player_veh = vehicle player;
			don_incar = true;
			if (!donn_notSafe) then {
				_don_veh_crew = don_player_veh getVariable ['don_crew', nil];
				if (isNil '_don_veh_crew') then {_don_veh_crew = [getPlayerUID player];};
				_groupUnits = units player;
				_canAccess = false;
				{
					if (getPlayerUID _x in _don_veh_crew) then {
						_canAccess = true;
					};
				} forEach _groupUnits;
				if (!_canAccess) then {
					call compile format ['if (isNil ''don_%1'') then {don_%1 = diag_tickTime;}; _last_mark = don_%1;', don_player_veh getVariable ['don_ownerity_code', 0]];
					_wait_time = diag_tickTime - _last_mark;
					if (_wait_time < _max_time) then {
						while {player != vehicle player} do {
							player action ['getOut', don_player_veh];
							uiSleep 0.01;
						};
						cuttext [format ['Owners:%1. %2 seconds to liberate.', don_player_veh getVariable ['don_passengers','Owners not found'], round (_max_time - _wait_time)], 'PLAIN DOWN'];
						cad_pvar_smessage = [format ['%1 is messing with your vehicle! %2 seconds to liberate!', name player, round (_max_time - _wait_time)], _don_veh_crew];
						publicVariable 'cad_pvar_smessage';
					} else {
						call compile format ['don_%1 = nil;', don_player_veh getVariable ['don_ownerity_code', 0]];
						don_player_veh setVariable ['don_ownerity_code', nil, true];
						don_player_veh setVariable ['don_crew', nil, true];
						don_player_veh setVariable ['don_passengers', nil, true];
						cuttext [format ['Vehicle is now free for all!'], 'PLAIN DOWN'];
						cad_pvar_smessage = [format ['Vehicle invaded by %1!', name player], _don_veh_crew];
						publicVariable 'cad_pvar_smessage';
					};
				};
				don_player_veh allowDamage false;
				don_player_veh removeAllEventHandlers 'handleDamage';
				don_player_veh addEventHandler ['handleDamage', {0}];
				don_player_veh removeAllEventHandlers 'Fired';
				don_player_veh addEventHandler ['Fired',{deleteVehicle (_this select 6);}];
			};
			if (donn_notSafe) then {
				don_player_veh allowDamage true;
				don_player_veh removeAllEventHandlers 'handleDamage';
				don_player_veh removeAllEventHandlers 'Fired';
				if (player == driver don_player_veh) then {
					don_player_veh setVariable ['don_ownerity_code', nil, true];
					don_player_veh setVariable ['don_crew', nil, true];
					don_player_veh setVariable ['don_passengers', nil, true];
				};
			};
			waitUntil {sleep 0.0625; vehicle player == player};
			don_incar = false;
			don_player_veh = nil;
		};
	};
	//Remote Mensages
	'cad_pvar_smessage' addPublicVariableEventHandler {
		private ['_message', '_receivers'];
		_message = (_this select 1) select 0; _receivers = (_this select 1) select 1;
		if (getPlayerUID player in _receivers) then {cutText [_message, 'PLAIN DOWN'];};
	};
	diag_log "! SAZON OK !";
};

//=============
// SERVER SIDE
//=============
if (isServer) then {
	//DONN SaZon Protected Veh
	donn_pv_protected_veh = [0,[]];
	publicVariable "donn_pv_protected_veh";
	"donn_pv_protected_veh_add" addPublicVariableEventHandler {
		donn_pv_protected_veh set [0,(donn_pv_protected_veh select 0) + 1];
		donn_pv_protected_veh set [1,(donn_pv_protected_veh select 1) + [_this select 1]];
		publicVariable "donn_pv_protected_veh";
		diag_log ("[SAZON] Added veh to protection: " + str (_this select 1));
	};
	"donn_pv_protected_veh_sub" addPublicVariableEventHandler {
		donn_pv_protected_veh set [0,(donn_pv_protected_veh select 0) + 1];
		donn_pv_protected_veh set [1,(donn_pv_protected_veh select 1) - [_this select 1]];
		publicVariable "donn_pv_protected_veh";
		diag_log ("[SAZON] Deadded veh to protection: " + str (_this select 1));
	};
};

 
 
THE SCRIPT: if you use infi-STAR Anti Hack
 
Ready for Altis. You can change the Konfiguration part to meet the map you is using and/or to add more safe zones.

*Put this file in the root of your mission file, with the name andre_safezone.sqf.

//===============
// KONFIGURATION
//===============

//Altis Safezones
donn_traders = [
	["Altis Trader City 1",[13323,14527,0]],
	["Altis Trader City 2",[6177,16835,0]],
	["Altis Trader City 3",[18460,14259,0]]
];

//====================
// CLIENT SIDE SCRIPT
//====================

if (hasInterface) then {
	//SENSORS
	donn_notSafe = true;
	donn_safeZone_name = "(nothing)";
	{
		_x spawn {
			private ["_dist","_tPos","_tName","_maxVel","_tRad"];
			_tName = _this select 0;
			_tPos = _this select 1;
			_maxVel = 100;
			_tRad = 250;
			waitUntil {sleep 0.25;speed player > 1};
			while {true} do {
				_dist = player distance _tPos;
				while {_dist > 150} do {
					sleep ((((_dist - _tRad)/_maxVel) max 0.25) min 5);
					_dist = player distance  _tPos;
				};
				donn_notSafe = false;
				inSafeZone = true; //NEW LINE 1
				donn_safeZone_name = _tName;
				systemChat ("You are in safezone city: " + _tName);
				while {_dist < 150} do {
					sleep 0.25;
					_dist = player distance _tPos;
				};
				donn_notSafe = true;
				inSafeZone = false; //NEW LINE 2
				donn_safeZone_name = "(nenhuma)";
				systemChat ("You leaved safezone city: " + _tName);
			};
		};
	} forEach donn_traders;

	//Safe zone Functions
	donn_avoidGearAccess = {
		_protecting = [];
		_toProtect = donn_pv_protected_veh select 1;
		_toUnprotect = [];
		_protectVersion = donn_pv_protected_veh select 0;
		while {!donn_notSafe} do {
			{
				_x addEventHandler ["ContainerOpened", {
					_veh = _this select 0;
					_player = _this select 1;
					_veh_crew = _veh getVariable ['don_crew', nil];
					if (isNil '_veh_crew') then {_veh_crew = [getPlayerUID _player];};
					_groupUnits = units _player;
					_canAccess = false;
					{
						if (getPlayerUID _x in _veh_crew) then {
							_canAccess = true;
						};
					} forEach _groupUnits;
					if (!_canAccess)then {
						systemChat format ['%1, you cant access this gear.', name _player];
						_player action ["Gear", objNull];
					};
				}];
			} forEach _toProtect;
			{
				_x removeAllEventHandlers "ContainerOpened";
			} forEach _toUnprotect;
			_protecting = _protecting + _toProtect - _toUnprotect;
			waitUntil {sleep 0.2;donn_pv_protected_veh select 0 > _protectVersion};
			_toProtect = (donn_pv_protected_veh select 1) - _protecting;
			_toUnprotect = _protecting - (donn_pv_protected_veh select 1);
		};
		{
			_x removeAllEventHandlers "ContainerOpened";
		} forEach _protecting;
	};
	
	//Safezone
	don_incar = false;
	donn_godMode = false;
	[] spawn {
		private ['_runOneTime','_donn_notSafe','_don_passengers','_don_veh_crew','_don_player_veh','_don_veh_driver'];
		waitUntil {!(isNil 'donn_notSafe')};
		_runOneTime = false;
		_donn_notSafe = donn_notSafe;
		while {true} do {
			waitUntil {!((_donn_notSafe && donn_notSafe) || (!_donn_notSafe && !donn_notSafe)) || !_runOneTime};
			_donn_notSafe = donn_notSafe;
			if (!_donn_notSafe) then {
				//Player God Mode
				player allowDamage false;
				donn_godMode = true;
				
				//Protect Player Gear
				donn_pv_protected_veh_add = player;
				publicVariableServer "donn_pv_protected_veh_add";
				
				//Avoid player to access other Gears (turn off is automatic)
				[] spawn donn_avoidGearAccess;
			};
			if (_donn_notSafe && _runOneTime) then {
				//Player God Mode Off
				player allowDamage true;
				donn_godMode = false;
				
				//Clear Player Gear Protection
				donn_pv_protected_veh_sub = player;
				publicVariableServer "donn_pv_protected_veh_sub";
			};
			if (!_donn_notSafe && don_incar) then {
				
				//Get Info
				_don_player_veh = don_player_veh;
				don_veh_crew = crew _don_player_veh;
				_don_veh_driver = driver _don_player_veh;
				
				if (player == _don_veh_driver) then {
					//Car God Mode
					_don_player_veh allowDamage false;
					_don_player_veh removeAllEventHandlers 'handleDamage';
					_don_player_veh addEventHandler ['handleDamage', {0}];
					_don_player_veh removeAllEventHandlers 'Fired';
					_don_player_veh addEventHandler ['Fired',{deleteVehicle (_this select 6);}];
					
					//Passenger Names
					_don_passengers = '';
					{if (alive _x) then {_don_passengers = _don_passengers + format [' %1',name _x];};} forEach don_veh_crew;
					
					//Passenger PlayerUID
					_don_veh_crew = [];
					{if (alive _x) then {_don_veh_crew = _don_veh_crew + [getPlayerUID _x];};} forEach don_veh_crew;

					//Put info on Vehicle
					_don_player_veh setVariable ['don_ownerity_code', format ['%1_%2', getPlayerUID player, round diag_tickTime], true];
					_don_player_veh setVariable ['don_crew', _don_veh_crew, true];
					_don_player_veh setVariable ['don_passengers', _don_passengers, true];

					//Protect Vehicle Gear
					donn_pv_protected_veh_add = _don_player_veh;
					publicVariable "donn_pv_protected_veh_add";
				};
				
			};
			if (_donn_notSafe && don_incar && _runOneTime) then {
				
				//Get Info
				_don_player_veh = don_player_veh;
				_don_veh_driver = driver _don_player_veh;			
				
				if (player == _don_veh_driver) then {
					//Clear Vehicle Protection Variables
					_don_player_veh setVariable ['don_ownerity_code', nil, true];
					_don_player_veh setVariable ['don_crew', nil, true];
					_don_player_veh setVariable ['don_passengers', nil, true];
				
					//Car God Mode Off
					_don_player_veh allowDamage true;
					_don_player_veh removeAllEventHandlers 'handleDamage';
					_don_player_veh removeAllEventHandlers 'Fired';
					
					//Clear Vehicle Gear Protection
					donn_pv_protected_veh_sub = _don_player_veh;
					publicVariableServer "donn_pv_protected_veh_sub";
				};
			};
			_runOneTime = true;
		};
	};
	[] spawn {
		private ['_don_veh_crew','_wait_time','_last_mark','_max_time'];
		while {true} do {
			_max_time = 480;
			waitUntil {sleep 0.0625; vehicle player != player};
			don_player_veh = vehicle player;
			don_incar = true;
			if (!donn_notSafe) then {
				_don_veh_crew = don_player_veh getVariable ['don_crew', nil];
				if (isNil '_don_veh_crew') then {_don_veh_crew = [getPlayerUID player];};
				_groupUnits = units player;
				_canAccess = false;
				{
					if (getPlayerUID _x in _don_veh_crew) then {
						_canAccess = true;
					};
				} forEach _groupUnits;
				if (!_canAccess) then {
					call compile format ['if (isNil ''don_%1'') then {don_%1 = diag_tickTime;}; _last_mark = don_%1;', don_player_veh getVariable ['don_ownerity_code', 0]];
					_wait_time = diag_tickTime - _last_mark;
					if (_wait_time < _max_time) then {
						while {player != vehicle player} do {
							player action ['getOut', don_player_veh];
							uiSleep 0.01;
						};
						cuttext [format ['Owners:%1. %2 seconds to liberate.', don_player_veh getVariable ['don_passengers','Owners not found'], round (_max_time - _wait_time)], 'PLAIN DOWN'];
						cad_pvar_smessage = [format ['%1 is messing with your vehicle! %2 seconds to liberate!', name player, round (_max_time - _wait_time)], _don_veh_crew];
						publicVariable 'cad_pvar_smessage';
					} else {
						call compile format ['don_%1 = nil;', don_player_veh getVariable ['don_ownerity_code', 0]];
						don_player_veh setVariable ['don_ownerity_code', nil, true];
						don_player_veh setVariable ['don_crew', nil, true];
						don_player_veh setVariable ['don_passengers', nil, true];
						cuttext [format ['Vehicle is now free for all!'], 'PLAIN DOWN'];
						cad_pvar_smessage = [format ['Vehicle invaded by %1!', name player], _don_veh_crew];
						publicVariable 'cad_pvar_smessage';
					};
				};
				don_player_veh allowDamage false;
				don_player_veh removeAllEventHandlers 'handleDamage';
				don_player_veh addEventHandler ['handleDamage', {0}];
				don_player_veh removeAllEventHandlers 'Fired';
				don_player_veh addEventHandler ['Fired',{deleteVehicle (_this select 6);}];
			};
			if (donn_notSafe) then {
				don_player_veh allowDamage true;
				don_player_veh removeAllEventHandlers 'handleDamage';
				don_player_veh removeAllEventHandlers 'Fired';
				if (player == driver don_player_veh) then {
					don_player_veh setVariable ['don_ownerity_code', nil, true];
					don_player_veh setVariable ['don_crew', nil, true];
					don_player_veh setVariable ['don_passengers', nil, true];
				};
			};
			waitUntil {sleep 0.0625; vehicle player == player};
			don_incar = false;
			don_player_veh = nil;
		};
	};
	//Remote Mensages
	'cad_pvar_smessage' addPublicVariableEventHandler {
		private ['_message', '_receivers'];
		_message = (_this select 1) select 0; _receivers = (_this select 1) select 1;
		if (getPlayerUID player in _receivers) then {cutText [_message, 'PLAIN DOWN'];};
	};
	diag_log "! SAZON OK !";
};

//=============
// SERVER SIDE
//=============
if (isServer) then {
	//DONN SaZon Protected Veh
	donn_pv_protected_veh = [0,[]];
	publicVariable "donn_pv_protected_veh";
	"donn_pv_protected_veh_add" addPublicVariableEventHandler {
		donn_pv_protected_veh set [0,(donn_pv_protected_veh select 0) + 1];
		donn_pv_protected_veh set [1,(donn_pv_protected_veh select 1) + [_this select 1]];
		publicVariable "donn_pv_protected_veh";
		diag_log ("[SAZON] Added veh to protection: " + str (_this select 1));
	};
	"donn_pv_protected_veh_sub" addPublicVariableEventHandler {
		donn_pv_protected_veh set [0,(donn_pv_protected_veh select 0) + 1];
		donn_pv_protected_veh set [1,(donn_pv_protected_veh select 1) - [_this select 1]];
		publicVariable "donn_pv_protected_veh";
		diag_log ("[SAZON] Deadded veh to protection: " + str (_this select 1));
	};
};

BE FILTERS TWEAK
 
FOR THE ORIGINAL EPOCH 0.3.0.2 FILTERS: My changes are after /*DONN*/.
 
scripts.txt: You need to change 4 lines.

7 allowDamage !="player allowDamage true;vehicle player allowDamage true;" !="player allowDamage false;{missionNamespace setVariable[format['EPOCH_player%1" /*DONN*/ !="(_|)don_player_veh allowDamage"
 
7 exec !="<execute expression=" !"RscDebugConsole_execute" !"execFSM" !"_executeStackedEventHandler" !"fn_execVM" !"fn_moduleExecute" !"fn_execRemote" !"fn_MPexec" !"bis_fnc_moduleExecute_activate" !"fn_tridentExecute" !"randomize_civ1" !"executed from" !"EPOCH_DebugGUI_exec" !"_handle = [_display] execVM _script;" !"execVM \"\A3\Structures_F\scripts" !="execVM \"\A3\Structures_F_EPC\Civ\PlayGround\scripts\Carousel_spin.sqf\"" !="reviveExecuteTemplates" /*DONN*/ !="execVM \"andre_safezone.sqf\";"
 
7 removeEventHandler !="displayRemoveEventHandler" !="player removeEventHandler ['Fired', 0];" !"_currentTarget removeEventHandler[\"EpeContactStart\", _onContactEH]" !" [_adminVar,objnull];\npublicvariable _adminVar;\nplayer removeeventhandler [\"respawn\",_respawn];" !="_plyr removeEventHandler [\"FiredNear\", _smokeEH];" /*DONN*/ !="player removeEventHandler [\"Fired\",donn_sz_fired]"

 

7 removeAllEventHandlers !="ctrlRemoveAllEventHandlers" !="_vehicle removeAllEventHandlers \"GetOut\";" !="_sapper removeAllEventHandlers \"Hit\";\n_sapper removeAllEventHandlers \"FiredNear\";" /*DONN*/ !="_x removeAllEventHandlers \"ContainerOpened\";"
 
7 GodMode /*DONN*/ !="donn_godMode"

publicvariable.txt: You need to change 1 line.

5 "" !="EPOCH_(UP|SAVE|PAINT|MAINT|REM)BUILD" !="EPOCH_(say3D|switchMove|(store|take)Crypto|TEMPOBJ|packJack|selectedGender)_PVS" !="EPOCH_(mineRocks|create(Object|AirDrop)|FillContainer|SapperObjs)_PVS" !="EPOCH_(load|revive|dead|push|force|respawn|check)Player_PVS" !="EPOCH_(build|equipped)Item_PVS" !="EPOCH_GROUP_(Upgrade|Player|create|Delete|Invite)_PVS" !="EPOCH_(lock|pack)Storage_PVS" !="EPOCH_(unlock|lock|fill|repair)Vehicle_PVS" !="EPOCH_(knockDownTree|destroyTrash|MAKETRADEREQ|MAKETRADE|S_S_VEHICLES|MAKENPCTRADE|oneWayTP)" !="EPOCH_Loot(Animal|Container|Building)" !="EPAH_[a-z]{5,10}" /*DONN*/ !="donn_pv_protected_veh_(add|sub)" !="cad_pvar_smessage"

setvariable.txt: You need to change 1 line.

5 "" !=(Offer|Accept|BUILD_SLOT|TRADE_ACTIVE|last_targeter) /*DONN*/ !="(_|)don_player_veh setVariable"

Link to comment
Share on other sites

A wilhe can be done to check something from time to time. This don't mean all the code inside the while runs all the time many times per second. It runs only when some condition is found. Also the chek is limited by the sleep function, so most of the while is really soft to run:

while {true} do {
    if (simple condition) then {
        *1000 lines of script*
    }
    sleep 1;
};

// [simple condition] will be true just some times, most of the time the while "heavyness" will be 0.
// Hope i have helped you guys
Link to comment
Share on other sites

I'm actually working with the same thing at the moment, "a bit" more sorted and customizable I'm telling you :P, just have to finish up some scripts for it.

Just gotta tweak the performance a tad bit and it should be released in the middle of the next week!

Also these "handleDamage" events are not required, all you have to do is use allowDamage if you're trying to disable the damage for an entity, really.

Link to comment
Share on other sites

 

A wilhe can be done to check something from time to time. This don't mean all the code inside the while runs all the time many times per second. It runs only when some condition is found. Also the chek is limited by the sleep function, so most of the while is really soft to run:

while {true} do {
    if (simple condition) then {
        *1000 lines of script*
    }
    sleep 1;
};

// [simple condition] will be true just some times, most of the time the while "heavyness" will be 0.
// Hope i have helped you guys

waitUntil {!((_donn_notSafe && donn_notSafe) || (!_donn_notSafe && !donn_notSafe)) || !_runOneTime};

This is also a loop that runs on the engine level.

 

Trust me, using a trigger is probably the most efficient way to do this.

Link to comment
Share on other sites

_donn_notSafe and _runOneTime are booleans.

Help is really desirable, but it not allways reach its objective.

maca134 is not banned from the forum?

Not anymore :P 

 

The main problem is the creation of many spawn's. Arma doesn't clean them up properly and it is defiantly a source of fps drops. Having each thread run a loop and then each having a waitUntil. It really isnt the way forward.

 

In arma, spawn's seem great but they really need to be used sparingly.

Link to comment
Share on other sites

Not anymore :P

 

The main problem is the creation of many spawn's. Arma doesn't clean them up properly and it is defiantly a source of fps drops. Having each thread run a loop and then each having a waitUntil. It really isnt the way forward.

 

In arma, spawn's seem great but they really need to be used sparingly.

 

Touching a bit more on this, the first part, spawning a new thread for each individual trader just to monitor whether or not you are within the range could be simplified with some refinement.

 

I would also suggest maybe changing the use of publicVariable as too many messages being sent to and from the server can cause issues, especially if you have people entering and exiting the traders all the time. And publicVariableClient would be better instead of sending a variable to every player connected, just to then check their UID against its desired recipient.

Link to comment
Share on other sites

Resume of the needed process power for a player outside the safe zones:

//===========================================================================
//Calculations when you are not in a safe - Example: 1000 meters from then
//===========================================================================

//CHECK 1
//=============================================================================================
// For each Trader (Altis have 3 main traders) with a interval of 5 seconds between checks
//=============================================================================================
(player distance _trader) > 150
//the 5 seconds interval is bacause player distance from safe, it rises as player go away

//CHECK 2
//======================================================================
// Did each player frame - Boolean Check (variables are true or false)
//======================================================================
(!((_donn_notSafe && donn_notSafe) || (!_donn_notSafe && !donn_notSafe)) || !_runOneTime)

//CHECK 3
//================================
// Did each 0.0625 seconds
//================================
vehicle player != player;

//RESULTS - THE CHECKS ARE
// - 1 distance check for each trader each 5 seconds (check frequency depends on last player distance from trader)
// - 1 boolean check each frame (you can safelly add a sleep of 1 second or more here)
// - 1 check if player is in a vehicle each 0.0625 seconds (you can also safelly increase the sleep time)
Link to comment
Share on other sites

"I would also suggest maybe changing the use of publicVariable as too many messages being sent to and from the server can cause issues, especially if you have people entering and exiting the traders all the time. And publicVariableClient would be better instead of sending a variable to every player connected, just to then check their UID against its desired recipient."

You can't add a event handler on the player to trigger when the player opens a container (a car gear or other player gear for example), because the Epoch anti hack will kick you.

So the solution is to add a event handler on the safezone vehicles, to trigger when any player access it. For that you need a list of vehicles in safe, and this list must be on the server, this is when surge the need of public variable.

The other need of public variable is to send players message. The public variable is used to sends the message text and the player object reference (i believe this reference is a code that identify the object, not the object itself, since everyone have the object by normal ways). Those messages not happens often, its something rare.

Link to comment
Share on other sites

waitUntil {!((_donn_notSafe && donn_notSafe) || (!_donn_notSafe && !donn_notSafe)) || !_runOneTime};

This is also a loop that runs on the engine level.

 

Trust me, using a trigger is probably the most efficient way to do this.

 

Are you talking a trigger on the server or client ? Assuming a client trigger as is the current environment ?

 

I'd be very interested to compare, based on this script, SQF / a Trigger and an FSM performing, as close as possible, the exact same function. Ramp it up to the point of crashing the engine and see which wins :)

Link to comment
Share on other sites

Added exclusions for;

#21 "otSafe = donn_notSafe;

#55 "["Gear", objNull];

#58 "& _runOneTime) then {

 

But I can't get past this BE restriction

 

14.04.2015 00:03:55: Ace22 (144.141.37.121:46705) 145203e43516a612c36985e411d8c28e98c - #88 "otecting;
};
 
 
don_incar = false;
don_firedEH_1 = nil;
donn_godMode = false;
[] spawn {
private ['_runOneTime','_donn_notSafe','"
 
I've tried the following so far;
 
all on line 89...................
!="otecting;"
!"otecting"
!"otecting;};don_incar = false;don_firedEH_1 = nil;donn_godMode = false;[] spawn {private ['_runOneTime','_donn_notSafe','"
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...