Jump to content
Sign in to follow this  
BEAKSBY

How to get addAction assigend to an object to broadcast over the network

Recommended Posts

Hi All,

For some reason the addAction assigned to _gun1 (StaticWeapon) is only appearing on the server's side player.

In my MP game, any player can call in a StaticWeapon to be spawned

fn_StaticWeaponDrop

//....code
_gun1 = createVehicle [_vehType, _pos, [], 0, "CAN_COLLIDE"]; 
[[_gun1],"BEAKS_addAction",true,true] call BIS_fnc_MP;
//...more code

initServer.sqf

if (isServer) then {
  BEAKS_addAction = {
  _gun1 = _this select 0;
  _gun1 addAction ['<t size=''0.85''>REINFORCE EMPLACEMENT </t>' + '<t size=''0.85''  color=''#ff0000''>$ 25 </t>', "ReinforceStaticWeapon.sqf", [], 6, true, true, "", "(_target distance _this ) < 5 &&  !(alive gunner _target) && alive _target && _allowAddAction"]; 
  };
};

Share this post


Link to post
Share on other sites

Addaction is local. So you must send the add action to every client.

One solution is BIS_FNC_MP.

Fnc_addaction = {
_gun1 = (_this select 0);
_gun1 addaction ["bla bla", {call script}]
};

If isserver then {
[[_gun1],"fnc_addaction", true] call BIS_fnc_MP;
};

Share this post


Link to post
Share on other sites
Addaction is local. So you must send the add action to every client.

One solution is BIS_FNC_MP.

Fnc_addaction = {
_gun1 = (_this select 0);
_gun1 addaction ["bla bla", {call script}]
};

If isserver then {
[[_gun1],"fnc_addaction", true] call BIS_fnc_MP;
};

Thanks again BangaBob,

I thought I did send the addAction to all clients with

[[_gun1],"BEAKS_addAction",true,true] call BIS_fnc_MP;

Do I have to add this after the function in the initServer also?

This is the part I'm still strugling with.

Share this post


Link to post
Share on other sites

Unless you preprocess the function then the BIS_fnc_MP call must be after the function.

Is your BEAKS_Addaction stored in the init where all clients can access it or in the initserver?

Share this post


Link to post
Share on other sites
Unless you preprocess the function then the BIS_fnc_MP call must be after the function.

Is your BEAKS_Addaction stored in the init where all clients can access it or in the initserver?

It is in initServer. Should i place it in initPlayerLocal.sqf this way all players will access it, along with other functions I have their (like KK's epic paradrop function).

I managed to get it to work by adding

[[_gun1],"BEAKS_fnc_StaticWeapon_addAction",true, true] call BIS_fnc_MP;

and creating my own funcion...which I assume has the same effect compile preprocessFileLineNumbers.

Edited by BEAKSBY

Share this post


Link to post
Share on other sites

Hi,

Just fighting with a similar issue. So I have put addAction "talk" for a civilian, which triggers a script. But as said, the action is Local, so the script works only for the player who uses the action. I would like the script to be run for each playable unit.

I was thinking is the following kind of logic possible in Arma, or how this should be done?

1) Player who uses the action will run local script, which change some global variable from false to true.

2) when this global variable is true, another trigger will be triggered

3) this another trigger will run a script, which is now global?

So as a result, when one player goes to civilian and presses talk, all the players hear the conversation and the action is removed from each player.

Cheers,

Lerbert

Share this post


Link to post
Share on other sites

Just use BIS_fnc_MP as exampled above, much easier and one line of code.

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  

×