54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
/*
|
|
Author: Djeeberjr
|
|
|
|
Description:
|
|
Installs a very simple radio in the vehicle
|
|
|
|
Parameter(s):
|
|
0: OBJECT - the vehicle
|
|
1: STRING or ARRAY - song or array of songs
|
|
*/
|
|
|
|
params ["_veh","_songs",["_offset",[0,0,0]]];
|
|
|
|
if((typeName _songs) == "STRING")then{
|
|
_songs = [_songs];
|
|
};
|
|
|
|
_veh addEventHandler ["Killed", {
|
|
params ["_unit"];
|
|
if(not isNull (_unit getVariable ["DLib_radio_source",objNull]))then{
|
|
deleteVehicle (_unit getVariable "DLib_radio_source");
|
|
};
|
|
}];
|
|
|
|
_startId = _veh addAction ["Press play",{
|
|
params ["_target", "_caller", "_actionId", "_arguments"];
|
|
_song = selectRandom (_arguments#0);
|
|
_offset = _arguments#1;
|
|
if(not isNull (_target getVariable ["DLib_radio_source",objNull]))then{
|
|
deleteVehicle (_target getVariable "DLib_radio_source");
|
|
};
|
|
|
|
_source = "Land_Can_V1_F" createVehicle [0,0,0];
|
|
_target setVariable ["DLib_radio_source",_source,true];
|
|
_source hideObjectGlobal true;
|
|
|
|
if((typeName _offset) == "STRING")then{
|
|
_source attachTo [_target,[0,0,0],_offset];
|
|
}else{
|
|
_source attachTo [_target,_offset];
|
|
};
|
|
|
|
[_source,[_song,120]] remoteExec ["say3D"];
|
|
|
|
},[_songs,_offset],1.5,false,true,"","driver _target == _this"];
|
|
|
|
_stopId = _veh addAction ["Press Stop",{
|
|
params ["_target", "_caller", "_actionId", "_arguments"];
|
|
|
|
deleteVehicle (_target getVariable ["DLib_radio_source",objNull]);
|
|
|
|
},[],1.5,false,true,"","driver _target == _this"];
|
|
|
|
_veh setVariable ["DLib_radio_actions",[_startId,_stopId],true]; |