Jump to content
MasterPuffin

[Release] Simple MP Restraining Script

Recommended Posts

Hello,

I searched a long time for a working restraining script, which works in MP. Long story short, I didn't found one, so I wrote one myself. Yes it's not perfect, so feel free to improve it, but it works.

 

********************************

Create a file called onPlayerRespawn.sqf (or use your existing one) and put the following code into it:

restrain=false;
restcaller=false;

 

Create a folder called scripts. Inside this folder create a file called restrain.sqf and put the following code into it:

restcaller = false;
if (restrain=false;) then {
	if (player distance cursortarget < 2) then {
		restcaller = true;
		[[[],"scripts\restrainTarget.sqf"],"BIS_fnc_execVM",cursortarget,false,false] call BIS_fnc_MP;
	};
};

player distance cursortarget < 2 --> the number is the max. distance in meters to restrain someone. Change it to whatever you want.

 

Inside the folder scripts create a file called restrainTarget.sqf and put the following code into it:

if (restcaller isEqualto false) then {
	if (restrain isEqualto false) then {
		restrain=true;
		player setVariable ["restrain", true, true];
		while { player getVariable ["restrain", false] }  do { 
			player playMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Animation in
			if (((!alive player) || (player getVariable["onkill",FALSE]))) then {
			player setVariable ["restrain", false, true];
			};
		};
		player playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	}
	else
	{
		restrain=false;
		player setVariable ["restrain", false, true]; //Set surrender to true
		player playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	};
};
restcaller = false;

 

Using the script: You can either use addaction or a keyhandler to execute the script. When you execute the script the player pointed at by the cursor will be restrained (as long as he's in your configured range). Executing the script again will set the player free.

 

If you have any questions or need help with your mission feel free to ask!

Cheers

Puffin

  • Like 2

Share this post


Link to post
Share on other sites

When someone is restrained can you please add an Enter Vehicle and Get Out of Vehicle command for the restrainer? That way the person being restrained will be able to be moved. 

 

 

Share this post


Link to post
Share on other sites
On 13.10.2017 at 7:02 AM, Taylor2.0 said:

@MasterPuffin Hey when i hit restrain it restrains me did i screw something up or?

Have you set the variables in the onPlayeRespawn.sqf correctly? Also try adding those variables in the init.sqf!

Share this post


Link to post
Share on other sites
On 12/8/2017 at 4:23 PM, MasterPuffin said:

Have you set the variables in the onPlayeRespawn.sqf correctly? Also try adding those variables in the init.sqf!

 

Ah ok i will try that thanks :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×