Jump to content

Police Sirens


Recommended Posts

Alright, here :)

 

variables.sqf inside dayz_resetSelfActions block

s_player_sirens_on = 	-1;
s_player_sirens_off = 	-1;
copcar_stoppolice = 	-1;

fn_selfActions.sqf

if (_inVehicle && (typeOf _vehicle in ["policecar","SUV_TK_CIV_EP1","SUV_TK_CIV_EP1_DZE1","SUV_TK_CIV_EP1_DZE2","SUV_TK_CIV_EP1_DZE3","SUV_TK_CIV_EP1_DZE4","LadaLM","LadaLM_DZE1","LadaLM_DZE2","LadaLM_DZE3","LadaLM_DZE4"]) && (driver _vehicle == player)) then {
	if ((_vehicle getVariable["sirenon",0]) == 0) then {
		if (s_player_sirens_on < 0) then {
			s_player_sirens_on = _vehicle addAction ["Sirens on","Scripts\sirens.sqf",[_vehicle,"start"],2,false,true,"",""];
		};
	};
	if (sirensOn == 1) then {
		if (s_player_sirens_off < 0) then {
			s_player_sirens_off = _vehicle addAction ["Sirens off","Scripts\sirens.sqf",[_vehicle,"end"],2,false,true,"",""];
		};
	};
} else {
	_vehicle removeAction s_player_sirens_on;
	_vehicle removeAction s_player_sirens_off;
	_vehicle removeAction copcar_stoppolice;
	s_player_sirens_on = -1;
	s_player_sirens_off = -1;
	copcar_stoppolice = -1;
};

save this as sirens.sqf inside Scripts folder

//Vehicle Sirens -Sukkaed
_case = (_this select 3) select 1;

