Jump to content
Thorimus

addAction in multiplayer

Recommended Posts

I'm trying to execute a piece of addAction code on a server where I do not have the ability to add .sqf files. Every guide and solution I have found uses them, so I'm hoping there's a differenct solution.

This is the code that I wish to make functional in multiplayer:

subcontroller addAction ["AUTHORISE CRUISE MISSILE LAUNCH", {
systemChat "OPCOM, GREAT WHITE. REQUEST RECIEVED. SURFACING, STAND BY.";
subengine swimInDepth 2;
sleep 8;

_marker = "";
{if ((markerText _x) == "FireMission") exitWith {_marker = _x;};} forEach allMapMarkers;
if (_marker != "") then {
	targethelipad = createVehicle ["Land_HelipadEmpty_F", getMarkerPos _marker, [], 0, "NONE"];
	systemChat "OPCOM, GREAT WHITE. TARGET COORDINATES RECIEVED. GREYHOUND AWAY.";
	};
west reportRemoteTarget [targethelipad, 3600];
targethelipad confirmSensorTarget [west, true];
submissiles fireAtTarget [targethelipad, "weapon_vls_01"];
sleep 6;
subengine swimInDepth -10;
systemChat "OPCOM, GREAT WHITE. FIRE MISSION COMPLETE, DIVING.";
}];

subcontroller addAction ["ORDER MANUAL DIVE", {
subengine swimInDepth -10;
systemChat "OPCOM, GREYHOUND. DIVING.";
subisdive = true;
}];
subcontroller addAction ["ORDER MANUAL SURFACE", {
subengine swimInDepth 2;
systemChat "OPCOM, GREYHOUND. SURFACING.";
subisdive = false;
}];

subcontroller is a laptop, if it matters.

Is there a way to make this work for all players in multiplayer?

Share this post


Link to post
Share on other sites
[
  subcontroller, 
  ["AUTHORISE CRUISE MISSILE LAUNCH", 
   { 
     systemChat "OPCOM, GREAT WHITE. REQUEST RECIEVED. SURFACING, STAND BY."; 
     subengine swimInDepth 2; 
     sleep 8; 
     _marker = ""; 
     {if ((markerText _x) == "FireMission") exitWith {_marker = _x;};} forEach allMapMarkers; 
     if (_marker != "") then { 
       targethelipad = createVehicle ["Land_HelipadEmpty_F", getMarkerPos _marker, [], 0, "NONE"]; 
       systemChat "OPCOM, GREAT WHITE. TARGET COORDINATES RECIEVED. GREYHOUND AWAY."; 
     }; 
     west reportRemoteTarget [targethelipad, 3600]; 
     targethelipad confirmSensorTarget [west, true]; 
     submissiles fireAtTarget [targethelipad, "weapon_vls_01"]; 
     sleep 6; 
     subengine swimInDepth -10; 
     systemChat "OPCOM, GREAT WHITE. FIRE MISSION COMPLETE, DIVING."; 
   }]
 ] remoteExec ["addAction", 0, true];
  
[
  subcontroller, 
  ["ORDER MANUAL DIVE", { subengine swimInDepth -10; systemChat "OPCOM, GREYHOUND. DIVING."; subisdive = true;}]
]remoteExec ["addAction", 0, true];
 
[ subcontroller, ["ORDER MANUAL SURFACE", { subengine swimInDepth 2; systemChat "OPCOM, GREYHOUND. SURFACING."; subisdive = false; }] 
] remoteExec ["addAction", 0, true];

Untested but should work

  • Thanks 1

Share this post


Link to post
Share on other sites

Sure you can. First of all your code must be run by each client. So, you can place them in init.sqf or init field of the object (subcontroller).

I guess subcontroller is a variable name in editor for laptop. So, all players have it locally.

If not, let say you have spawned it on server, subcontroller variable is not public. Problem is here if the players can't see the action.

Tell us more about the way you place the variables: subengine, subcontroller,submissiles,targetHelipad... All must be known locally on each PC. Marker "FireMission" must be common also (normal, not created locally).

 

Then, the action code. This code is always local and run only on the calling player's PC. But the effect can be global, depending on each command.

Here swimindepth should work as is, but systemChat need to be broadcast (if you want).

Replace all messages like:

systemChat "OPCOM, GREAT WHITE. FIRE MISSION COMPLETE, DIVING.";

by

"OPCOM, GREAT WHITE. FIRE MISSION COMPLETE, DIVING." remoteExec ["systemChat"];

 

  • Thanks 1

Share this post


Link to post
Share on other sites
5 hours ago, Thorimus said:

I'm trying to execute a piece of addAction code on a server where I do not have the ability to add .sqf files.

You might want to explain this situation further.

Share this post


Link to post
Share on other sites
59 minutes ago, Harzach said:

You might want to explain this situation further.

He's trying to fire one of the VLS cruise missiles at a map marker that the player made when an addaction is used.  This is his 3rd thread on the subject.

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites
4 hours ago, stanhope said:

He's trying to fire one of the VLS cruise missiles at a map marker that the player made when an addaction is used.  This is his 3rd thread on the subject.

That's not the situation I referenced. It sounds as though he's trying to execute code as a client on a server he does not manage.

  • Like 1

Share this post


Link to post
Share on other sites

I agree with @Harzach - It sounds and smells dodgy. :rofl:

@stanhope - Love your sig!

Quote

There is no place like 127.0.0.1

Haha

  • Haha 2

Share this post


Link to post
Share on other sites

@Harzach @HazJ haha, I like to zeus in a community with several hundred members. They only give the community managers the ability to apply SQFs, but anyone can zeus.

 

I’ve done fine relying on google to teach me stuff before, but with this there was either no documentation or a lot of threads where the examples were way more complex than what I can understand.

  • Like 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

×