mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
port lock backpacks
This commit is contained in:
parent
e67602d76e
commit
06f39aa158
@ -1,62 +0,0 @@
|
||||
class CfgPatches {
|
||||
class AGM_Backpacks {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.60;
|
||||
requiredAddons[] = {AGM_Core, AGM_Interaction};
|
||||
version = "0.95";
|
||||
versionStr = "0.95";
|
||||
versionAr[] = {0,95,0};
|
||||
author[] = {"bux", "commy2"};
|
||||
authorUrl = "https://github.com/commy2/";
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions {
|
||||
class AGM_Backpacks {
|
||||
class AGM_Backpacks {
|
||||
file = "\AGM_Backpacks\functions";
|
||||
class getBackpackAssignedUnit;
|
||||
class isBackpack;
|
||||
class openInventory;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_InventoryOpened_EventHandlers {
|
||||
class CAManBase {
|
||||
class AGM_Backpacks_openInventory {
|
||||
clientInventoryOpened = "if (_this select 0 == AGM_player) then {_this call AGM_Backpacks_fnc_openInventory};";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class AGM_SelfActions {
|
||||
class AGM_Equipment {
|
||||
class AGM_LockBackpack {
|
||||
displayName = "$STR_AGM_Backpacks_LockBackpack";
|
||||
condition = "[backpackContainer _player] call AGM_Backpacks_fnc_isBackpack && {!((backpackContainer _player) getVariable ['AGM_LockedInventory', false])}";
|
||||
statement = "(backpackContainer _player) setVariable ['AGM_LockedInventory', true, true]";
|
||||
showDisabled = 0;
|
||||
priority = 2.5;
|
||||
icon = ""; // @todo
|
||||
hotkey = "L";
|
||||
enableInside = 1;
|
||||
};
|
||||
class AGM_UnlockBackpack {
|
||||
displayName = "$STR_AGM_Backpacks_UnlockBackpack";
|
||||
condition = "[backpackContainer _player] call AGM_Backpacks_fnc_isBackpack && {(backpackContainer _player) getVariable ['AGM_LockedInventory', false]}";
|
||||
statement = "(backpackContainer _player) setVariable ['AGM_LockedInventory', false, true]";
|
||||
showDisabled = 0;
|
||||
priority = 2.5;
|
||||
icon = ""; // @todo
|
||||
hotkey = "L";
|
||||
enableInside = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Author: bux, commy2
|
||||
*
|
||||
* Handle the open inventory event. Don't open the inventory if it's locked and display message.
|
||||
*
|
||||
* Argument:
|
||||
* Input from "InventoryOpened" eventhandler
|
||||
*
|
||||
* Return value:
|
||||
* Don't open the inventory dialog? (Bool)
|
||||
*/
|
||||
|
||||
private ["_target", "_isBackpack", "_isLocked", "_return"];
|
||||
|
||||
_target = _this select 1;
|
||||
|
||||
_isBackpack = [_target] call AGM_Backpacks_fnc_isBackpack;
|
||||
_isLocked = _target getVariable ["AGM_LockedInventory", false];
|
||||
|
||||
_return = false;
|
||||
if (_isBackpack) then {
|
||||
// target is a backpack
|
||||
private "_unit";
|
||||
_unit = [_target] call AGM_Backpacks_fnc_getBackpackAssignedUnit;
|
||||
|
||||
if (!alive _unit || {_unit getVariable ["AGM_isUnconscious", false]}) exitWith {};
|
||||
|
||||
if (_isLocked) then {
|
||||
// target is a locked backpack
|
||||
[format [localize "STR_AGM_Backpacks_BackpackLocked", [_unit] call AGM_Core_fnc_getName]] call AGM_Core_fnc_displayTextStructured;
|
||||
_return = true;
|
||||
} else {
|
||||
// target is a not-locked backpack
|
||||
if (_unit getVariable ["AGM_LockedInventory", false]) then {
|
||||
[localize "STR_AGM_Backpacks_InventoryLocked"] call AGM_Core_fnc_displayTextStructured;
|
||||
_return = true;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
// target is not a backpack
|
||||
if (_isLocked) then {
|
||||
[localize "STR_AGM_Backpacks_InventoryLocked"] call AGM_Core_fnc_displayTextStructured;
|
||||
_return = true;
|
||||
};
|
||||
};
|
||||
_return
|
1
addons/lockbackpacks/$PBOPREFIX$
Normal file
1
addons/lockbackpacks/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\lockbackpacks
|
14
addons/lockbackpacks/CfgEventHandlers.hpp
Normal file
14
addons/lockbackpacks/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_InventoryOpened_EventHandlers {
|
||||
class CAManBase {
|
||||
class GVAR(onOpenInventory) {
|
||||
clientInventoryOpened = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(onOpenInventory)};);
|
||||
};
|
||||
};
|
||||
};
|
31
addons/lockbackpacks/CfgVehicles.hpp
Normal file
31
addons/lockbackpacks/CfgVehicles.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class ACE_LockBackpack {
|
||||
displayName = "$STR_ACE_LockBackpacks_LockBackpack";
|
||||
condition = QUOTE([backpackContainer _player] call FUNC(isBackpack) && {!((backpackContainer _player) getVariable [ARR_2('ACE_LockedInventory', false)])});
|
||||
statement = QUOTE((backpackContainer _player) setVariable [ARR_3('ACE_LockedInventory', true, true)];);
|
||||
showDisabled = 0;
|
||||
priority = 2.5;
|
||||
icon = ""; // @todo
|
||||
hotkey = "L";
|
||||
enableInside = 1;
|
||||
};
|
||||
|
||||
class ACE_UnlockBackpack {
|
||||
displayName = "$STR_ACE_LockBackpacks_UnlockBackpack";
|
||||
condition = QUOTE([backpackContainer _player] call FUNC(isBackpack) && {(backpackContainer _player) getVariable [ARR_2('ACE_LockedInventory', false)]});
|
||||
statement = QUOTE((backpackContainer _player) setVariable [ARR_3('ACE_LockedInventory', false, true)];);
|
||||
showDisabled = 0;
|
||||
priority = 2.5;
|
||||
icon = ""; // @todo
|
||||
hotkey = "L";
|
||||
enableInside = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
5
addons/lockbackpacks/XEH_preInit.sqf
Normal file
5
addons/lockbackpacks/XEH_preInit.sqf
Normal file
@ -0,0 +1,5 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
PREP(getBackpackAssignedUnit);
|
||||
PREP(isBackpack);
|
||||
PREP(onOpenInventory);
|
16
addons/lockbackpacks/config.cpp
Normal file
16
addons/lockbackpacks/config.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common","ace_interaction"};
|
||||
author[] = {"bux","commy2"};
|
||||
authorUrl = "https://github.com/commy2/";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
@ -9,6 +9,7 @@
|
||||
* Return value:
|
||||
* Unit that has the backpack equipped. (Object)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_backpack", "_unit"];
|
||||
|
||||
@ -16,6 +17,6 @@ _backpack = _this select 0;
|
||||
|
||||
_unit = objNull;
|
||||
{
|
||||
if (backpackContainer _x == _backpack) exitWith {_unit = _x};
|
||||
if (backpackContainer _x == _backpack) exitWith {_unit = _x};
|
||||
} forEach (allUnits + allDeadMen);
|
||||
_unit
|
@ -9,13 +9,14 @@
|
||||
* Return value:
|
||||
* Boolean (Bool)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_backpack", "_config"];
|
||||
|
||||
_backpack = _this select 0;
|
||||
|
||||
if (typeName _backpack == "OBJECT") then {
|
||||
_backpack = typeOf _backpack;
|
||||
_backpack = typeOf _backpack;
|
||||
};
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> _backpack;
|
47
addons/lockbackpacks/functions/fnc_onOpenInventory.sqf
Normal file
47
addons/lockbackpacks/functions/fnc_onOpenInventory.sqf
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: bux, commy2
|
||||
*
|
||||
* Handle the open inventory event. Don't open the inventory if it's locked and display message.
|
||||
*
|
||||
* Argument:
|
||||
* Input from "InventoryOpened" eventhandler
|
||||
*
|
||||
* Return value:
|
||||
* Don't open the inventory dialog? (Bool)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_target", "_isBackpack", "_isLocked", "_return"];
|
||||
|
||||
_target = _this select 1;
|
||||
|
||||
_isBackpack = [_target] call FUNC(isBackpack);
|
||||
_isLocked = _target getVariable ["ACE_LockedInventory", false];
|
||||
|
||||
_return = false;
|
||||
if (_isBackpack) then {
|
||||
// target is a backpack
|
||||
private "_unit";
|
||||
_unit = [_target] call FUNC(getBackpackAssignedUnit);
|
||||
|
||||
if (!alive _unit || {_unit getVariable ["ACE_isUnconscious", false]}) exitWith {};
|
||||
|
||||
if (_isLocked) then {
|
||||
// target is a locked backpack
|
||||
[format [localize "STR_ACE_LockBackpacks_BackpackLocked", [_unit] call EFUNC(common,getName)]] call EFUNC(common,displayTextStructured);
|
||||
_return = true;
|
||||
} else {
|
||||
// target is a not-locked backpack
|
||||
if (_unit getVariable ["ACE_LockedInventory", false]) then {
|
||||
[localize "STR_ACE_LockBackpacks_InventoryLocked"] call EFUNC(common,displayTextStructured);
|
||||
_return = true;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
// target is not a backpack
|
||||
if (_isLocked) then {
|
||||
[localize "STR_ACE_LockBackpacks_InventoryLocked"] call EFUNC(common,displayTextStructured);
|
||||
_return = true;
|
||||
};
|
||||
};
|
||||
_return
|
1
addons/lockbackpacks/functions/script_component.hpp
Normal file
1
addons/lockbackpacks/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\lockbackpacks\script_component.hpp"
|
12
addons/lockbackpacks/script_component.hpp
Normal file
12
addons/lockbackpacks/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#define COMPONENT lockbackpacks
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_LOCKBACKPACKS
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ENABLED_LOCKBACKPACKS
|
||||
#define DEBUG_SETTINGS DEBUG_ENABLED_LOCKBACKPACKS
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Edited with tabler - 2014-12-21 -->
|
||||
<Project name="AGM">
|
||||
<Package name="Backpacks">
|
||||
<Key ID="STR_AGM_Backpacks_BackpackVentralTake">
|
||||
<Project name="ACE">
|
||||
<Package name="LockBackpacks">
|
||||
<Key ID="STR_ACE_LockBackpacks_BackpackVentralTake">
|
||||
<English>Take (Ventral)</English>
|
||||
<German>Aufnehmen (Am Bauch)</German>
|
||||
<Spanish>Coger (Mochila delantera)</Spanish>
|
||||
@ -14,7 +14,7 @@
|
||||
<Portuguese>Pegar (Mochila Ventral)</Portuguese>
|
||||
<Italian>Prendi</Italian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_Backpacks_BackpackVentralPut">
|
||||
<Key ID="STR_ACE_LockBackpacks_BackpackVentralPut">
|
||||
<English>Take Off Backpack</English>
|
||||
<German>Rucksack ablegen</German>
|
||||
<Spanish>Dejar mochila</Spanish>
|
||||
@ -26,7 +26,7 @@
|
||||
<Portuguese>Retirar Mochila</Portuguese>
|
||||
<Italian>Togliere zaino</Italian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_Backpacks_LockBackpack">
|
||||
<Key ID="STR_ACE_LockBackpacks_LockBackpack">
|
||||
<English>Lock Backpack</English>
|
||||
<German>Rucksack verschließen</German>
|
||||
<French>Verrouiller le sac à dos</French>
|
||||
@ -36,7 +36,7 @@
|
||||
<Hungarian>Táska zárolása</Hungarian>
|
||||
<Russian>Запереть рюкзак</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_Backpacks_UnlockBackpack">
|
||||
<Key ID="STR_ACE_LockBackpacks_UnlockBackpack">
|
||||
<English>Unlock Backpack</English>
|
||||
<German>Rucksack aufschließen</German>
|
||||
<French>Déverouiller le sac à dos</French>
|
||||
@ -46,7 +46,7 @@
|
||||
<Hungarian>Táska nyitása</Hungarian>
|
||||
<Russian>Отпереть рюкзак</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_Backpacks_BackpackLocked">
|
||||
<Key ID="STR_ACE_LockBackpacks_BackpackLocked">
|
||||
<English>Backpack of %1 is locked</English>
|
||||
<German>Der Rucksack von %1 ist verschlossen</German>
|
||||
<French>Le sac à dos de %1 est verroullé</French>
|
||||
@ -56,7 +56,7 @@
|
||||
<Hungarian>%1 táskája zárolva</Hungarian>
|
||||
<Russian>Рюкзак %1 заперт</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_Backpacks_InventoryLocked">
|
||||
<Key ID="STR_ACE_LockBackpacks_InventoryLocked">
|
||||
<English>Inventory is locked</English>
|
||||
<German>Das Inventar ist verschlossen</German>
|
||||
<French>L'inventaire est verrouillé</French>
|
Loading…
Reference in New Issue
Block a user