Sign in to follow this  
Followers 0
[RG] Salutesh

Multiplayer script execution problems

9 posts in this topic

Posted (edited)

Some of you may have seen my project here:

I am a noob in MP scripting and i have some issues with my scripts on Dedicated Servers.

Its the simple problem, some of the action scripts that are behind my hold actions should not be executed on every single client because they are not involved in the mission and not in the mission area.

I tryed to put all players in a definied area into a string and use that sring as a target for remoteExec some scripts from the server to the targeted clients.

This is what i tryed so far and its not working like i want it:

fortressRaid_dokument_ActionScript = {
  	// Put players in mission area into string
	_playerUnits = ([12103.6,2491.62,0] nearEntities ["Exile_Unit_Player", 250]);
	// Remove action for all clients after use.
	[fortressRaid_dokument, 0] remoteExec ["bis_fnc_holdActionRemove", 0, true];
	// Play ambient music for players in mission area.
	playMusic ["AmbientTrack01_F_EXP", 0];
	// Notifiy toast for players in mission area.
	[] remoteExec ["fortressRaid_ToastDokuments", _playerUnits, true];
	// Create the first mission task for players in mission area.
	[] remoteExec ["fortressRaidTask_One", _playerUnits, true];
	// Wait 3 seconds.
	sleep 3;
	// Notifiy toast for players in mission area.
	[] remoteExec ["fortressRaid_ToastNewTask", _playerUnits, true];
};

Is there a better way to execute code on players in a special area or maybe on a group?!

I am grateful for any help :).

Edited by [RG] Salutesh

Share this post


Link to post
Share on other sites

Posted (edited)

On 2016-08-21 at 2:02 PM, [RG] Salutesh said:

This is what i tryed so far and its not working like i want it:

How do you want it to work?
What is not working? 

Not sure but think playMusic is a local function, try use

["AmbientTrack01_F_EXP", 0] remoteExec ["BIS_fnc_playMusic", _playerUnits];

 

This also seems to be inaccurate since you can't know the action ID (it can be different on all clients)

[fortressRaid_dokument, 0] remoteExec ["bis_fnc_holdActionRemove", 0, true];

you can read about the function BIS_fnc_holdActionRemove here

Edited by Janski
1 person likes this

Share this post


Link to post
Share on other sites
Advertisement
On 24.8.2016 at 10:40 PM, Janski said:

How do you want it to work?
What is not working? 

Not sure but think playMusic is a local function, try use


["AmbientTrack01_F_EXP", 0] remoteExec ["BIS_fnc_playMusic", _playerUnits];

 

This also seems to be inaccurate since you can't know the action ID (it can be different on all clients)


[fortressRaid_dokument, 0] remoteExec ["bis_fnc_holdActionRemove", 0, true];

you can read about the function BIS_fnc_holdActionRemove here

Thank you Janski! 

I will try to call the music in that way.

The Hold action removement is working just fine because 0 is just the first id of each different action and they get removed for every client if someone use it. 

The main problem i have is that the tasks and the toast notifications are executed on every single client that is connectet if someone uses the actions.

But like i said in my first post i want to restrict the scripts behind the actions to the mission area. So only players in this area will see the notifications and will get the task. I can give you the hole addon if you want to take a look. 

Share this post


Link to post
Share on other sites
50 minutes ago, [RG] Salutesh said:

The main problem i have is that the tasks and the toast notifications are executed on every single client that is connectet if someone uses the actions.

Can you post the code, which you have connected to the action. 

1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

10 minutes ago, Janski said:

Can you post the code, which you have connected to the action. 

The code for the action creation:

// Create interaction object for hold actions.
// Dokuments interaction Object.
fortressRaid_dokument = "Land_Document_01_F" createVehicle [12108.5, 2314.93, 3.27098];
fortressRaid_dokument allowDamage false;
fortressRaid_dokument setPosWorld [12108.5, 2314.93, 3.27098];
fortressRaid_dokument setVectorDirAndUp [[-0.783477, -0.621421, 0], [0, 0, 1]];
fortressRaid_dokument enableSimulationGlobal false;
fortressRaid_dokument setVariable ["ExileIsLocked", -1, true];
// Add the hold action
[fortressRaid_dokument, "Read Secret Dokuments", "default", "_this distance _target < 5", {remoteExec ["fortressRaid_dokument_ActionScript", 0, true];},	[], 3, true] remoteExec ["RG_fnc_raidAddHoldAction", 0, true];
publicVariable "fortressRaid_dokument";

My function (RG_fnc_raidAddHoldAction):

params [["_object", player], ["_label", "Search"], ["_type", "search"], ["_active", "true"], ["_completeCode", {hint 'Nothing found'}], ["_args", []], ["_duration", 2], ["_remove", "true"]];

// Change icon based on _type input.
_idleIcon = switch (_type) do {
	case "data": {"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa"};
	case "launcher": {"icons\holdAction_launcher.paa"};
	case "pc": {"icons\holdAction_laptop.paa"};
	case "crate": {"icons\holdAction_search.paa"};
	case "charge": {"icons\holdAction_terminal.paa"};
	case "connect": {"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa"};
	default {"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa"};		
};


[
/* 0 object */							_object,
/* 1 action title */					_label,
/* 2 idle icon */						_idleIcon,
/* 3 progress icon */					_idleIcon,
/* 4 condition to show */				_active,
/* 5 condition for action */			"true",
/* 6 code executed on start */			{},
/* 7 code executed per tick */			{},
/* 8 code executed on completion */		_completeCode,
/* 9 code executed on interruption */	{},
/* 10 arguments */						_args,
/* 11 action duration */				_duration,
/* 12 priority */						0,
/* 13 remove on completion */			_remove,
/* 14 show unconscious */				false
] remoteExec ["BIS_fnc_holdActionAdd",[0,-2] select isDedicated,true];

 

Edited by [RG] Salutesh

Share this post


Link to post
Share on other sites

@[RG] Salutesh It's hard for me to guess where and when these are executed but it seems like you need to change the remoteExec target to 2 if you only wanna execute the code on the server, in many places you use 0 which is the reason why it get executed on all clients and the server. 

1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

post removed, I misread the code, sry 

Edited by Janski

Share this post


Link to post
Share on other sites
29 minutes ago, Janski said:

@[RG] Salutesh It's hard for me to guess where and when these are executed but it seems like you need to change the remoteExec target to 2 if you only wanna execute the code on the server, in many places you use 0 which is the reason why it get executed on all clients and the server. 

I will try something related to this tipp, thank you. I send you a PM.

Share this post


Link to post
Share on other sites

So i finaly fixed my issues and the mission is working very well in Multiplayer so far. Thanks Janski for your time!

Thread can be closed!

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.