Jump to content
Sign in to follow this  
Icaruk

AddAction not showing on MP.

Recommended Posts

this is my action:

box1 addAction ["Blabla",'null = [] execVM "script.sqf";', "", 9,false,true,"",""];

This line is inside a script that is only read by the server, because if it were read by each player, the box1 would have 5427395 actions.

The problem now is that this action is not visible by clients.

Any solution to this? I would love examples because I'm sitill pretty new with the addAction command.

Share this post


Link to post
Share on other sites
because if it were read by each player, the box1 would have 5427395 actions

That is not right. addAction only has local effect, so yes ... run it on every player.

Share this post


Link to post
Share on other sites
You will need to use bis_fnc_mp or similar to tell the players machines to create it locally.

https://community.bistudio.com/wiki/BIS_fnc_MP

My problem is that I can't merge addAction with BIS_fnc_MP, I get always some error. That's why I asked for some examples :/

Share this post


Link to post
Share on other sites

Kylania's post on my question I asked a bit ago

example

Create our own Function, only way BIS_FNC_MP works

LALA_fnc_addAction = {
   private["_object","_script"];
   _object = _this select 0;
   _script = _this select 1;

   _object addAction _script;

};

then use this function on an object

[[myM2, ["Delete Vehicle", {deleteVehicle (_this select 0)}, [], 0, false, true, "", "driver _target == _this"]], "LALA_fnc_addAction", true, true] spawn BIS_fnc_MP;
//myM2 == Object
//["Delete Vehicle", {deleteVehicle (_this select 0)}, [], 0, false, true, "", "driver _target == _this"] == Script part

Share this post


Link to post
Share on other sites
Kylania's post on my question I asked a bit ago

example

Create our own Function, only way BIS_FNC_MP works

LALA_fnc_addAction = {
   private["_object","_script"];
   _object = _this select 0;
   _script = _this select 1;

   _object addAction _script;

};

then use this function on an object

[[myM2, ["Delete Vehicle", {deleteVehicle (_this select 0)}, [], 0, false, true, "", "driver _target == _this"]], "LALA_fnc_addAction", true, true] spawn BIS_fnc_MP;
//myM2 == Object
//["Delete Vehicle", {deleteVehicle (_this select 0)}, [], 0, false, true, "", "driver _target == _this"] == Script part

Thanks.

-----------------------------------------------------------------------

Edit: I'm still confused. I want to use addAction on a recently spawned unit. And this addAction must be visible for everyone.

Example:

FNC_Actions {
         guy1 addAction ["<t color=""#0101DF"" size='1' shadow='1'>" +"Blablabla",'null = [player] execVM "script.sqf";', "", 7,false,true,"",""];
};

Cant I call this FNC from the init so all players can read it?

Edited by Icaruk

Share this post


Link to post
Share on other sites
Example:

FNC_Actions {
         guy1 addAction ["<t color=""#0101DF"" size='1' shadow='1'>" +"Blablabla",'null = [player] execVM "script.sqf";', "", 7,false,true,"",""];
};

Cant I call this FNC from the init so all players can read it?

so we would first create the function somewhere so if it's in a script place it there, it can be used later when ever we need it also in anyother script.

ICARUK_fnc_addAction = { 
   private["_object","_script"]; 
   _object = _this select 0; 
   _script = _this select 1; 

   _object addAction _script; 

};  

now that we have that defined we can do this

[[guy1, ["<t color=""#0101DF"" size='1' shadow='1'>" +"Blablabla",'null = [player] execVM "script.sqf";', "", 7,false,true,"",""]], "ICARUK_fnc_addAction", true, true] spawn BIS_fnc_MP;
//very weird also on the null = [player] execVM "script.spf"
//this may be causing an error if possible can you tell us is this happening to GUY1 or a player doing the action,
//if its the player then we would use (_this select 1) instead of player
//if its GUY1 we can just use "script.sqf" no need for the other bits.

the function then uses the two params which are:

_object which is the first part of the param i.e guy1

&

_script which is the second part if the param i.e ["<t color=""#0101DF"" size='1' shadow='1'>" +"Blablabla",'null = [player] execVM "script.sqf";', "", 7,false,true,"",""].

then the function plugs this in when called:

_object "
guy1
" addAction _script "
["<t color=""#0101DF"" size='1' shadow='1'>" +"Blablabla",'null = [player] execVM "script.sqf";', "", 7,false,true,"",""]
"

another example maybe.

We want to execute a script on each player from a script

well there is a funciton predefined by Bohemia called BIS_fnc_execVM

so we don't need to define this we can just create the PARAMS!

[[guy1],"addhealth.sqf"], "BIS_fnc_execVM", true, true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites

Thank you Lala14, you saved me a lot of time!

Share this post


Link to post
Share on other sites

Here's an example of how I usually define actions. Writing functions for them, so they can easily be re-added is always useful.

eed_action_select = {
if ( !isNil "eed_actID_select" ) then {
	player removeAction eed_actID_select;
};

eed_actID_select = player addAction [
	"Title",
	'
		if (cursorTarget in eed_selectedForSaving) then {
			eed_selectedForSaving = eed_selectedForSaving - [cursorTarget];
		} else {
			eed_selectedForSaving = eed_selectedForSaving + [cursorTarget];
		};

		publicVariable "eed_selectedForSaving";
	',
	"",
	-5,
	false,
	false,
	"",
	'
		_show = false;
		if ( player call eed_showMenu ) then {
			if (!isNull cursorTarget) then {
				if (!cursorTarget isKindOf "Man") then {
					_show = true;
					if (cursorTarget in eed_selectedForSaving) then {
						player setUserActionText[eed_actID_select, format["Deselect %1", typeName cursorTarget]];
					} else {
						player setUserActionText[eed_actID_select, format["Select %1", typeName cursorTarget]];
					};
				};
			};

			{ _x call eed_drawBBox;	} forEach eed_selectedForSaving;
		};
		_show
	'
];
};
[] call eed_action_select;

player addEventHandler ["Respawn", {
[] spawn {
	sleep 1;
	[] spawn eed_action_select;
};
}];

ps.: You don't have to put the code for your action into a seperate scriptfile. You can either put it directly into the action or define it as functions (the latter is very useful as it can then be called by BIS_fnc_MP)

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  

×