Jump to content

Police Sirens


Recommended Posts

Simple togglable police sirens and blinking head lights to Black SUV, Police Car and Police Lada :)

 

Add to description.ext right above "class RscLoadingText : RscText"

class CfgSounds
{
    sounds[] = {siren};
    class siren
    {
	name = "siren";
	sound[] = {Scripts\sirens\siren.ogg,0.5,1};
	titles[] = {};
    };
};

Add to fn_selfActions.sqf right above "//Grab Flare"

//Sirens
_isCopcar = typeOf _vehicle in ["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","policecar"];

if (_inVehicle and _isCopcar and (driver _vehicle == player)) then {
        dayz_addsirens = _vehicle;
    if (s_player_sirens_on < 0) then {
        s_player_sirens_on = dayz_addsirens addAction ["Sirens on","Scripts\sirens\sirens_on.sqf",dayz_addsirens,2,false,true,"",""];
        s_player_sirens_off = dayz_addsirens addAction ["Sirens off","Scripts\sirens\sirens_off.sqf",dayz_addsirens,2,false,true,"",""];
        };
    } else {
        dayz_addsirens removeAction s_player_sirens_on;
        dayz_addsirens removeAction s_player_sirens_off;
        s_player_sirens_on = -1;
        s_player_sirens_off = -1;
    };

Make "Scripts" folder to your mission file root if you don't have it yet and place "sirens" folder inside.

 

DOWNLOAD

 

Optional:

Add police car to traders

INSERT INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES 
(0, '["policecar",2]', 50, '[1,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar",1]', 0, 565, 'trade_any_vehicle'),
(0, '["policecar",2]', 50, '[1,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar",1]', 0, 568, 'trade_any_vehicle'),
(0, '["policecar",2]', 50, '[1,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar",1]', 0, 591, 'trade_any_vehicle'),
(0, '["policecar",2]', 50, '[1,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar",1]', 0, 661, 'trade_any_vehicle');
Link to comment
Share on other sites

can you add more then one vehicle calss?

//Sirens
if (_inVehicle and (_vehicle isKindOf "car1","car2)) then { 
		dayz_addsirens = _vehicle;
	if (s_player_sirens_on < 0) then {
		s_player_sirens_on = dayz_addsirens addAction ["Sirens On","Scripts\sirens\sirens_on.sqf",dayz_addsirens,2,false,true,"",""];
		s_player_sirens_off = dayz_addsirens addAction ["Sirens Off","Scripts\sirens\sirens_off.sqf",dayz_addsirens,2,false,true,"",""];
		};
	} else {
		dayz_addsirens removeAction s_player_sirens_on;
		dayz_addsirens removeAction s_player_sirens_off;
		s_player_sirens_on = -1;
		s_player_sirens_off = -1;
	};
Link to comment
Share on other sites

I got a quick question to, I already have cfgsounds configured in an addon already.  I've added the script in and everything works but the sound.  Is there a way to use playSound "siren"; and have it loop until the player toggles the siren off?

 

i've tried it several ways and tried to search for an answer but my google fu wasnt strong. 

 

Cool script tho, Thanks for sharing and helping

Link to comment
Share on other sites

people are able to toggle the sirens on over and over.. what could i add to stop them from doing that?

 

That was kind of intentional. You can make cool sounds when you overlap it :) . You could change it so that "Sirens On" stops the loop if it's already running but I like it more as it is.

Link to comment
Share on other sites

I got a quick question to, I already have cfgsounds configured in an addon already.  I've added the script in and everything works but the sound.  Is there a way to use playSound "siren"; and have it loop until the player toggles the siren off?

 

i've tried it several ways and tried to search for an answer but my google fu wasnt strong. 

 

Cool script tho, Thanks for sharing and helping

 

That is just how this works. It plays on loop untill you click "Sirens Off". You need to merge it if you already have cfgsounds. So yours should look something like this.

class CfgSounds
{
    sounds[] = {sound1,sound2,sound3};
    class sound1
    {
	name = "sound1";
	sound[] = {Scripts\sounds\sound1.ogg,0.5,1};
	titles[] = {};
    };
    class sound2
    {
	name = "sound2";
	sound[] = {Scripts\sounds\sound2.ogg,0.5,1};
	titles[] = {};
    };
    class sound3
    {
	name = "sound3";
	sound[] = {Scripts\sounds\sound3.ogg,0.5,1};
	titles[] = {};
    };
};
Link to comment
Share on other sites

Would love to get the anti theft alarm especially if it only goes off on vehicles that are hot wired and no way to disable it till a restart or sold

I'll throw it in here later but the alarm only starts when you try to access gear in locked vehicle or open backpack inside a safezone from player who is not tagged friendly.

If you pull the hotwire kit file from dayz_code and redirect it in fn_selfactions, should be possible to play alarm sound in infinite loop when hotwire kit is used.

Link to comment
Share on other sites

This doesn't work for me, tried a LadaLM using the original code which worked, but then using LadaLM and SUV_TK_CIV_EP1 with the code above made nothing work.

 

Thanks for the code overall though, very nice.

 

Right, that doesn't work. I didn't remember it right. This works:

_sirenCars = ["SUV_TK_CIV_EP1","LadaLM"];

