Jump to content
tom.machu

MP - switch ( profileName ) do {}

Recommended Posts

I´m wondering if this can work in MP scenario... 

init.sqf

_player = ""; 
 { 
  if (isPlayer _x AND alive _x) then {_player = _x}; 
 } foreach (playableUnits + switchAbleUnits);

switch (profileName) do {
case "playerProfileName": 	{
		_player setName "John Wick"
		};
};	


script.sqf
function called via: [params] remoteExecCall ["radio1_fnc_coordinates",0];


defined function:
radio addAction ["Coordinates", {
params ["_target", "_caller", "_id", "_args"];
//[_target, _id] remoteExec ["removeAction"];
_target = _this select 0;
_caller = _this select 1;
_pilot = pilot;

switch (name _caller) do { 

case "John Wick": { 
_spoj = floor (random 4);
	switch (_spoj) do {

	case 0: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["some text %1",mapGridPosition (getposatl _pilot)];
	};

	case 1: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["*no connection*"];
	};

	case 2: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["*no connection*"];
	};

	case 3: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["some text %1",mapGridPosition (getposatl _pilot)];
	};
	};
};

case "Max Max": { 
_spoj2 = floor (random 4);
	switch (_spoj2) do {

	case 0: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["some text %1",mapGridPosition (getposatl _pilot)];
	};

	case 1: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["*no connection*"];
	};

	case 2: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["*no connection*"];
	};

	case 3: {
		_caller sideChat "some text";
		sleep 5;
		[west, "HQ"] sideChat format ["some text %1",mapGridPosition (getposatl _pilot)];
	};
	};
};
};
}, nil, 1, true, true, "", "true", 5, false, "", ""];

In MP scenario it called the function, but it doesn´t work with "name _caller" parameter.

Share this post


Link to post
Share on other sites

"name player" in MP returns the actual username of the player, use setvariable or something to give people a custom name or rename their group or something

  • Like 1

Share this post


Link to post
Share on other sites

On top of what stanhope said (which is correct as far as I am aware) I believe that the forEach loop you have at the beginning of the script will leave in the _player variable only the name of the last playable or switchable unit. I am not sure this is what you want to achieve. If this is the case please just skip this post, otherwise you may want to consider placing the switch statement inside the forEach loop.

Share this post


Link to post
Share on other sites
3 hours ago, ZaellixA said:

On top of what stanhope said (which is correct as far as I am aware) I believe that the forEach loop you have at the beginning of the script will leave in the _player variable only the name of the last playable or switchable unit. I am not sure this is what you want to achieve. If this is the case please just skip this post, otherwise you may want to consider placing the switch statement inside the forEach loop.

 

My bad, it should not be there, I know. Anyway I tried to cfgIdentities in description.ext and call it via:

switch (profileName) do {
case "*profileName*": 	{
		[player, "*name*"] remoteExec ["setIdentity", 0, player];
		};
};	

With no luck. So I guess, player just has to change the desired profileName in the options for MP scenario. I wanted to add every player his authentic voice and name in the chat for communications in the mission. 

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

×