Towing - Add rope to vehicle inventory (#8963)

* Add rope to vehicle inventory

* Use LINKFUNC

* Make setting not need restart

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Dystopian 2022-08-29 03:24:24 +03:00 committed by GitHub
parent e677021e5a
commit 20fb895b31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 0 deletions

View File

@ -1,3 +1,4 @@
PREP(addRopeToVehicle);
PREP(attachRopePFH);
PREP(canStartTow);
PREP(detach);

View File

@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
#include "initSettings.sqf"
ADDON = true;

View File

@ -0,0 +1,27 @@
#include "script_component.hpp"
/*
* Author: Dystopian
* Adds rope to vehicle inventory.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* cursorObject call ace_towing_fnc_addRopeToVehicle
*
* Public: No
*/
if (!GVAR(addRopeToVehicleInventory)) exitWith {};
params ["_vehicle"];
if (0 == getNumber (configOf _vehicle >> QEGVAR(cargo,hasCargo))) exitWith {};
private _ropeType = if (
-1 < ["Tank", "Wheeled_APC_F", "Truck_F"] findIf {_vehicle isKindOf _x}
) then {"ACE_rope12"} else {"ACE_rope6"};
_vehicle addItemCargoGlobal [_ropeType, 1];

View File

@ -0,0 +1,13 @@
[
QGVAR(addRopeToVehicleInventory), "CHECKBOX",
LSTRING(Setting_addRopeToVehicleInventory_DisplayName),
LELSTRING(OptionsMenu,CategoryLogistics),
true,
true,
{
if !(_this && {isServer} && {isNil QGVAR(addRopeToVehicleInventory_initialized)}) exitWith {};
GVAR(addRopeToVehicleInventory_initialized) = true;
["Tank", "initPost", LINKFUNC(addRopeToVehicle), true, [], true] call CBA_fnc_addClassEventHandler;
["Car", "initPost", LINKFUNC(addRopeToVehicle), true, [], true] call CBA_fnc_addClassEventHandler;
}
] call CBA_fnc_addSetting;

View File

@ -111,5 +111,9 @@
<Chinesesimp>解开牵引绳</Chinesesimp>
<Korean>견인줄 분리</Korean>
</Key>
<Key ID="STR_ACE_Towing_Setting_addRopeToVehicleInventory_DisplayName">
<English>Add Tow Rope to Vehicle Inventory</English>
<Russian>Добавить буксировочный трос в инвентарь машин</Russian>
</Key>
</Package>
</Project>