Jump to content
Sign in to follow this  
Orion987

Multiplayer Framework

Recommended Posts

Hello. I was wondering if there was anyway I could get the multiplayer framework working on Arma 3 so I could make RE calls. Is there anyway I could do this? I have already tried manually creating the module, but the "\ca\modules\MP\data\scripts\MPframework.sqf" I used in Arma 2 no longer seems to exist in Arma 3 (after looking around in the AddOns folder, I noticed that 'modules' is now 'modules_f', however, changing to that doesn't work either.

Thanks!

Share this post


Link to post
Share on other sites

Easy enough, just use a PVEH.

if (isNil "RemExCode") then
{
RemExCode = [{}, []];
publicVariable "RemExCode";
};

"RemExCode" addPublicVariableEventHandler
{
private["_this","_code","_params"];
_this = _this select 1;
_code = _this select 0;
_params = _this select 1;

_params call _code;
};

Share this post


Link to post
Share on other sites

I seem to be having trouble with this code. If I execute this on the server, shouldn't both the client and the server see the hint "WORKING"? I am not getting the hint on the client or the server when I run this. Thanks

   if (isNil "RemExCode") then
{
   RemExCode = [{}, []];
   publicVariable "RemExCode";
};

"RemExCode" addPublicVariableEventHandler
{
   private["_this","_code","_params"];
   _this = _this select 1;
   _code = _this select 0;
   _params = _this select 1;

   _params call _code;
};  

RemExCode= [compile "hint 'WORKING'" ,[]];	
publicVariable "RemExCode";

Edited by Orion987

Share this post


Link to post
Share on other sites

There is a new Framework, an improved version of the one included in Take On Helicopters.

This already takes advantage of the new publicVariableClient and publicVariableServer commands.

In editor open the Functions Viewer, select from the left list box the entry called MP and check BIS_fnc_MP.

/*
Author: Karel Moricky

Description:
Send function for remote execution (and executes locally if conditions are met)

Parameter(s):
	0: ANY - function params
	1: STRING - function name
	2 (Optional):
		OBJECT - function will be executed only where unit is local [default: everyone]
		BOOL - true to execute on every client, false to execute it on server only
		NUMBER - function will be executed only on client with the given ID
		ARRAY - array of objects
	3 (Optional): BOOL - true for persistent call (will be called now and for every JIP client) [default: false]

Returns:
ARRAY - sent packet
*/

Share this post


Link to post
Share on other sites

I saw that , so I tried running

[[],"myscript.sqf",true] spawn BIS_fnc_MP;

on the server. However, it doesn't execute the given code (Just a hint statement) on either the server or the client. Any ideas?

Edit: Is it because "myscript.sqf" isn't technically a function? If so, do I have to compile it first or something?

Share this post


Link to post
Share on other sites
I saw that , so I tried running
[[],"myscript.sqf",true] spawn BIS_fnc_MP;

on the server. However, it doesn't execute the given code (Just a hint statement) on either the server or the client. Any ideas?

You are passing a script path, but you need a function name.

You need to define the function before using the command. Keep in mind that the function needs to exist where this will run.

myFunction = {
     hint "Hello World!";
};

[[],"myFunction",true] spawn BIS_fnc_MP;

Edited by neokika

Share this post


Link to post
Share on other sites

Could I define a function to call a script? For example

 myFunction = { [] execVM "myscript.sqf"}

Would that call the function from the client computer then if I ran my previous code (with "myFunction" instead of "myscript.sqf")?

Edit: I tried to do this with the following code, which is not working either...

 	_func = {[] spawn "myscript.sqf"};
[[],"_func",true] spawn BIS_fnc_MP;  

Edited by Orion987

Share this post


Link to post
Share on other sites
Could I define a function to call a script? For example
 myFunction = { [] execVM "myscript.sqf"}

Would that call the function from the client computer then if I ran my previous code (with "myFunction" instead of "myscript.sqf")?

Yes, but unnecessary.

Share this post


Link to post
Share on other sites

Are these functions to do things like prevent scripts executing once for each client and causing lag and such? Is this like the old game logic global form OFP?

Share this post


Link to post
Share on other sites

Edit: Just editing over this post to update it. Anyway... I am running this in my init.sqf

  myFunction = { 
     hint "Hello World!"; 
  }; 

if (isServer) then { 

  [[],"myFunction",true] spawn BIS_fnc_MP;   

};  

I am getting the hint on the server, but not the client. I don't understand why, since that true parameter should execute the code on clients as well. Putting a publicVariable "myFunction" before the BIS_fnc_MP call does not help either.

---------- Post added at 10:24 PM ---------- Previous post was at 09:24 PM ----------

Figured it out. Since the spawn function was being called on the clients computer, it was being run in parallel to the server, which had to do more work, so the client was executing the code first. Using a 'waitUntil' command worked fine (but I did need to declare publicVariable for the function). Thanks so much neokika!

Edited by Orion987

Share this post


Link to post
Share on other sites
Edit: Just editing over this post to update it. Anyway... I am running this in my init.sqf

  myFunction = { 
     hint "Hello World!"; 
  }; 

if (isServer) then { 

  [[],"myFunction",true] spawn BIS_fnc_MP;   

};  

I am getting the hint on the server, but not the client. I don't understand why, since that true parameter should execute the code on clients as well. Putting a publicVariable "myFunction" before the BIS_fnc_MP call does not help either.

---------- Post added at 10:24 PM ---------- Previous post was at 09:24 PM ----------

Figured it out. Since the spawn function was being called on the clients computer, it was being run in parallel to the server, which had to do more work, so the client was executing the code first. Using a 'waitUntil' command worked fine (but I did need to declare publicVariable for the function). Thanks so much neokika!

Orion or anybody else reading this, have you figured out how to use BIS_fnc_MP with tasks yet so they work properly for multiplayer (i.e they show their proper status for JIP players)?

Share this post


Link to post
Share on other sites

use this to hint to all

in your init.sqf...

//GLOBAL HINT
"FOCK_GHint" addPublicVariableEventHandler
 {
   private ["_GHint"];
  _GHint = _this select 1;
   hint format["%1", _GHint];
 };

in whatever script you have - use this...

	FOCK_GHint = "New Cache has been created - Start Hunting"; publicVariable "FOCK_GHint"; // This data will only be received on other machines. Not on the machine where it is executed.
	hint FOCK_GHint; //this hints locally as the code above never runs locally

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

exactly the same for executing a file across the board - same process

init.sqf

//execute script for all  
"FOCK_CallScriptEveryone" addPublicVariableEventHandler
 {
   private ["_forAll"];

     _forAll = _this select 1;
execVM _forAll;
 };

in whatever script.sqf

FOCK_CallScriptEveryone = "EndMission.sqf"; publicVariable "FOCK_CallScriptEveryone";
	execVM FOCK_CallScriptEveryone;

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  

×