Jump to content

Restrain player


Tarabas

Recommended Posts

This is a script to restrain a player you stand close to (needs a rope - until i find a better solution like handcuffs/zipties)

all credits go to @He-Man Thank you for your support again

The link to the action-pic and the prepared script is here:

https://www.dropbox.com/s/xjmfqi9xywp8dpq/restrainscript.zip

 

in init.sqf add

 


 restraincheck = compileFinal  preprocessFileLineNumbers "addons\restrain\restraincheck.sqf";
restrain = compileFinal  preprocessFileLineNumbers "addons\restrain\restrain.sqf"; 

in CfgRemoteExec.hpp add

 


	    class restrain {
      allowedTargets=1;
      jip = 0;
    };

in CfgActionMenu_target.hpp add

 



 class restrainPlayer
{
    condition = "dyna_isPlayer && (damage dyna_cursorTarget < 1) && !(dyna_cursorTarget getvariable ['restrain',false])";
    action= "if !('ItemRope' in magazines player) exitwith {['Get a rope to restrain a player!',5] call Epoch_Message;};player removeitem 'ItemRope';dyna_cursorTarget call restraincheck;";
    icon = "addons\pics\Actions\restrain.paa";
    tooltip = "Restrain player";
};
class unrestrainPlayer
{
    condition = "dyna_isPlayer && (damage dyna_cursorTarget < 1) && dyna_cursorTarget getvariable ['restrain',false]";
    action= "dyna_cursorTarget call restraincheck;";
    icon = "addons\pics\Actions\restrain.paa";
    tooltip = "UnRestrain player";
}; 

in addons\restrain\restrain.sqf write

 



 params ["_target","_caller","_isrestrained"];
if !(player isEqualTo _target) exitwith {};
if (_target isEqualTo _caller) exitwith {};
if (_target distance _caller > 10) exitwith {};
if (vehicle player != player) exitwith {['Restrain warning!', 5] call Epoch_message;};
if (_isrestrained) then {
    player setVariable ["restrain", false, true];
}
else {
    player setVariable ["restrain", true, true];
    [] spawn {
        _pos = getposatl player;
        while {player getVariable ["restrain", false]}  do {
            player playMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Animation in
            player setposatl _pos;            
            if (((!alive player) || (player getVariable["onkill",FALSE]))) then {
                player setVariable ["restrain", false, true];
            };
        };
        player playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
    };
}; 

 

and in addons\restrain\restraincheck.sqf write

 



 _target = _this;
_isrestrained = _target getVariable ["restrain", false];
[_target,player,_isrestrained] remoteexec ["restrain",_target];

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...