if (_inVehicle and (typeOf _vehicle in _sirenCars)) then {
Link to comment
Share on other sites

I'll throw it in here later today but the alarm only starts when you try to access gear in locked vehicle or open backpack inside a safezone from player who is not tagged friendly.

If you pull the hotwire kit file from dayz_code and redirect it in fn_selfactions, should be possible to play alarm sound in infinite loop when hotwire kit is used.

have had a look at the hot wire file and have no idea how I would make a car alarm go off that's attached to the vehicle. Any help would be appreciated. I can make the sound file it's just the scripting

Link to comment
Share on other sites

have had a look at the hot wire file and have no idea how I would make a car alarm go off that's attached to the vehicle. Any help would be appreciated. I can make the sound file it's just the scripting

 

Make sound "alarm" and try this:

 

hotwire_veh.sqf

private ["_vehicle","_removed"];
_vehicle = _this select 3;

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_32") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

{player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
s_player_lockUnlock_crtl = 1;

_removed = ([player,"ItemHotwireKit",1] call BIS_fnc_invRemove);

if (_removed == 1) then {

	if((random 10) <= 7.5) then {

		PVDZE_veh_Lock = [_vehicle,false];
		if(player distance _vehicle < 10) then {
			
			if (local _vehicle) then {
				PVDZE_veh_Lock spawn local_lockUnlock			
			} else {
				publicVariable "PVDZE_veh_Lock";
				s_player_lockUnlock_crtl = -1;
				DZE_ActionInProgress = false;
				for "_i" from 0 to 1 step 0 do {
				_nul = [objNull, _vehicle, rSAY, "alarm", 50] call RE;
				sleep 8; //<-- Change the length of your sound here
				};
			};
		};
	} else {
		cutText [(localize "str_epoch_player_33") , "PLAIN DOWN"];
	};
};
s_player_lockUnlock_crtl = -1;
DZE_ActionInProgress = false;
Link to comment
Share on other sites

Just a suggestion to fix a bug I found:

if (_inVehicle and (_vehicle isKindOf "SUV_TK_CIV_EP1") and (driver _vehicle == player)) then { 

This makes it so only the driver can turn on and off the siren, that way you can't have a full car of people all turning on sirens.

 

Also if the driver gets out and another person gets in the drivers seat they can't turn off the sirens the first person started but they can start up a second set of sirens.

Link to comment
Share on other sites

Just a suggestion to fix a bug I found:

if (_inVehicle and (_vehicle isKindOf "SUV_TK_CIV_EP1") and (driver _vehicle == player)) then { 

This makes it so only the driver can turn on and off the siren, that way you can't have a full car of people all turning on sirens.

 

Also if the driver gets out and another person gets in the drivers seat they can't turn off the sirens the first person started but they can start up a second set of sirens.

Link to comment
Share on other sites

Updated OP:

 

- Limited sirens only to black SUV and Police Lada

- Only driver can control sirens

- Sirens turn off if vehicle doesn't have driver

- Zombies are alerted from longer distance while sirens are on

 

*replace fn_selfActions block and both .sqf files for update.

Link to comment
Share on other sites

Another thing my player base has told me, you can spam siren on and it'll repeat the siren noise over and over making it sound like multiple sirens.

 

so in the on we need to remove action for on and in off, we need to add action for on, only if off has been used maybe?
 

 

In on i have:

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
_vehicle removeAction s_player_sirens_on; // removing on option since on has been used.
If (!_inVehicle) then {
	sirensOn = 0;
};
if (isnil ("sirensOn")) then {
    sirensOn = 0;
};
if (sirensOn == 0) then {
	sirensOn = 1;
    cutText ["Sirens ON!","PLAIN DOWN"];
};
while {sirensOn == 1} do {
	If (_inVehicle and (driver _vehicle == player)) then {
	_nul = [objNull, _vehicle, rSAY, "siren", 120] call RE;
	[_vehicle, 200, true, (getPosATL _vehicle)] spawn player_alertZombies;
	for "_i" from 1 to 12 do {
	player action ["lightOn", _vehicle];
	sleep 0.2;
	player action ["lightOff", _vehicle];
	sleep 0.2;
	};
	sleep 0.2;
	} else {
	sirensOn = 0;
	};
};

Then in off, not sure if this would work:

_vehicle = vehicle player;
if (isnil ("sirensOn")) then {
    sirensOn = 0;
};
if (sirensOn == 1) then {
	sirensOn = 0;
    cutText ["Sirens OFF!","PLAIN DOWN"];
	_vehicle addAction s_player_sirens_on; // re-adds on option only if siren is on and off has been used?
	} else {
	cutText ["Sirens OFF!","PLAIN DOWN"];
};

Link to comment
Share on other sites

the off portion did nothing so my second test is this:

_vehicle = vehicle player;
if (isnil ("sirensOn")) then {
    sirensOn = 0;
};
if (sirensOn == 1) then {
	sirensOn = 0;
    cutText ["Sirens OFF!","PLAIN DOWN"];
	sleep 10;
	s_player_sirens_on = _vehicle addAction ["Sirens On","Scripts\sirens\sirens_on.sqf",dayz_addsirens,2,false,true,"",""];
	} else {
	cutText ["Sirens OFF!","PLAIN DOWN"];
};

This makes it so when off is used, the on option doesn't appear for 10 seconds. but it places it under off for some reason.

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
  • Advertisement
×
×
  • Create New...