Jump to content
cklymowsky

Help with remoteExec and class CfgFunctions

Recommended Posts

HI All,

 

I've read remoteExec and CfgRemoteExec but yet I still cannot get my function, fn_sectorDistances.sqf,  to display for the host or all players that join.

 

fn_sectorDistances is supposed to show the distance from the player to the sector...

 

description.ext

class CfgRemoteExec
{
	// List of script functions allowed to be sent from client via remoteExec
	class Functions
	{
		file = "functions\SetUp";	
		class sectorDistances {};	 // allowedTargets = 0 can target only clients
	};
};

 

and in initPlayerLocal.sqf

//show distances to all sectors for all players
remoteExec ["fn_sectorDistances", 0, true]; 

I've stored fn_sectorDistances.sqf in a sub-folder folder in: functions>>SetUp

 

Am I executing it from the right location? Have I set up class CfgRemoteExec correctly?

Share this post


Link to post
Share on other sites

if your trying to *execVM* your sqf file with remoteExec you need to do it more so how its done normally but backwards if that makes sense. when executing a file you need the path of the file and the extension(.sqf) so fn_sectorDistances should be functions\SetUp\fn_sectorDistances.sqf.

null = [["PARAMETERS HERE"], "functions\SetUp\fn_sectorDistances.sqf"] remoteExec ["execVM", 0, true];

 

Share this post


Link to post
Share on other sites

I tried placing it in initServer.sqf thinking it could broadcast to all players

 

initServer.sqf

//show distances to all sectors for all players
remoteExec ["BEAKS_fnc_sectorDistances", 0];

...but it only works on the host. How can I get fn_sectorDistances to run on all players.

 

fn_sectorDistances.sqf

Quote

waitUntil {!isNull player};

fn_Draw3Dsectors = {
	{
		private ["_text", "_distance", "_pos", "_picture"];
		_distance = round (_x distance player);
		_text =  format ["%1m from %2", str (_distance), name player];
		_colour = [1,1,1,1];
		_picture = switch (_x getVariable "Name") do {
			case "1 CONTROL POINT":{"\A3\ui_f\data\map\markers\military\flag_CA.paa"};
		};
			_colour = [];
			if (_distance >=2000) then {_colour = [1,1,1,1]}; 
			if ((_distance >= 1000) and (_distance < 2000)) then {_colour = [1,1,1,.75]}; 
			if (_distance < 1000) then {_picture = ""; _colour = [1,1,1,0.66]}; 
			
    		drawIcon3D [
				_picture,
				_colour,
				[(visiblePosition _x) select 0,(visiblePosition _x) select 1,((visiblePosition _x) select 2) + 20],
				.5,
				.5,
				0,
				_text,
				2,
				0.025,
				"PuristaMedium",
				"center",
				TRUE
    		];
	} forEach ([TRUE] call bis_fnc_moduleSector);	 
};

private ["_addNew"];

_addNew = ["BIS_id", "onEachFrame", "fn_Draw3Dsectors"] call BIS_fnc_addStackedEventHandler	

 

 

Share this post


Link to post
Share on other sites
33 minutes ago, cklymowsky said:

I tried placing it in initServer.sqf thinking it could broadcast to all players

 

initServer.sqf


//show distances to all sectors for all players
remoteExec ["BEAKS_fnc_sectorDistances", 0];

...but it only works on the host. How can I get fn_sectorDistances to run on all players.

 

fn_sectorDistances.sqf

 

it should still be the same. just run remoteExec with the path and the name of the .sqf file like in the post above, it executes the .sqf file on all clients

null = [[""], "path\to\your\file.sqf"] remoteExec ["execVM", 0, true];

 

Share this post


Link to post
Share on other sites

Thanks gokitty1199, 

 

22 hours ago, gokitty1199 said:

it should still be the same. just run remoteExec with the path and the name of the .sqf file like in the post above, it executes the .sqf file on all clients


null = [[""], "path\to\your\file.sqf"] remoteExec ["execVM", 0, true];

 

BUT, the problem is TRUE call bis_fnc_moduleSector in the fn_sectorDistances.sqf.

 

When I test with the following:

