Jump to content
Chris_37

BIS_fnc_holdActionAdd to dead bodys?

Recommended Posts

Im wanting to use BIS_fnc_holdActionAdd however im struggling to add it to a dead player body any ideas? i can easily do a addaction but cant seem to work out what the  target: Object - Object the action is attached to" would be for a players dead body.

Share this post


Link to post
Share on other sites

you could use the "onPlayerKilled.sqf" event script          and it would add it to player unit when the player dies?

Share this post


Link to post
Share on other sites

T

13 hours ago, HazJ said:

Another way is addEventHandler command.

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers


player addEventHandler ["Killed",
{
	params ["_unit", "_killer"];
	// add BIS_fnc_holdActionAdd to _unit
}];

 

 

14 hours ago, lordfrith said:

you could use the "onPlayerKilled.sqf" event script          and it would add it to player unit when the player dies?

 

Thanks guys really helped however can you not use getVariable in the Condition for the action to be shown?

Share this post


Link to post
Share on other sites
3 minutes ago, Chris_37 said:

Thanks guys really helped however can you not use getVariable in the Condition for the action to be shown?

 

how were you trying to use it and what variable? it should be possible i think as long as the syntax is right...

 

could you maybe post an example of what you're trying to do

Share this post


Link to post
Share on other sites
31 minutes ago, Chris_37 said:

T

 

 

Thanks guys really helped however can you not use getVariable in the Condition for the action to be shown?

Of course you can, in the conditionShow parameter, take a look at the wiki.

 

Cheers

Share this post


Link to post
Share on other sites
45 minutes ago, lordfrith said:

 

how were you trying to use it and what variable? it should be possible i think as long as the syntax is right...

 

could you maybe post an example of what you're trying to do

player addEventHandler ["Killed",
{
    params ["_unit", "_killer"];
    [
    _unit,                                                                                                                              // Object the action is attached to
    "Harvest Organs",                                                                                                                        // Title of the action
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",                     // Idle icon shown on screen
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",                // Progress icon shown on screen
    "_target getVariable ["Organs",false];",                                                        // Condition for the action to be shown
    "_caller distance _target < 3",                                                      // Condition for the action to progress
    {},                                                                                  // Code executed when action starts
    {},                                                                                  // Code executed on every progress tick
    {hint "test";},                                                // Code executed on completion
    {},                                                                                  // Code executed on interrupted
    [],                                                                                  // Arguments passed to the scripts as _this select 3
    12,                                                                                  // Action duration

    0,                                                                                   // Priority
    true,                                                                                // Remove on completion
    false                                                                                // Show in unconscious state 
] remoteExec ["BIS_fnc_holdActionAdd", [0,2] select isDedicated, _unit]; 

 

not sure if i should be using _target or not?

i also get this error

12:18:03 Error in expression                 
"_target getVariable ["Organs",false];",                       
12:18:03   Error position: <Organs",false];",                       
12:18:03   Error Missing ]

Share this post


Link to post
Share on other sites
39 minutes ago, Chris_37 said:

not sure if i should be using _target or not?

i also get this error

12:18:03 Error in expression                 
"_target getVariable ["Organs",false];",                       
12:18:03   Error position: <Organs",false];",                       
12:18:03   Error Missing ]

 

in this case _unit is what you're using for _target, see if changing that helps.

Share this post


Link to post
Share on other sites

thanks not getting any errors now however i am getting no action on the body?

Share this post


Link to post
Share on other sites
1 hour ago, Chris_37 said:

"_caller distance _target < 3",

 

same problem here in that _caller won't be defined, use _killer (or add the _instigator param as that always returns a unit, see event handlers wiki above for details)

Share this post


Link to post
Share on other sites
Spoiler

