Jump to content
hanzventura

Multiplayer addAction for every client -- yes, another post on this

Recommended Posts

Hi all, apologies for making the Nth post on this. I spent about five hours yesterday racking my brain on this with remoteExec.

 

Goal: Spawn an item through createVehicle and allow every JIP to interact with the item within X radius.

The issue: Only the first player on the dedicated server sees the actions

 

The code

Github

 

Spawning the item:

    _fridge = createVehicle [
      "Fridge_01_closed_F",
      _fridgeLocation, [],
      0, "CAN_COLLIDE"
    ];

    [_fridge, "Store food", "call StoreFood", 1] call AddLiteAction;

Creating the action:

AddLiteAction = {
  params [
    "_target",
    "_name",
    "_script",
    "_radius",
    ["_params", []]
  ];

  _extraArguments    = [];
  _defaultPriority   = 1.5;
  _defaultShowWindow = true;
  _defaultHideOnUse  = true;
  _defaultShortcut   = "";
  _defaultCondition  = "true";

  _target addAction [
    _name,
    _script,
    _params,
    _defaultPriority,
    _defaultShowWindow,
    _defaultHideOnUse,
    _defaultShortcut,
    _defaultCondition,
    _radius
  ];
};

(Nearly) Everything:

// init.sqf

if (isServer) then {
  [] call CreatePlayerBases;
};

// Base.sqf
CreatePlayerBases = {
    // ... deleted extra code for brevity
    _fridge = createVehicle [
      "Fridge_01_closed_F",
      _fridgeLocation, [],
      0, "CAN_COLLIDE"
    ];

    [_fridge, "Store food", "call StoreFood", 1] call AddLiteAction;
};

// Util.sqf
AddLiteAction = {
  params [
    "_target",
    "_name",
    "_script",
    "_radius",
    ["_params", []]
  ];

  _extraArguments    = [];
  _defaultPriority   = 1.5;
  _defaultShowWindow = true;
  _defaultHideOnUse  = true;
  _defaultShortcut   = "";
  _defaultCondition  = "true";

  _target addAction [
    _name,
    _script,
    _params,
    _defaultPriority,
    _defaultShowWindow,
    _defaultHideOnUse,
    _defaultShortcut,
    _defaultCondition,
    _radius
  ];
};

Cheers!

Share this post


Link to post
Share on other sites

No tested, but something like this:

[[_fridge, "Store food","call StoreFood", 1], AddLiteAction] remoteExec [call",0,true];

  • Like 2

Share this post


Link to post
Share on other sites
[_fridge, "Store food", "call StoreFood", 1] remoteExec [ "AddLiteAction", [ 0, -2 ] select isDedicated, true ];

 

  • Like 2

Share this post


Link to post
Share on other sites

@Larrow and @pierremgi, thank you both for the responses. I'll try this out after work today.
 

In the haze of yesterday's 5 hours of debugging, I had previously tried `remoteExec` on `addAction`, but not `AddLiteAction`. The result was it either didn't work, or it worked but `_radius` had no effect -- the action was available from any distance.

 

Is it visible to you why using `remoteExecCall` on `AddLiteAction` would yield a different result than directly on `addAction` inside of `AddLiteAction`?

 

Thanks again. I'll report back later this evening when I get a chance to try it out.

 

P.S. Am I able to format my posts using Markdown?

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

×