ATU.Lasthope

interactions

10 posts in this topic

TBH Do not know if this is the right place for it so sorry if it is!

FE. moving cuffed players and a surrender 

Im spent over a month trying to create my own interaction and got no where. has anyone else got anything 

Edited by ATU.Lasthope

Share this post


Link to post
Share on other sites

Drag Handcuffed players (not my script). I was trying to change this to drag a dead player.

initPlayerLocal.sqf

Spoiler

ExileClientPlayerIsDragging = false;
XG_DragPlayer = compileFinal preprocessFileLineNumbers "custom\drag\drag.sqf";   

custom\drag\drag.sqf

Spoiler

switch (_this) do
{
    case "Drag":
    {
        player playMoveNow "AcinPknlMstpSrasWrflDnon";
        ExileClientInteractionObject attachTo [player, [0, 1.1, 0.092]];
        ExileClientInteractionObject setVariable["IsBeingDragged",true,true];
        ExileClientDraggedPlayer = ExileClientInteractionObject;
        ExileClientPlayerIsDragging = true;
        _code =
        {
            _animation = animationState player;
            if!((_animation isEqualTo "acinpknlmstpsraswrfldnon") || _animation isEqualTo "acinpknlmwlksraswrfldb") then
            {
                player playMoveNow "AcinPknlMstpSrasWrflDnon";
            };
            if!(alive player) then
            {
                "End" call XG_DragPlayer;
            };
            if!(alive ExileClientDraggedPlayer) then
            {
                "End" call XG_DragPlayer;
            };
            if!((vehicle player) isEqualTo player) then
            {
                player action["Eject", (vehicle player)];
            };
        };
        ExileClientDraggingThreadID = [0.1,_code,[],true] call ExileClient_system_thread_addtask;
        call ExileClient_gui_interactionMenu_unhook;
    };
    case "End":
    {
        try
        {
            if((count(nearestObjects [(getpos ExileClientDraggedPlayer),["Exile_Construction_Abstract_Static","House"],3])) != 0) then
            {
                throw "Are you trying to glitch?";
            };
            if!(ExileClientDraggedPlayer getVariable["IsBeingDragged",false]) then
            {
                throw "The target is not being dragged!";
            };
            player playMove "AmovPknlMstpSrasWrflDnon";
            detach ExileClientDraggedPlayer;
            ExileClientDraggedPlayer setVariable["IsBeingDragged",false,true];
            ExileClientPlayerIsDragging = false;
            [ExileClientDraggingThreadID] call ExileClient_system_thread_removeTask;
            call ExileClient_gui_interactionMenu_unhook;
        }
        catch
        {    
            ["ErrorTitleOnly", [_exception]] call ExileClient_gui_toaster_addTemplateToast;
        };
    };
};

 

Find class CfgExileCustomCode in your mission config.cpp and add:

class CfgExileCustomCode
{
    /*
        You can overwrite every single file of our code without touching it.
        To do that, add the function name you want to overwrite plus the
        path to your custom file here. If you wonder how this works, have a
        look at our bootstrap/fn_preInit.sqf function.

        Simply add the following scheme here:

        <Function Name of Exile> = "<New File Name>";

        Example:

        ExileClient_util_fusRoDah = "myaddon\myfunction.sqf";
    */
    ExileClient_object_handcuffs_use = "ExileClient_object_handcuffs_use .sqf";
};

Spoiler