this addEventHandler ["Killed",  //changed to this as i was messing about with one unit in editor
        {
                params ["_unit", "_killer", "_instigator"];
                [
                _unit,                                                                                                                             
                "Harvest Organs",                                                                                                                     
                "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",                  
                "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",              
                "true",                                                    
                "true",                                                      
    {},                                                                                 
    {},                                                                                 
    {hint "test";},                                              
    {},                                                                        
    [],                                                                    
    12,                                                                         

    0,                                                                               
    true,                                                                           
    false                                                                               
] remoteExec ["BIS_fnc_holdActionAdd",[0,2] select isDedicated, _unit];}  ];

 

 

so... i got this working by placing a civilian unit on editor, pasting your code in, tweaking it till it worked.

 

there were some bracket issues, mostly and i could only get it to work once i'd replaced condition with "true", still going to have a look at the conditions but this should maybe help some syntax issues.

Share this post


Link to post
Share on other sites

_unit getVariable ["Organs",false] seems to work but its a little temperamental.........

 

also how does the BIS_fnc_holdActionRemove because whats the id?

Share this post


Link to post
Share on other sites

my bad, i'd not noticed something in the wiki  :

 

Quote

condShow: String - Condition for the action to be shown. Special variables passed to the script code are _target (unit to which action is attached to) and _this (caller/executing unit)

condProgress: String - Condition for the action to progress.If false is returned action progress is halted; arguments passed into it are: _target, _caller, _id, _arguments

 

so _target is fine! sorry mate :D its a lot to absorb in one go...

 

anyways heres the latest test that seems to work as intended. note it only worked when i set "organs" to true...

 

Spoiler

this setVariable ["Organs", true];       //using 'this' as testing on placed civ unit

this addEventHandler ["Killed",  
  {
    params ["_unit", "_killer", "_instigator"];  //added _instigator through force of habit... don't think its neccisary ;)
    [
    _unit,                                                                                                                              
    "Harvest Organs",                                                                                                                      
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",                   
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",               
    "_target getVariable ['Organs',false]",                                                         //organs is already in quotes so use single '
    "_target  distance _caller  < 3",                                                      
    {},                                                                                  
    {},                                                                                  
    {hint "test";},                                               
    {},                                                                         
    [],                                                                     
    12,                                                                          
 
    0,                                                                                
    true,                                                                            
    false                                                                                
] remoteExec ["BIS_fnc_holdActionAdd",[0,2] select isDedicated, _unit];}  ];

 

Share this post


Link to post
Share on other sites
26 minutes ago, lordfrith said:

my bad, i'd not noticed something in the wiki  :

 

 

so _target is fine! sorry mate :D its a lot to absorb in one go...

 

anyways heres the latest test that seems to work as intended. note it only worked when i set "organs" to true...

 

  Hide contents

this setVariable ["Organs", true];       //using 'this' as testing on placed civ unit

this addEventHandler ["Killed",  
  {
    params ["_unit", "_killer", "_instigator"];
    [
    _unit,                                                                                                                              
    "Harvest Organs",                                                                                                                      
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",                   
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",               
    "_target getVariable ['Organs',false]",                                                         //organs is already in quotes so use single '
    "_target  distance _caller  < 3",                                                      
    {},                                                                                  
    {},                                                                                  
    {hint "test";},                                               
    {},                                                                         
    [],                                                                     
    12,                                                                          
 
    0,                                                                                
    true,                                                                            
    false                                                                                
] remoteExec ["BIS_fnc_holdActionAdd",[0,2] select isDedicated, _unit];}  ];

 

thanks for the help 

any idea how i could remove that action after a certain amount of time?

Share this post


Link to post
Share on other sites
3 hours ago, Chris_37 said:

thanks for the help 

any idea how i could remove that action after a certain amount of time?

 

Keep track of the ID of the action, spawn a function that removes the action from the object after some time, similar to this:

 

//player dies, add some random action to the dead body
_ID = [holdactionstuffandparameters] call BIS_fnc_holdActionAdd;
_delay = [_ID,player] spawn {
	params ["_ID","_object"];
	sleep 30;
	_remove = [_object,_ID] call BIS_fnc_holdActionRemove;

};

Cheers

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

×