Skip to content

Instantly share code, notes, and snippets.

@KiloSwiss
Created December 23, 2019 14:23
Show Gist options
  • Save KiloSwiss/6eae7aeaca582129599983f666c9e42e to your computer and use it in GitHub Desktop.
Save KiloSwiss/6eae7aeaca582129599983f666c9e42e to your computer and use it in GitHub Desktop.
Swap the car horn of any vehicle (must be type "Car") with any other existing one.
// How to use when in a vehicle:
// [vehicle player, "PoliceHorn"] call KS_fnc_swapCarHorn;
//
// Possible Horns to select from (Note: "BikeHorn" doesn't make any sound):
// ["BikeHorn","CarHorn","TruckHorn","TruckHorn2","TruckHorn3","SportCarHorn","MiniCarHorn","AmbulanceHorn","PoliceHorn"]
//
// Returns "true" or "false".
KS_fnc_swapCarHorn =
{
params [ ["_veh", objNull, [objNull] ], ["_newHorn", "", [""] ] ];
private _return = false;
if ( _veh isKindOf "Car" ) then
{
private _horns = "inheritsFrom _x isEqualTo (configFile >> 'CfgWeapons' >> 'CarHorn')" configClasses (configFile >> 'CfgWeapons') apply {configName _x};
_horns set [_horns find "FakeHorn", "CarHorn"]; // Add "CarHorn" manually as it does not inherit from itself and replace "FakeHorn" as we don't want to remove that from vehicles.
if ( _newHorn in _horns ) then
{
{
_veh removeWeaponTurret [_x, [-1]];
}
forEach _horns;
_veh addWeapon _newHorn;
_return = true;
};
};
_return
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment