Jump to content
Sign in to follow this  
K120

Ambulance lights+sirens

Recommended Posts

2013_11_29_00001.jpg

Hello,i'm making s small medical vehicle pack for the game and have some problems to make emergency lights and sirens work.

I spent yesterday trying to search solution from old threads and mods but couldn't find much.

I've found script to make lights and sirens work with addAction but as i lack knowledge of scripting i can't find any "proper" way to turn them off. Also siren sound doesn't come from the vehicle but plays the same no matter how far i'm from the vehicle.

nul = [this,1,1,0,0,0,1,1,0] execVM "texture\emergencyoffroad.sqf";this addAction ["Emergencylights ON", "scripts\emergencylights.sqf"];

I guess i need to use exitWith but i'm not sure what is the condition when player uses other action to turn sirens off. I need to use action id?

_vehicle = _this select 0; 
_lightRed = [5, 0.5, 0.5];
_lightBlue = [0.5, 0.5, 5];

lightleft = "#lightpoint" createVehicle getpos _vehicle;  
lightleft setLightColor _lightRed;
lightleft setLightBrightness 0.4; 
lightleft setLightAmbient _lightRed;
lightleft lightAttachObject [_vehicle, [-3, 0.8, 0]]; 
lightleft setLightAttenuation [3, 0, 0, 0.6];

lightright = "#lightpoint" createVehicle getpos _vehicle;  
lightright setLightColor _lightBlue;
lightright setLightBrightness 0.4; 
lightright setLightAmbient _lightBlue;
lightright lightAttachObject [_vehicle, [3, 0.8, 0]]; 
lightright setLightAttenuation [3, 0, 0, 0.6];

// playSound "AlarmCar";	
_leftRed = true; 
while{ (alive _vehicle)} do 
{ 
  if(_leftRed) then 
 { 
	_leftRed = false; 
	lightleft setLightColor _lightRed;
	lightleft setLightAmbient _lightRed;
	lightright setLightColor _lightBlue;
	lightright setLightAmbient _lightBlue;
	playSound "AlarmCar";
 } 
 else 
 { 
	_leftRed = true; 
	lightleft setLightColor _lightBlue;
	lightleft setLightAmbient _lightBlue;
	lightright setLightColor _lightRed;
	lightright setLightAmbient _lightRed;
 }; 	 

 sleep 1; 
};

Also how can i make it so the action is available only when in vehicle? I tried to use player in _target and similiars but didn't get it to work.

Share this post


Link to post
Share on other sites

Here's what I got for police offroads:

put this line into siren.sqf or your own .sqf file executing from the vehicles init:

_this addAction ["Siren On",{_this execvm "SirenOn.sqf"},[],52,false,true,"","Alive(_target) AND driver _target == _this"];

this will add a siren on action

then the SirenOn.sqf:

_car = _this select 0;
_action = _this select 2;
_car removeaction _action;
Copsiren = true;
_car addAction ["Siren Off",{_this execvm "SirenOff.sqf"},[],53,false,true,"","Alive(_target) AND driver _target == _this"];
while {Copsiren} do {
_car say3D "AlarmCar";
sleep 1.95;
};

this will remove the "Siren On" action and loop the vanilla arma3 car alarm sound, so no further editing of the description.ext needed

then there's the SirenOff.sqf:

_car = _this select 0;
_action = _this select 2;
_car removeaction _action;
Copsiren = false;
_car addAction ["Siren On",{_this execvm "SirenOn.sqf"},[],52,false,true,"","Alive(_target) AND driver _target == _this"];
_car say3D "AlarmCar";
sleep 1.95;

that's pretty much it

probably not the most elegant solution since my scripting skills are limited but it gets the job done.

Share this post


Link to post
Share on other sites

Big thanks! Managed to combine lights to same script but i'm not able to make them turn off. I suppose i need to use "xxx = false;" in SirenOff.sqf?

SirenOn.sqf

_car = _this select 0;
_action = _this select 2;
_lightRed = [5, 0.5, 0.5];
_lightBlue = [0.5, 0.5, 5];

_car removeaction _action;
Copsiren = true;
_car addAction ["Siren Off",{_this execvm "scripts\SirenOff.sqf"},[],53,false,true,"","Alive(_target) AND driver _target == _this"];

while {Copsiren} do {
_car say3D "AlarmCar";

lightleft = "#lightpoint" createVehicle getpos _car;  
lightleft setLightColor _lightRed;
lightleft setLightBrightness 0.4; 
lightleft setLightAmbient _lightRed;
lightleft lightAttachObject [_car, [-3, 0.8, 0]]; 
lightleft setLightAttenuation [3, 0, 0, 0.6];

lightright = "#lightpoint" createVehicle getpos _car;  
lightright setLightColor _lightBlue;
lightright setLightBrightness 0.4; 
lightright setLightAmbient _lightBlue;
lightright lightAttachObject [_car, [3, 0.8, 0]]; 
lightright setLightAttenuation [3, 0, 0, 0.6];

_leftRed = true; 
{ 
  if(_leftRed) then 
 { 
	lightleft setLightColor _lightRed;
	lightleft setLightAmbient _lightRed;
	lightright setLightColor _lightBlue;
	lightright setLightAmbient _lightBlue;
 } 
 else 
 { 
	lightleft setLightColor _lightBlue;
	lightleft setLightAmbient _lightBlue;
	lightright setLightColor _lightRed;
	lightright setLightAmbient _lightRed;
 }; 
  sleep 1; 
};

sleep 1.95;
};