/**
 * ExileClient_object_handcuffs_use
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_success","_object"];
_success = false;
try
{
    if !(alive player) then
    {
        throw false;
    };
    if (ExileClientIsHandcuffed) then
    {
        throw false;
    };
    if (ExilePlayerInSafezone) then
    {
        throw false;
    };
    if !(((currentThrowable player) select 0) isEqualTo "Exile_Item_ZipTie") then
    {
        throw false;
    };
    _object = cursorTarget;
    if (_object isEqualTo player) then
    {
        throw false;
    };
    if !(_object isKindOf "Exile_Unit_Player") then
    {
        throw false;
    };
    if !(isPlayer _object) then
    {
        throw false;
    };
    if !(alive _object) then
    {
        throw false;
    };
    if (_object getVariable ["ExileIsHandcuffed", false]) then
    {
        throw false;  
    };
    if ((player distance _object) > 2) then
    {
        throw false;  
    };
    ["handcuffRequest", [netId _object]] call ExileClient_system_network_send;
    call ExileClient_gui_interactionMenu_unhook;
}
catch
{
    _success = _exception;
};
_success

config.cpp
 

Spoiler

class Player
{
    targetType = 2;
    target = "Exile_Unit_Player";

    class Actions
    {
        class Drag: ExileAbstractAction
        {
            title = "Drag";
            condition = "(alive ExileClientInteractionObject) && (ExileClientInteractionObject getVariable ['ExileIsHandcuffed', false]) && !(ExileClientIsHandcuffed) && !(ExileClientInteractionObject getVariable['IsBeingDragged',false])";
            action = "'Drag' call XG_DragPlayer";
        };
        class EndDrag: ExileAbstractAction
        {
            title = "Stop Dragging";
            condition = "(alive ExileClientInteractionObject) && (ExileClientInteractionObject getVariable ['ExileIsHandcuffed', false]) && !(ExileClientIsHandcuffed) && (ExileClientInteractionObject getVariable['IsBeingDragged',false]) && ExileClientPlayerIsDragging";
            action = "'End' call XG_DragPlayer";
        };
        class Free: ExileAbstractAction
        {
            title = "Free";
            condition = "(alive ExileClientInteractionObject) && (ExileClientInteractionObject getVariable ['ExileIsHandcuffed', false]) && !(ExileClientIsHandcuffed) && !(ExileClientInteractionObject getVariable['IsBeingDragged',false]) && !(ExileClientPlayerIsDragging)";
            action = "_this call ExileClient_object_handcuffs_free";
        };
        class Search: ExileAbstractAction
        {
            title = "Search Gear";
            condition = "(alive ExileClientInteractionObject) && (ExileClientInteractionObject getVariable ['ExileIsHandcuffed', false]) && !(ExileClientIsHandcuffed) && !(ExileClientInteractionObject getVariable['IsBeingDragged',false]) && !(ExileClientPlayerIsDragging)";
            action = "_this call ExileClient_object_handcuffs_searchGear";
        };

        class Identify: ExileAbstractAction
        {
            title = "Identify Body";
            condition = "!(alive ExileClientInteractionObject)";
            action = "_this call ExileClient_object_player_identifyBody";
        };
        
        class HideCorpse: ExileAbstractAction
        {
            title = "Hide Body";
            condition = "!(alive ExileClientInteractionObject) && ('Exile_Melee_Shovel' isEqualTo (currentWeapon player))";
            action = "['HideBody', (_this select 0)] call ExileClient_action_execute";
        };
    };
};

 

Not sure who coded this to give them credits.

Double check the latest ExileClient_object_handcuffs_use.sqf to see that there has been no extra code added over updates, this is old code.

Share this post


Link to post
Share on other sites
Advertisement

It does work, I managed to drag a dead player with it.

I probably didnt explain this bit well:

Find class CfgExileCustomCode in your mission config.cpp and add:

Spoiler

class CfgExileCustomCode
{
    /*
        You can overwrite every single file of our code without touching it.
        To do that, add the function name you want to overwrite plus the
        path to your custom file here. If you wonder how this works, have a
        look at our bootstrap/fn_preInit.sqf function.

        Simply add the following scheme here:

        <Function Name of Exile> = "<New File Name>";

        Example:

        ExileClient_util_fusRoDah = "myaddon\myfunction.sqf";
    */
    ExileClient_object_handcuffs_use = "custom\drag\ExileClient_object_handcuffs_use.sqf.sqf";
};


Drop this file into the drag folder that you created:

custom\drag\ExileClient_object_handcuffs_use.sqf

Spoiler