switch (_case) do {
	case "start": {
		private ["_vehicle","_inVehicle","_lightRed","_redLight","_lightBlue","_blueLight","_lastValidVehicles","_validVehicles","_nearPlayerVehicles"];
		s_player_sirens_off = -1;
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",1,true];
		_inVehicle = (_vehicle != player);
		_lightRed = {
			_redLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_redLight setLightBrightness 0.03;	
			_redLight setLightAmbient [ 0.5, 0, 0 ]; 
			_redLight setLightColor [0.77,0.05,0.23]; 
			_redLight lightAttachObject [_vehicle, [1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _redLight;
			uiSleep 0.13;
		};
		_lightBlue = {
			_blueLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_blueLight setLightBrightness 0.03;
			_blueLight setLightAmbient [ 0, 0, 0.5 ]; 
			_blueLight setLightColor [0,0,1.0]; 
			_blueLight lightAttachObject [_vehicle, [-1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _blueLight;
			uiSleep 0.13;
		};
		
		if (isNil ("sirensOn")) then { sirensOn = 0; };
		if (sirensOn == 0) then {
			sirensOn = 1;
			cutText ["Sirens ON!","PLAIN DOWN"];
		};
		_vehicle removeAction s_player_sirens_on;
		_lastValidVehicles = [];

		while {sirensOn == 1} do {
			if (_inVehicle and (driver _vehicle == player)) then {
				_validVehicles = [];
				_nearPlayerVehicles = position _vehicle nearEntities [["Car","Motorcycle"],50];
				if ((count _nearPlayerVehicles) > 0) then {
					{
						if (_x != _vehicle && ((count (crew _x)) > 0)) then {
							_validVehicles set [(count _validVehicles), _x];
						};
					} forEach _nearPlayerVehicles;
				};
				if ((count _validVehicles) > 0) then {
					if ((count _lastValidVehicles) != (count _validVehicles)) then {
						_vehicle removeAction copcar_stoppolice;
						copcar_stoppolice = -1;
						_lastValidVehicles = _validVehicles;
					};
					if (copcar_stoppolice < 0) then {
						copcar_stoppolice = _vehicle addAction ["STOP POLICE","Scripts\sirens.sqf",[_vehicle,"stop",_lastValidVehicles],2,true,true,"",""];
					};
				} else {
					_vehicle removeAction copcar_stoppolice;
					copcar_stoppolice = -1;
				};
				[nil, _vehicle, rSAY, "siren", 120] call RE;
				[_vehicle, 200, true, (getPosATL _vehicle)] spawn player_alertZombies;
				if (_vehicle isKindOf "policecar") then {
					for "_i" from 1 to 10 do {
						call _lightRed;
						call _lightBlue;
					};
				} else {
					for "_i" from 1 to 12 do {
						player action ["lightOn", _vehicle];
						uiSleep 0.2;
						player action ["lightOff", _vehicle];
						uiSleep 0.2;
					};
					uiSleep 0.2;
				};
			} else {
				sirensOn = 0;
				uiSleep 2;
				_vehicle setVariable["sirenon",0,true];
				_vehicle removeAction s_player_sirens_off;
				_vehicle removeAction copcar_stoppolice;
				s_player_sirens_on = -1;
				s_player_sirens_off = -1;
				copcar_stoppolice = -1;
			};
		};
	};
	
	case "end": {
		private ["_vehicle"];
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",0,true];
		_vehicle removeAction s_player_sirens_off;
		sirensOn = 0;
		cutText ["Sirens OFF!","PLAIN DOWN"];
		uiSleep 5;
		s_player_sirens_on = -1;
	};
	
	case "stop": {
		private ["_vehicle", "_vehicleList", "_messageList", "_targetCrew"];
		_vehicle = (_this select 3) select 0;
		_vehicleList = (_this select 3) select 2;
		_vehicle removeAction copcar_stoppolice;
		copcar_stoppolice = 0;
		_messageList = [];
		{
			_targetCrew = (crew _x);
			if ((count _targetCrew) > 0) then {
				{
					if (!isNull _x && alive _x) then {
						_messageList set [(count _messageList), _x];			
					};
				} forEach _targetCrew;	
			};
		} forEach _vehicleList;

		if ((count _messageList) > 0) then {
			{
				[nil,(_x),"loc",rTITLETEXT,"! POLICE !\n\n! STOP YOUR VEHICLE - RIGHT NOW !","PLAIN",0] call RE;
			} forEach _messageList;
		};
		uiSleep 30;
		copcar_stoppolice = -1;
	};
};

Use the siren sound from original post.

 

 

Credits to OtterNas3 for remote stop message function.

Link to comment
Share on other sites

  • 4 weeks later...

Is there any way to disable the Radio on the CVPI Police Cars from Overpoch?

Does anyone know how to disable the Radio in the CVPI Police cars from Overpoch.

If not, I guess i will take them out, because everyone i know that has got one in the pass has blown it up or sold it after about 5 minutes. I really like the cars BUT the radios SUCK.

Link to comment
Share on other sites

  • 2 weeks later...

Alright, here :)

 

variables.sqf inside dayz_resetSelfActions block

s_player_sirens_on = 	-1;
s_player_sirens_off = 	-1;
copcar_stoppolice = 	-1;

fn_selfActions.sqf

 

if (_inVehicle && (typeOf _vehicle in ["policecar","SUV_TK_CIV_EP1","SUV_TK_CIV_EP1_DZE1","SUV_TK_CIV_EP1_DZE2","SUV_TK_CIV_EP1_DZE3","SUV_TK_CIV_EP1_DZE4","LadaLM","LadaLM_DZE1","LadaLM_DZE2","LadaLM_DZE3","LadaLM_DZE4"]) && (driver _vehicle == player)) then {
	if ((_vehicle getVariable["sirenon",0]) == 0) then {
		if (s_player_sirens_on < 0) then {
			s_player_sirens_on = _vehicle addAction ["Sirens on","Scripts\sirens.sqf",[_vehicle,"start"],2,false,true,"",""];
		};
	};
	if (sirensOn == 1) then {
		if (s_player_sirens_off < 0) then {
			s_player_sirens_off = _vehicle addAction ["Sirens off","Scripts\sirens.sqf",[_vehicle,"end"],2,false,true,"",""];
		};
	};
} else {
	_vehicle removeAction s_player_sirens_on;
	_vehicle removeAction s_player_sirens_off;
	_vehicle removeAction copcar_stoppolice;
	s_player_sirens_on = -1;
	s_player_sirens_off = -1;
	copcar_stoppolice = -1;
};

save this as sirens.sqf inside Scripts folder

//Vehicle Sirens -Sukkaed
_case = (_this select 3) select 1;

switch (_case) do {
	case "start": {
		private ["_vehicle","_inVehicle","_lightRed","_redLight","_lightBlue","_blueLight","_lastValidVehicles","_validVehicles","_nearPlayerVehicles"];
		s_player_sirens_off = -1;
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",1,true];
		_inVehicle = (_vehicle != player);
		_lightRed = {
			_redLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_redLight setLightBrightness 0.03;	
			_redLight setLightAmbient [ 0.5, 0, 0 ]; 
			_redLight setLightColor [0.77,0.05,0.23]; 
			_redLight lightAttachObject [_vehicle, [1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _redLight;
			uiSleep 0.13;
		};
		_lightBlue = {
			_blueLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_blueLight setLightBrightness 0.03;
			_blueLight setLightAmbient [ 0, 0, 0.5 ]; 
			_blueLight setLightColor [0,0,1.0]; 
			_blueLight lightAttachObject [_vehicle, [-1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _blueLight;
			uiSleep 0.13;
		};
		
		if (isNil ("sirensOn")) then { sirensOn = 0; };
		if (sirensOn == 0) then {
			sirensOn = 1;
			cutText ["Sirens ON!","PLAIN DOWN"];
		};
		_vehicle removeAction s_player_sirens_on;
		_lastValidVehicles = [];

		while {sirensOn == 1} do {
			if (_inVehicle and (driver _vehicle == player)) then {
				_validVehicles = [];
				_nearPlayerVehicles = position _vehicle nearEntities [["Car","Motorcycle"],50];
				if ((count _nearPlayerVehicles) > 0) then {
					{
						if (_x != _vehicle && ((count (crew _x)) > 0)) then {
							_validVehicles set [(count _validVehicles), _x];
						};
					} forEach _nearPlayerVehicles;
				};
				if ((count _validVehicles) > 0) then {
					if ((count _lastValidVehicles) != (count _validVehicles)) then {
						_vehicle removeAction copcar_stoppolice;
						copcar_stoppolice = -1;
						_lastValidVehicles = _validVehicles;
					};
					if (copcar_stoppolice < 0) then {
						copcar_stoppolice = _vehicle addAction ["STOP POLICE","Scripts\sirens.sqf",[_vehicle,"stop",_lastValidVehicles],2,true,true,"",""];
					};
				} else {
					_vehicle removeAction copcar_stoppolice;
					copcar_stoppolice = -1;
				};
				[nil, _vehicle, rSAY, "siren", 120] call RE;
				[_vehicle, 200, true, (getPosATL _vehicle)] spawn player_alertZombies;
				if (_vehicle isKindOf "policecar") then {
					for "_i" from 1 to 10 do {
						call _lightRed;
						call _lightBlue;
					};
				} else {
					for "_i" from 1 to 12 do {
						player action ["lightOn", _vehicle];
						uiSleep 0.2;
						player action ["lightOff", _vehicle];
						uiSleep 0.2;
					};
					uiSleep 0.2;
				};
			} else {
				sirensOn = 0;
				uiSleep 2;
				_vehicle setVariable["sirenon",0,true];
				_vehicle removeAction s_player_sirens_off;
				_vehicle removeAction copcar_stoppolice;
				s_player_sirens_on = -1;
				s_player_sirens_off = -1;
				copcar_stoppolice = -1;
			};
		};
	};
	
	case "end": {
		private ["_vehicle"];
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",0,true];
		_vehicle removeAction s_player_sirens_off;
		sirensOn = 0;
		cutText ["Sirens OFF!","PLAIN DOWN"];
		uiSleep 5;
		s_player_sirens_on = -1;
	};
	
	case "stop": {
		private ["_vehicle", "_vehicleList", "_messageList", "_targetCrew"];
		_vehicle = (_this select 3) select 0;
		_vehicleList = (_this select 3) select 2;
		_vehicle removeAction copcar_stoppolice;
		copcar_stoppolice = 0;
		_messageList = [];
		{
			_targetCrew = (crew _x);
			if ((count _targetCrew) > 0) then {
				{
					if (!isNull _x && alive _x) then {
						_messageList set [(count _messageList), _x];			
					};
				} forEach _targetCrew;	
			};
		} forEach _vehicleList;

		if ((count _messageList) > 0) then {
			{
				[nil,(_x),"loc",rTITLETEXT,"! POLICE !\n\n! STOP YOUR VEHICLE - RIGHT NOW !","PLAIN",0] call RE;
			} forEach _messageList;
		};
		uiSleep 30;
		copcar_stoppolice = -1;
	};
};

[/spolier]

Use the siren sound from original post.

 

 

Credits to OtterNas3 for remote stop message function.

 

I am getting this error:

 

dayz_addsirens removeAction s_player_sir>
  Error position: <dayz_addsirens removeAction s_player_sir>
  Error Undefined variable in expression: dayz_addsirens
File mpmissions\__CUR_MP.Chernarus\Functions\fn_selfActions.sqf, line 71
Error in expression <sirens,2,false,true,"",""]; 

 

When I define the variable dayz_addsirens = -1; in my variables.sqf my plot management and door management stop working. I guess I am doing it wrong, is there another way? Maybe dayz_addsirens = objNull; in my init.sqf or variables.sqf?

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

This script has a very unsightly Bug.

Replace this line

 

[_vehicle, 200, true, (getPosATL _vehicle)] spawn player_alertZombies;
with this code

 

[player, 200, true, (getPosATL player)] spawn player_alertZombies;
Is better if you want that the zombies are still a danger to the players.

Do not do it to change, the zombies will always stay beside the car.

The player can get out off the car and the zombies will not chase the player.

Link to comment
Share on other sites

  • 5 months later...

Alright, here :)

 

variables.sqf inside dayz_resetSelfActions block

s_player_sirens_on = 	-1;
s_player_sirens_off = 	-1;
copcar_stoppolice = 	-1;

fn_selfActions.sqf

if (_inVehicle && (typeOf _vehicle in ["policecar","SUV_TK_CIV_EP1","SUV_TK_CIV_EP1_DZE1","SUV_TK_CIV_EP1_DZE2","SUV_TK_CIV_EP1_DZE3","SUV_TK_CIV_EP1_DZE4","LadaLM","LadaLM_DZE1","LadaLM_DZE2","LadaLM_DZE3","LadaLM_DZE4"]) && (driver _vehicle == player)) then {
	if ((_vehicle getVariable["sirenon",0]) == 0) then {
		if (s_player_sirens_on < 0) then {
			s_player_sirens_on = _vehicle addAction ["Sirens on","Scripts\sirens.sqf",[_vehicle,"start"],2,false,true,"",""];
		};
	};
	if (sirensOn == 1) then {
		if (s_player_sirens_off < 0) then {
			s_player_sirens_off = _vehicle addAction ["Sirens off","Scripts\sirens.sqf",[_vehicle,"end"],2,false,true,"",""];
		};
	};
} else {
	_vehicle removeAction s_player_sirens_on;
	_vehicle removeAction s_player_sirens_off;
	_vehicle removeAction copcar_stoppolice;
	s_player_sirens_on = -1;
	s_player_sirens_off = -1;
	copcar_stoppolice = -1;
};

save this as sirens.sqf inside Scripts folder

//Vehicle Sirens -Sukkaed
_case = (_this select 3) select 1;

switch (_case) do {
	case "start": {
		private ["_vehicle","_inVehicle","_lightRed","_redLight","_lightBlue","_blueLight","_lastValidVehicles","_validVehicles","_nearPlayerVehicles"];
		s_player_sirens_off = -1;
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",1,true];
		_inVehicle = (_vehicle != player);
		_lightRed = {
			_redLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_redLight setLightBrightness 0.03;	
			_redLight setLightAmbient [ 0.5, 0, 0 ]; 
			_redLight setLightColor [0.77,0.05,0.23]; 
			_redLight lightAttachObject [_vehicle, [1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _redLight;
			uiSleep 0.13;
		};
		_lightBlue = {
			_blueLight = "#lightpoint" createVehicle (getPos _vehicle); 
			_blueLight setLightBrightness 0.03;
			_blueLight setLightAmbient [ 0, 0, 0.5 ]; 
			_blueLight setLightColor [0,0,1.0]; 
			_blueLight lightAttachObject [_vehicle, [-1, 0, 1.0]];
			uiSleep 0.13;
			deleteVehicle _blueLight;
			uiSleep 0.13;
		};
		
		if (isNil ("sirensOn")) then { sirensOn = 0; };
		if (sirensOn == 0) then {
			sirensOn = 1;
			cutText ["Sirens ON!","PLAIN DOWN"];
		};
		_vehicle removeAction s_player_sirens_on;
		_lastValidVehicles = [];

		while {sirensOn == 1} do {
			if (_inVehicle and (driver _vehicle == player)) then {
				_validVehicles = [];
				_nearPlayerVehicles = position _vehicle nearEntities [["Car","Motorcycle"],50];
				if ((count _nearPlayerVehicles) > 0) then {
					{
						if (_x != _vehicle && ((count (crew _x)) > 0)) then {
							_validVehicles set [(count _validVehicles), _x];
						};
					} forEach _nearPlayerVehicles;
				};
				if ((count _validVehicles) > 0) then {
					if ((count _lastValidVehicles) != (count _validVehicles)) then {
						_vehicle removeAction copcar_stoppolice;
						copcar_stoppolice = -1;
						_lastValidVehicles = _validVehicles;
					};
					if (copcar_stoppolice < 0) then {
						copcar_stoppolice = _vehicle addAction ["STOP POLICE","Scripts\sirens.sqf",[_vehicle,"stop",_lastValidVehicles],2,true,true,"",""];
					};
				} else {
					_vehicle removeAction copcar_stoppolice;
					copcar_stoppolice = -1;
				};
				[nil, _vehicle, rSAY, "siren", 120] call RE;
				[_vehicle, 200, true, (getPosATL _vehicle)] spawn player_alertZombies;
				if (_vehicle isKindOf "policecar") then {
					for "_i" from 1 to 10 do {
						call _lightRed;
						call _lightBlue;
					};
				} else {
					for "_i" from 1 to 12 do {
						player action ["lightOn", _vehicle];
						uiSleep 0.2;
						player action ["lightOff", _vehicle];
						uiSleep 0.2;
					};
					uiSleep 0.2;
				};
			} else {
				sirensOn = 0;
				uiSleep 2;
				_vehicle setVariable["sirenon",0,true];
				_vehicle removeAction s_player_sirens_off;
				_vehicle removeAction copcar_stoppolice;
				s_player_sirens_on = -1;
				s_player_sirens_off = -1;
				copcar_stoppolice = -1;
			};
		};
	};
	
	case "end": {
		private ["_vehicle"];
		_vehicle = (_this select 3) select 0;
		_vehicle setVariable["sirenon",0,true];
		_vehicle removeAction s_player_sirens_off;
		sirensOn = 0;
		cutText ["Sirens OFF!","PLAIN DOWN"];
		uiSleep 5;
		s_player_sirens_on = -1;
	};
	
	case "stop": {
		private ["_vehicle", "_vehicleList", "_messageList", "_targetCrew"];
		_vehicle = (_this select 3) select 0;
		_vehicleList = (_this select 3) select 2;
		_vehicle removeAction copcar_stoppolice;
		copcar_stoppolice = 0;
		_messageList = [];
		{
			_targetCrew = (crew _x);
			if ((count _targetCrew) > 0) then {
				{
					if (!isNull _x && alive _x) then {
						_messageList set [(count _messageList), _x];			
					};
				} forEach _targetCrew;	
			};
		} forEach _vehicleList;

		if ((count _messageList) > 0) then {
			{
				[nil,(_x),"loc",rTITLETEXT,"! POLICE !\n\n! STOP YOUR VEHICLE - RIGHT NOW !","PLAIN",0] call RE;
			} forEach _messageList;
		};
		uiSleep 30;
		copcar_stoppolice = -1;
	};
};

Use the siren sound from original post.

 

 

Credits to OtterNas3 for remote stop message function.

Hi

When i use that, i got the action Sirens On & Sirens Off repeating a lot, like "Gear, Sirens On, Sirens On, Sirens Off, Sirens On, Sirens Off, Get Out", etc...

What can i do to prevent this ?

Thanks

Link to comment
Share on other sites

  • 1 year later...
On 30.12.2014 at 5:31 AM, Sukkaed said:

Yes, only driver can see it. This script is about adding sirens like the topic says. If you want working lights, try to look somewhere else.

This statement is not very helpful. If you already offer a script then you should do it right. I have now written a public version and all players can see the lights. You can turn on the lights on my script and leave the vehicle. You can also leave the server and join again. The lights will continue to flash when you forget to turn them off. So write a decent script ;-)

Link to comment
Share on other sites

23 minutes ago, hellraver said:

This statement is not very helpful. If you already offer a script then you should do it right. I have now written a public version and all players can see the lights. You can turn on the lights on my script and leave the vehicle. You can also leave the server and join again. The lights will continue to flash when you forget to turn them off. So write a decent script ;-)

On 30/12/2014 at 1:31 AM, Sukkaed said:

i think you need wait others 3 years to get a response:laugh:.   Do you wanna share your adaptation mate?

Link to comment
Share on other sites

  • 9 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
×
×
  • Create New...