Tried to put lightleft = false;lightright = false; and such in SirenOff.sqf but nothing seems to turn lights off. :confused:

Share this post


Link to post
Share on other sites

See if this helps get you started

place in the vehicles init

this setvariable ["siren",false,true];    this addAction ["Siren Off",{(_this select 0) setvariable ["siren",false,true]},[],53,false,true,"","Alive(_target) AND driver _target == _this  and _target getvariable 'siren'; "];     this addAction ["Siren On",{_this execvm "scripts\Siren.sqf"},[],52,false,true,"","Alive(_target) AND driver _target == _this and  !(_target getvariable 'siren')"];

save as siren.sqf

_car = _this select 0;
_action = _this select 2;
_lightRed = [5, 0.5, 0.5];
_lightBlue = [0.5, 0.5, 5];

_leftRed = true;


_car setvariable ["siren",true,true];

lightleft = "#lightpoint" createVehicle getpos _car; 
 lightright = "#lightpoint" createVehicle getpos _car;  

while {_car getvariable "siren" and alive _car} do {
   _car say3D "AlarmCar";

    lightleft setLightColor _lightRed;
   lightleft setLightBrightness 0.4; 
   lightleft setLightAmbient _lightRed;
   lightleft lightAttachObject [_car, [-3, 0.8, 0]]; 
   lightleft setLightAttenuation [3, 0, 0, 0.6];

   lightright setLightColor _lightBlue;
   lightright setLightBrightness 0.4; 
   lightright setLightAmbient _lightBlue;
   lightright lightAttachObject [_car, [3, 0.8, 0]]; 
   lightright setLightAttenuation [3, 0, 0, 0.6];

for "_i" from 0 to 1.7 step (0.2) do{

 switch (_leftRed) do {

     case true : {
  lightleft setLightColor _lightRed;
       lightleft setLightAmbient _lightRed;
       lightright setLightColor _lightBlue;
       lightright setLightAmbient _lightBlue;
       _leftred=false;
       };

       case false :{
        lightleft setLightColor _lightBlue;
       lightleft setLightAmbient _lightBlue;
       lightright setLightColor _lightRed;
       lightright setLightAmbient _lightRed;
       _leftred = true;
       };

   }; // end switches
   sleep 0.2;
};// end for


}; // endwhile main 

deletevehicle lightleft;
deletevehicle lightright;

  • Like 1

Share this post


Link to post
Share on other sites

Thanks guys,it works now. :)

Little off topic but i'm not sure if it's something to start new for. Anyone know if offroad parts such as the lightbar or the back cage can be created alone with classname and then be attached to some other vehicle?

Edited by K120

Share this post


Link to post
Share on other sites

See if this helps get you started

place in the vehicles init

this setvariable ["siren",false,true]; this addAction ["Siren Off",{(_this select 0) setvariable ["siren",false,true]},[],53,false,true,"","Alive(_target) AND driver _target == _this and _target getvariable 'siren'; "]; this addAction ["Siren On",{_this execvm "scripts\Siren.sqf"},[],52,false,true,"","Alive(_target) AND driver _target == _this and !(_target getvariable 'siren')"];

save as siren.sqf

_car = _this select 0;
_action = _this select 2;
_lightRed = [5, 0.5, 0.5];
_lightBlue = [0.5, 0.5, 5];

_leftRed = true;


_car setvariable ["siren",true,true];

lightleft = "#lightpoint" createVehicle getpos _car;
lightright = "#lightpoint" createVehicle getpos _car;

while {_car getvariable "siren" and alive _car} do {
_car say3D "AlarmCar";

lightleft setLightColor _lightRed;
lightleft setLightBrightness 0.4;
lightleft setLightAmbient _lightRed;
lightleft lightAttachObject [_car, [-3, 0.8, 0]];
lightleft setLightAttenuation [3, 0, 0, 0.6];

lightright setLightColor _lightBlue;
lightright setLightBrightness 0.4;
lightright setLightAmbient _lightBlue;
lightright lightAttachObject [_car, [3, 0.8, 0]];
lightright setLightAttenuation [3, 0, 0, 0.6];

for "_i" from 0 to 1.7 step (0.2) do{

switch (_leftRed) do {

case true : {
lightleft setLightColor _lightRed;
lightleft setLightAmbient _lightRed;
lightright setLightColor _lightBlue;
lightright setLightAmbient _lightBlue;
_leftred=false;
};

case false :{
lightleft setLightColor _lightBlue;
lightleft setLightAmbient _lightBlue;
lightright setLightColor _lightRed;
lightright setLightAmbient _lightRed;
_leftred = true;
};

}; // end switches
sleep 0.2;
};// end for


}; // endwhile main

deletevehicle lightleft;
deletevehicle lightright;

 
 
Are they available in blue? :)

Share this post


Link to post
Share on other sites

Are they available in blue? :)

 

Why would you necro a three year old thread to ask a stupid question like that when _lightBlue is the 4th line of the giant script you quoted?

Share this post


Link to post
Share on other sites

Why would you necro a three year old thread to ask a stupid question like that when _lightBlue is the 4th line of the giant script you quoted?

Sorry, I have no idea of scripts and absolutely need a blue light-script ... :/

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×