/**
 * ExileClient_object_handcuffs_use
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_success","_object"];
_success = false;
try
{
    if !(alive player) then
    {
        throw false;
    };
    if (ExileClientIsHandcuffed) then
    {
        throw false;
    };
    if (ExilePlayerInSafezone) then
    {
        throw false;
    };
    if !(((currentThrowable player) select 0) isEqualTo "Exile_Item_ZipTie") then
    {
        throw false;
    };
    _object = cursorTarget;
    if (_object isEqualTo player) then
    {
        throw false;
    };
    if !(_object isKindOf "Exile_Unit_Player") then
    {
        throw false;
    };
    if !(isPlayer _object) then
    {
        throw false;
    };
    if !(alive _object) then
    {
        throw false;
    };
    if (_object getVariable ["ExileIsHandcuffed", false]) then
    {
        throw false;  
    };
    if ((player distance _object) > 2) then
    {
        throw false;  
    };
    ["handcuffRequest", [netId _object]] call ExileClient_system_network_send;
    call ExileClient_gui_interactionMenu_unhook;
}
catch
{
    _success = _exception;
};
_success

 

Edited by aussie battler

Share this post


Link to post
Share on other sites

Animations are pretty simple to run. I'll use one I wrote as an example. So you have a player who is handcuffed and you can search thru their gear which is all fine and dandy, but I wanted more. So I thought, why not have a beat up feature. Awesome, so I created a simple executable that would remove 5 health points every time it was executed. Alright, this is cool, but it's missing something. So I went diving through the hundreds of animations that Arma 3 has to offer. I found one that was a swinging motion with a pistol in their hand. Perfect! Now it looks like we're pistol whipping the guy. Hilarious!

Now to how I did it. So first we start off with the SQF file we'll execute when the action is selected. I create my SQF file and name it fnc_BeatUp:
 

private["_player"];
_player = _this select 0;

if (_player getVariable ["ExileIsHandcuffed", false]) then //Check to make sure the player is handcuffed
{
	player playMoveNow "AwopPercMstpSgthWnonDnon_end"; //Execute the animation

	_player setDamage 0.05; //Remove 5 hitpoints from the handcuffed player

	_name = _player getVariable ["ExileName", -1]; //Pull the name of the handcuffed player
	if !(_name isEqualTo -1) then 
	{
		["InfoTitleAndText", //setup message to client
			[
				"Beat Up",
				format ["You have beaten up %1", _name] //Message reads You have beaten up name of handcuffed player
			]
		] call ExileClient_gui_toaster_addTemplateToast; //Send message to client
	};
};
call ExileClient_gui_interactionMenu_unhook;

Now I want to setup a way to execute it thru an action. I could just call the SQF file in the action, but I don't like doing things that way. So I create a function. I make a SQF file called fn_preInit and add in the needed code:
 

private ['_code', '_function', '_file'];

{
    _code = '';
    _function = _x select 0;
    _file = _x select 1;

    _code = compileFinal (preprocessFileLineNumbers _file);

    missionNamespace setVariable [_function, _code];
}
forEach
[
	["fnc_BeatUp","scripts\Functions\fnc_BeatUp.sqf"] //assign function name fnc_Beatup to fnc_BeatUp.sqf
];

true

Cool, now I have a simple function I can use instead of typing scripts\Functions\fnc_BeatUp every time I want to use the damn thing. You don't have to do that step, but I hate long directory paths in my code. Now I need to have the server run this SQP function file every time the server starts up, so I'll add a class CfgFunctions to my Description.ext
 

class CfgFunctions
{
	class Functions
    {
        class Bootstrap
        {
            file="scripts";
            class preInit
            {
                preInit = 1;
            };
        };
    };
};

Now we could clean that up and add the class Function to a CPP file else where and call it in the Description class CfgFunctions with a #include but I'm not, sue me. Okay so now we have our code, we have our function name assigned to the SQF, and we have out fn_preInit SQF being executed on startup. Last step is to add it to an action. We go into our Config CPP file and locate the Player to Player action handler and make a new one:
 

	class Player 
	{
		targetType = 2;
		target = "Exile_Unit_Player";

		class Actions 
		{
			class Beat: ExileAbstractAction //Add a custom class name
			{
				title = "Beat Up"; //Give our Action a name
				condition = "(alive ExileClientInteractionObject) && (ExileClientInteractionObject getVariable ['ExileIsHandcuffed', false]) && !ExileClientIsHandcuffed"; //This condition checks for Handcuffed players and won't show the action unless the player is handcuffed
				action = "_this call fnc_BeatUp"; //execute our function
			};
		};
	};

And that is an extensive breakdown of how to execute a Player to Player action. It's important to note that the class Player action handler is strictly Player to Player actions and NOT Player to self. So if you wanted to do something like the surrender option, you will need to setup a Show Action function. I have already done that in a script release. It's the interior vehicle lock and unlock function. That would be a good place to learn how to setup show action and assign Surrender to a key rather than a scroll wheel option so players don't have it on their screens 24/7. Lastly I'll leave you with this. These two links are some animations and how to execute them. Just copy my method above and make changes where needed. I have given you the method of executing an animation on yourself and pointed you where you can find how I assign functions to keys. Hope it helps.

Animations
https://community.bistudio.com/wiki/BIS_fnc_ambientAnim
https://community.bistudio.com/wiki/ArmA:_Moves

Edited by Beowulfv
  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.