This tutorial will allow you to add a function so that only "Cop" can open/close doors.
___________________________________
Installation
- Go to the root of your mission then core/cop
- Create a file fn_lockCop.sqf
- In this file add the following code:
Code:
/*
Put it in the init of the object
this addAction ["Lock/Unlock", "core\cop\fn_LockCop.sqf","",0,false,false,"","side player isEqualTo WEST"];
this setVariable ["lockedDoor",true];
this setVariable ["BIS_Disabled_Door_1",1,true];
this setVariable ["BIS_Disabled_Door_2",1,true];
this allowDamage false;
FORMAT
BIS_Disabled_Door_2,0,true
BIS_Disabled_Door_%1 == %1 If a gate have two doors there is BIS_Disabled_Door_1 && BIS_Disabled_Door_2
0 == unlock && 1 == lock
true == idk
*/
if !(side player isEqualTo WEST) exitWith {}; // Only police officers can open
_door = _this select 0;
_door2 = _door getVariable "lockedDoor";
if (_door2 isEqualTo true) then
{
_door setVariable ["BIS_Disabled_Door_1",0,true];
_door setVariable ["BIS_Disabled_Door_2",0,true];
_door setVariable ["lockedDoor",false];
hint "The door is unlocked";
} else {
_door setVariable ["BIS_Disabled_Door_1",1,true];
_door setVariable ["BIS_Disabled_Door_2",1,true];
_door setVariable ["lockedDoor",true];
hint "The door is locked";
};
- Go to your Functions.hpp at the root of your mission and add this
Code:
class lockCop {};
- Go to your mapping and add this code to the object you want to block
Code:
this addAction ["Lock/Unlock", life_fnc_lockCop,"",0,false,false,"","side player isEqualTo WEST"];
this setVariable ["lockedDoor",true];
this setVariable ["BIS_Disabled_Door_1",1,true];
this setVariable ["BIS_Disabled_Door_2",1,true];
this allowDamage false;
- For those who want to do the close/open with an object Y here is the code
Dernière édition par un modérateur: