Jump to content
kibaBG

addAction disappears with barrel objects

Recommended Posts

I have made addAction to pick and drop some crates but its not working with barrel objects ... very strange ...
 

_crate = createVehicle ["Land_MetalBarrel_F",position helipad,[],0,"NONE"]; 
	_crate enableDynamicSimulation true;
	
	_crate addAction
			[
			"<t color='#FFFF80'>Pickup</t>",
			{
				params ["_target", "_caller", "_actionId", "_arguments"];
				_target attachTo [_caller,[0,2,1],"Pelivs"];
			},nil,1.5,false,false,"","true",3,false,"",""];
			
	_crate addAction 
			[
			"<t color='#FFFF80'>Drop</t>",
			{
				params ["_target", "_caller", "_actionId", "_arguments"];
				{
				detach _x;
				_x enableSimulationGlobal true;
				} forEach attachedObjects _caller;
			},nil,1.5,false,false,"","true",3,false,"",""];

Its working fine with other boxes, but not with anything that resembles barrels filled with fuel ("CargoNet_01_barrels_F") ... :dozingoff:

Share this post


Link to post
Share on other sites

1. Pelvis is misspelled. I'm surprised you didn't get an error. 
2. Your first addaction had an invisible character that precluded it from running. If you copied it from here, that is probably where you got it.
3. Now it adds the addactions, however once you pick it up, the object loses it's addaction, as it is attached to the player. To solve this, you need to assign the second addaction to the caller, not the object, and remove it when the caller drops it.

Example (tested):

// Create the barrel on the server
_crate = createVehicle ["Land_MetalBarrel_F", position helipad, [], 0, "NONE"];
_crate enableDynamicSimulation false;

_crate addAction
[
    "<t color='#FFFF80'>Pickup</t>",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];

     
        _target attachTo [_caller, [0, 2, 1], "Pelvis"];

   
        _caller addAction
        [
            "<t color='#FFFF80'>Drop</t>",
            {
                params ["_target", "_caller", "_actionId", "_arguments"];

                {
                    detach _x;
                    _x enableSimulationGlobal true;
                } forEach attachedObjects _caller;

                _caller removeAction _actionId;
            }
        ];
    },
    nil, 1.5, false, false, "", "true", 3, false, "", ""
];

 

  • Thanks 2

Share this post


Link to post
Share on other sites

Thanks, now its working perfectly. :icon_dj:

Edit: I have found the best relative pos for puckup objects to be

_target attachTo [_caller, [0,2,0],"Pelvis"];

 

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

×