English Add closure for police officers only

  • Auteur de la discussion Auteur de la discussion I'm the Boss
  • Date de début Date de début

I'm the Boss

Admin
2/1/20
657
3
43
1 100
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:
Développer Réduire Copier
/*
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:
Développer Réduire Copier
class lockCop {};
  • Go to your mapping and add this code to the object you want to block
Code:
Développer Réduire Copier
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
Without modification it will be impossible to close the entire building with more than 2 doors
 
Dernière édition par un modérateur:
  • Like
Les réactions: Teravince
hello, i replaced my line by this one :
this addAction ["Ouvrir/Fermer", life_fnc_lockdoor,"",0,false,false,"","side player isEqualTo civilian && license_civ_martinez"]; in my init

in my file i putted this one :

if !(side player isEqualTo civilian && license_civ_martinez) exitWith {};

i made it for en enterprise

Should it work ???

Thank you ;)
 
Activité
Pour l'instant, il n'y a personne ici