[Release] Sirens on cars - now with lights and bugfixes!

FallingSheep

OpenDayZ Lord!
Since i couldn't find it any where else and have no idea who created it, ill post the sirens script here for all to use!

UPDATED: thanks to inkko for the updated code!
this fixes the siren spam, duplicate menu and undefined variable problems!
it also adds flashing lights and is now a toggle function!

What it does....
adds flashing sirens with sound to cars!

What you need:
Notepad++
Custom fn_selfactions.sqf

Difficulty:
Easy = Blue <10 min

Installation Steps:

create a new sqf file called siren_on.sqf and paste this into it
Code:
_vehicle = (vehicle player);
_inVehicle = (_vehicle != player);

if (isnil "toggle_siren") then {
toggle_siren = 1;
};
if (toggle_siren == 1) then {
toggle_siren = 0;
_lightRed =
{
    _redLight = "#lightpoint" createVehicle (getPos _vehicle);
    _redLight setLightBrightness 0.1;
    _redLight setLightAmbient [ 0.5, 0, 0 ];
    _redLight setLightColor [0.77,0.05,0.23];
    _redLight lightAttachObject [_vehicle, [1, 0, 1.0]];
    sleep 0.13;
    deleteVehicle _redLight;
    sleep 0.13;
};
_lightBlue =
{
    _blueLight = "#lightpoint" createVehicle (getPos _vehicle);
    _blueLight setLightBrightness 0.1;
    _blueLight setLightAmbient [ 0, 0, 0.5 ];
    _blueLight setLightColor [0,0,1.0];
    _blueLight lightAttachObject [_vehicle, [-1, 0, 1.0]];
    sleep 0.13;
    deleteVehicle _blueLight;
    sleep 0.13;
};

if (isnil ("sirensOn")) then {
    sirensOn = 0;
};
If (!_inVehicle) 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", 200] 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];
                        sleep 0.2;
                        player action ["lightOff", _vehicle];
                        sleep 0.2;
                    };
                sleep 0.2;
            };
        } else {
        toggle_siren = 1;
        dayz_siren_vehicle removeAction s_player_sirens_on;
        sirensOn = 0;
    };
};
} else {
toggle_siren = 1;
if (isnil ("sirensOn")) then {
    sirensOn = 0;
};

if (sirensOn == 1) then {
    sirensOn = 0;
    cutText ["Sirens OFF!","PLAIN DOWN"];
    } else {
    cutText ["Sirens OFF!","PLAIN DOWN"];
};
};
create another sqf called siren_off.sqf and paste this into it
Code:
player removeAction sirens_off;
sirens_off = -1;

if (isnil ("sirensOn")) then {
    sirensOn = 0;
};

if (sirensOn == 1) then {
    sirensOn = 0;
    cutText ["Sirens OFF!","PLAIN DOWN"];
    } else {
    cutText ["Sirens OFF!","PLAIN DOWN"];
};
now create a folder in your mpmissions called sirens and put the 2 sqfs into it

in your custom fn_selfactions.sqf just above
Code:
_nearLight = nearestObject [player,"LitObject"];
add this
Code:
//Sirens
_isCopcar = typeOf _vehicle in ["LadaLM","HMMWV_Ambulance","HMMWV_Ambulance_CZ_DES_EP1","S1203_ambulance_EP1","GAZ_Vodnik_MedEvac","policecar"];
if (_inVehicle and _isCopcar and (driver _vehicle == player)) then {
    dayz_siren_vehicle = _vehicle;
    if (s_player_sirens_on < 0) then {
        s_player_sirens_on = dayz_siren_vehicle addAction ["Toggle Siren","sirens\siren_on.sqf",dayz_siren_vehicle,2,false,true,"",""];
    };
} else {
    dayz_siren_vehicle removeAction s_player_sirens_on;
    s_player_sirens_on = -1;
};
next open your description.ext file and add this at the very bottom
Code:
class CfgSounds
{
    class siren
    {
        name="siren";
        sound[]={sounds\siren.ogg,0.9,1};
        titles[] = {};
    };
};
if you already have custom sounds in your description.ext after this
Code:
class CfgSounds
{
add this part
Code:
    class siren
    {
        name="siren";
        sound[]={sounds\siren.ogg,0.9,1};
        titles[] = {};
    };
add this to your variables.sqf
Code:
if(isNil "dayz_siren_vehicle") then {
    dayz_siren_vehicle = objNull;
};
then in the dayz_resetSelfActions section add this
Code:
s_player_sirens_on = -1;
next download this sound and place in your mpmission folder in a folder called sounds
http://www.mediafire.com/download/tpbm4be84voouv4/siren.ogg

you can add the siren effect to any vehicle just add it to the array in the fn_selfactions.sqf
_isCopcar = typeOf _vehicle in ["ADD NEW VEHICLE ID HERE","LadaLM","HMMWV_Ambulance","HMMWV_Ambulance_CZ_DES_EP1","S1203_ambulance_EP1","GAZ_Vodnik_MedEvac","policecar"];

dont forget the , !
 
Last edited:
Sooo this script is awesome but there needs to be a few edits.

1. When adding:

//Sirens
_isCopcar = typeOf _vehicle in ["LadaLM","HMMWV_Ambulance","HMMWV_Ambulance_CZ_DES_EP1","S1203_ambulance_EP1","GAZ_Vodnik_MedEvac","policecar"];
if (_inVehicle and _isCopcar and (driver _vehicle == player)) then {
dayz_siren_vehicle = _vehicle;
if (s_player_sirens_on < 0) then {
s_player_sirens_on = dayz_siren_vehicle addAction ["Toggle Siren","Scripts\siren_on.sqf",dayz_siren_vehicle,2,false,true,"",""];
};
} else {
dayz_siren_vehicle removeAction s_player_sirens_on;
s_player_sirens_on = -1;
};


You need to either rename the folder sirens to scripts or edit the code above to say:

if (s_player_sirens_on < 0) then {
s_player_sirens_on = dayz_siren_vehicle addAction ["Toggle Siren","sirens\siren_on.sqf",dayz_siren_vehicle,2,false,true,"",""];
};


2. Then the files named sirens_off and sirens_on need to be renamed siren_off and siren_on.


After these edits the script works for me.
 
Top