Hello,
It's possible to put an "addaction" command to a certain building door ?
I did locked all this building doors via gamelogic (9 doors in total). Now I want to put an addaction to some of this doors. Is there any easy way to do it?
I know there are some scripts to breach doors and all, but I was thinking to do it as simple as possible, just an addaction to unlock/picklock. That's it.
For info, the map is Zargabad.
Thank you in advance
You can add actions to specific selections of an object, doing something like a lock/unlock system isn't simple by any means though.
Feel free to use and adapt the snippet I quickly sketched together.
To lock all doors you need to go through all door selections and set a special variable on them.
Why BIS implemented a module instead of a dedicated script command to do this is beyond me.
So using this snippet you no longer need the editor modules.
Something like this will lock all building doors, add a lock/unlock option to every door and also has a check for the owner of the building, so players can only open doors on buildings they own:
//put these three functions in init.sqf
GOM_fnc_lockBuildingDoor = {
params ["_building","_door"];
_building addAction ["Unlock door",{
params ["_object","_caller","_ID","_door"];
if (_object in (_caller getVariable ["GOM_fnc_keyRing",[]])) exitWith {
_object removeAction _ID;
_object setVariable [format ["bis_disabled_%1",_door],0,true];
systemchat "Door unlocked.";
playSound "Click";
_unlockAction = [_object,_door,_caller] call GOM_fnc_unlockBuildingDoor;
};
systemchat "This door is locked!";//your code here
playSound "Click";
},_door,6,true,true,"","_this isEqualTo vehicle _this",15,false,_door];
};
GOM_fnc_unlockBuildingDoor = {
params ["_building","_door"];
_building addAction ["Lock door",{
params ["_object","_caller","_ID","_door"];
if (_object in (_caller getVariable ["GOM_fnc_keyRing",[]])) exitWith {
_object removeAction _ID;
_object setVariable [format ["bis_disabled_%1",_door],1,true];
systemchat "Door locked.";
playSound "Click";
_lockAction = [_object,_door,_caller] call GOM_fnc_lockBuildingDoor;
};
},_door,6,true,true,"","_this isEqualTo vehicle _this",15,false,_door];
};
GOM_fnc_initBuildingDoors = {
params ["_building","_owner"];
//this adds the building to the specified player so he can unlock the doors
_alreadyOwned = _owner getVariable ["GOM_fnc_keyRing",[]];
_alreadyOwned pushBackUnique _building;
_owner setVariable ["GOM_fnc_keyRing",_alreadyOwned,true];
//grabbing all valid doors
_selectionNames = selectionNames _building;
_doors = _selectionNames select {toUpper _x find "DOOR" >= 0 AND toUpper _x find "HANDLE" == -1};
{
//lock all doors and add the actions
_building setVariable [format ["bis_disabled_%1",_x],1,true];
_lock = [_building,_x] call GOM_fnc_lockBuildingDoor;
} forEach _doors;
};
Now to initialize a building and owner to this system simply do this during mission runtime or wherever you seem fit:
_building = cursorObject;
_owner = player;
//this sets the player as owner and locks all doors and adds all respective actions
_init = [_building,_owner] call GOM_fnc_initBuildingDoors;
Cheers