Jump to content
Sign in to follow this  
sekurlsa

Help required with passing params to function using BIS_fnc_holdActionAdd .

Recommended Posts

Hello community,

 

I'm trying to optimize the code and further expand the functionality of a MP mission I've made: HazardZone

The idea is to create an Apex's hold action by passing couple of params, issue is I really can't figure out how to pass them - especially line 4, 8 and 9

For example, I just put params ["_sample", "_unit"]; in lines 10-13 and it works like a charm, but is there anyway to do it for the rest or for the whole function without specifying params on each line?

 

 

 

Hold Action Function:

createSample = 
{
	params ["_sample", "_unit"];
	[_sample, // Name of the object
	"Collect a sample", //title of the action
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
	"_unit distance _sample < 5", // The condition for the Action to be shown
	"_unit distance _sample < 5", // The condition for the Action to progress
	{}, // The code executed when the action starts
	{}, // The code executed on every progress tick 
	{},  // The Code which is executed on action completion
	{}, // The code which is executed when the player is interrrupted or stops interaction
	[], // No idea! Some arguments...
	5, // The duration how long will it take for the action to be completed in seconds
	0, // Priority
	false, // Remove the action once it has been completed
	false // show Unconsious state
	] remoteExec ["BIS_fnc_holdActionAdd", [0,-2] select isDedicated, true];
};

// This is how the function will be called
[objVar, playerVar] call createSample;

 

I really would really appreciate the help.


Thank you!

 

Share this post


Link to post
Share on other sites
Posted (edited)

Per your example you don't need _unit variable because you're using it for evaluating only the availability of the action which you can/have to replace with _this, _target and _caller (BIS_fnc_holdActionAdd example 2).

If you need it though you could pass it (to a total of ten custom variables) as arguments to be evaluated on codeStart, codeProgress, codeCompleted and codeInterrupted.

In the example below we are hinting our arguments on code completion.

All arguments are available through _this # 3 or params ["_target", "_caller", "_actionId", "_arguments"];.

createSample = {
	params ["_sample", "_unit"];
	[
		_sample, // Name of the object
		"Collect a sample", //title of the action
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
		"_this distance _target < 5", // The condition for the Action to be shown
		"_caller distance _target < 5", // The condition for the Action to progress
		{}, // The code executed when the action starts
		{}, // The code executed on every progress tick 
		{
			params ["_target", "_caller", "_actionId", "_arguments"];
			_arguments params ["_sample", "_unit"];
			hint str [_sample,_unit];
		},  // The Code which is executed on action completion
		{}, // The code which is executed when the player is interrrupted or stops interaction
		[_sample, _unit], // Arguments passed to the scripts as _this select 3
		5, // The duration how long will it take for the action to be completed in seconds
		0, // Priority
		false, // Remove the action once it has been completed
		false // show Unconsious state
	] remoteExec ["BIS_fnc_holdActionAdd", [0,-2] select isDedicated, true];
};

// This is how the function will be called
[objVar, playerVar] call createSample;
Edited by RCA3
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, RCA3 said:

Per your example..

 

This is the most clear & precise explanation I've ever seen, now everything makes sense to me. Thank you!!!

  • Like 1

Share this post


Link to post
Share on other sites
On 3/28/2022 at 7:54 AM, sekurlsa said:

This is the most clear & precise explanation I've ever seen, now everything makes sense to me. Thank you!!!

Thanks 😍

 

Now let's say we only want the action on our given unit:

createSample = {
	params ["_sample", "_unit"];
	[
		_sample, // Name of the object
		"Collect a sample",
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
		"_this distance _target < 5",
		"_caller distance _target < 5",
		{},
		{},
		{
			params ["_target", "_caller", "_actionId", "_arguments"];
			_arguments params ["_sample", "_unit"];
			//code
		},
		{},
		[_sample, _unit],
		5,
		0,
		false,
		false
	] remoteExec ["BIS_fnc_holdActionAdd", _unit]; //execute only where _unit is local
};

[objVar, playerVar] call createSample;
  • Thanks 1

Share this post


Link to post
Share on other sites
On 3/29/2022 at 4:47 PM, RCA3 said:

Thanks 😍

 

Now let's say we only want the action on our given unit:

 

Hey, you are awesome! Thanks for the great support you have provided me.
I've included you (if you don't mind) inside the credits of my mission which uses the function you helped me create.

 

Share this post


Link to post
Share on other sites
On 4/9/2022 at 2:17 PM, sekurlsa said:

Hey, you are awesome! Thanks for the great support you have provided me.
I've included you (if you don't mind) inside the credits of my mission which uses the function you helped me create. 

Hey, thanks! It was nothing, really.

Congrats on the release! It looks cool :uzi:

  • Thanks 1

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
Sign in to follow this  

×