{
	_bis_fnc_moduleSector = TRUE call bis_fnc_moduleSector;
	hint format ["TRUE call bis_fnc_moduleSector: \n %1 ", _bis_fnc_moduleSector];
} remoteExec ["bis_fnc_call", 0, true];

On the host I get an array sectors that works with fn_sectorDistances.sqf, but on the client I dont't get the same array, and as a result fn_sectorDistances.sqf doesn't work.

 

on host I get:

TRUE call bis_fnc_moduleSector:

[BIS_fnc_moduleSector_sector2_751, BIS_fnc_moduleSector_sector2_756, ...]

 

on the client:

TRUE call bis_fnc_moduleSector:

[L Bravo 1-5:1 REMOTE, L Bravo 1-6:1 REMOTE, ...]

 

I can't even import a global variable allSectorsArray = TRUE call BIS_fnc_moduleSector; through:

 

initServer.sqf

[[allSectorsArray],"functions\SetUp\fn_sectorDistances.sqf"] remoteExec ["execVM", 0, true];

It gives the same results as in hint message above.

 

HOW do I broadcast a variable to other clients the same way it would show up on the server and host?

Share this post


Link to post
Share on other sites
1 hour ago, cklymowsky said:

HOW do I broadcast a variable to other clients the same way it would show up on the server and host?

thats strange why its different on the clients(never used moduleSector before), one way to broadcast a variable to all machines is by using publicVariable, so on the server/host do

publicVariable "variableName";

and it will broadcast variableName to everyone/everything. keep in mind you can only broadcast global variables so trying to do

publicVariable "_variableName";

wont work

Share this post


Link to post
Share on other sites
13 hours ago, gokitty1199 said:

never used moduleSector before), one way to broadcast a variable to all machines is by using publicVariable

Thanks, 

Not sure if I should start a new thread on this. 

I am creating sectors using _logic= (createGroup sideLogic) createUnit ["ModuleSector_F", _pos, [], 0,"NONE"];  which should create a sector that is global. Then initiating it with _logic call BIS_fnc_moduleSector.

Share this post


Link to post
Share on other sites
1 hour ago, beako said:

Thanks, 

Not sure if I should start a new thread on this. 

I am creating sectors using _logic= (createGroup sideLogic) createUnit ["ModuleSector_F", _pos, [], 0,"NONE"];  which should create a sector that is global. Then initiating it with _logic call BIS_fnc_moduleSector.

whats your question? are you trying to broadcast it?

Share this post


Link to post
Share on other sites
7 hours ago, gokitty1199 said:

Whats your question? are you trying to broadcast it?

allSectorsArray = ...sectors created using BIS_fnc_sectorModule

I have tried using publicVariable "allSectorsArray"; which I think is the same as missionNamespace setVariable ["sectorsArray",allSectorsArray, TRUE];

and have also tried defining allSectorsArray = ...sectors created using BIS_fnc_sectorModule inside of init.sqf as per http://killzonekid.com/arma-scripting-tutorials-variables-part-3/

 

yet they all yield the same results:

on host I get:

TRUE call bis_fnc_moduleSector:

[BIS_fnc_moduleSector_sector2_751, BIS_fnc_moduleSector_sector2_756, ...]

 

on the client:

TRUE call bis_fnc_moduleSector:

[L Bravo 1-5:1 REMOTE, L Bravo 1-6:1 REMOTE, ...]

 

My question is why aren't any of these methods transferring the global variable allSectorsArray to the clients the same way as it appears on the host?

 

Is this because you cannot transfer sectors as variables because they are not supported by these commands?

 

SOLUTION:

 

I used publicVariable "controlPointsArray"; even if this generates [L Bravo 1-5:1 REMOTE, L Bravo 1-6:1 REMOTE, ...]  as sectors and had to change my sectorDistance.sqf

 

from 

		_picture = switch (_x getVariable "Name") do {
			case "1 CONTROL POINT":{"\A3\ui_f\data\map\markers\military\flag_CA.paa"};
		};

to 

if (_x in controlPointsArray) then {_picture = "\A3\ui_f\data\map\markers\military\flag_CA.paa"};

As it could not get the value from, since the public value in was not set to true.

 

 

Edited by cklymowsky
Found problem

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

×