Jump to content
Sign in to follow this  
captainclaw

Mulitplayer credits

Recommended Posts

So I was wondering if anyone would be able to help with this

I am trying to write a script that will take the names of the players in a mission, of which numbers and names change.

What I have managed to do with some searching around is get my name to appear in the credits (easy part tbh)

Here is what I have so far

if (isNull player) exitWith {};


_credits = [
[ "", ["Reach","Elite","Forces"] ],
[ "Active Members", [_name] ]

];
_layers = ["credits1" call bis_fnc_rscLayer,"credits2" call bis_fnc_rscLayer];
_delay = 5.5;
_duration = _delay * 1.5;
{
   _title = [_x,0,""] call bis_fnc_paramin;
   _names = _x select 1;
   _text = format ["<t font='PuristaBold'>%1</t>",toUpper (_title)] + "<br />";
   {
        _text = _text + _x + "<br />";
   } foreach _names;
   _text = format ["<t size='0.8'>%1</t>",_text];
   _index = _foreachindex % 2;
   _layer = _layers select _index;
   [_layer,_text,_index,_duration] spawn {
       disableserialization;
       _layer = _this select 0;
       _text = _this select 1;
       _index = _this select 2;
       _duration = _this select 3;
       _fadeTime = 0.5;
       _time = time + _duration - _fadeTime;
       _layer cutrsc ["RscDynamicText","plain"];
       _display = uinamespace getvariable ["BIS_dynamicText",displaynull];
       _ctrlText = _display displayctrl 9999;
       _ctrlText ctrlsetstructuredtext parsetext _text;
       _offsetX = 0.1;
       _offsetY = 0.3;
       _posW = 0.4;
       _posH = ctrltextheight _ctrlText + _offsetY;
       _pos = [
        [safezoneX + _offsetX,safezoneY + _offsetY,_posW,_posH],
        [safezoneX + safezoneW - _posW - _offsetX,safezoneY + safezoneH - _posH,_posW,_posH]
       ] select _index;
       _ctrlText ctrlsetposition _pos;
       _ctrlText ctrlsetfade 1;
       _ctrlText ctrlcommit 0;
       _ctrlText ctrlsetfade 0;
       _ctrlText ctrlcommit _fadeTime;
       waituntil {time > _time};
       _ctrlText ctrlsetfade 1;
       _ctrlText ctrlcommit _fadeTime;
   };
   _time = time + _delay;
   waituntil {time > _time};
} foreach _credits;  

and what I need is for the Active members part

 [ "Active Members", [_name] ]

to be able to pull all the players online at the time and display them

I don't want to give up on the idea just yet so I thought I would ask the more talented scripters :D

Thanks Guys

Claw

Share this post


Link to post
Share on other sites

You could run a forEach allUnits with an if (isPlayer) check that then pushes back each of the names of the current player units, then you would have an array of names to mess with and use as you would want to.

_arrayOfNames = [];
{
  if (isPlayer _x) then
  {
     _arrayOfNames pushBack (name _x);
  };
} forEach allUnits;

Share this post


Link to post
Share on other sites
You could run a forEach allUnits with an if (isPlayer) check that then pushes back each of the names of the current player units, then you would have an array of names to mess with and use as you would want to.

_arrayOfNames = [];
{
  if (isPlayer _x) then
  {
     _arrayOfNames pushBack (name _x);
  };
//} forEach allUnits;
} forEach playableUnits;

would be a lot faster

Share this post


Link to post
Share on other sites

I already did the job of adding in that code that was posted above, all total it should look like this:

_arrayOfNames = []; 
_finalnames = "";
{ 
if(isplayer _x) then
{
	_arrayOfNames pushBack (name _x); 
};
} forEach allUnits;  

hint format ["%1",_arrayofNames];
{
_finalnames = _finalnames + format ["%1 <br/>",_x];
} foreach _arrayofnames;
//hint format ["%1 \n\n\n %2",_arrayofNames,_finalnames];

_credits = [
[ "", ["Reach","Elite","Forces"] ],
[ "Active Members", [_finalnames] ]

];
_layers = ["credits1" call bis_fnc_rscLayer,"credits2" call bis_fnc_rscLayer];
_delay = 5.5;
_duration = _delay * 1.5;
{
   _title = [_x,0,""] call bis_fnc_paramin;
   _names = _x select 1;
   _text = format ["<t font='PuristaBold'>%1</t>",toUpper (_title)] + "<br />";
   {
        _text = _text + _x + "<br />";
   } foreach _names;
   _text = format ["<t size='0.8'>%1</t>",_text];
   _index = _foreachindex % 2;
   _layer = _layers select _index;
   [_layer,_text,_index,_duration] spawn {
       disableserialization;
       _layer = _this select 0;
       _text = _this select 1;
       _index = _this select 2;
       _duration = _this select 3;
       _fadeTime = 0.5;
       _time = time + _duration - _fadeTime;
       _layer cutrsc ["RscDynamicText","plain"];
       _display = uinamespace getvariable ["BIS_dynamicText",displaynull];
       _ctrlText = _display displayctrl 9999;
       _ctrlText ctrlsetstructuredtext parsetext _text;
       _offsetX = 0.1;
       _offsetY = 0.3;
       _posW = 0.4;
       _posH = ctrltextheight _ctrlText + _offsetY;
       _pos = [
        [safezoneX + _offsetX,safezoneY + _offsetY,_posW,_posH],
        [safezoneX + safezoneW - _posW - _offsetX,safezoneY + safezoneH - _posH,_posW,_posH]
       ] select _index;
       _ctrlText ctrlsetposition _pos;
       _ctrlText ctrlsetfade 1;
       _ctrlText ctrlcommit 0;
       _ctrlText ctrlsetfade 0;
       _ctrlText ctrlcommit _fadeTime;
       waituntil {time > _time};
       _ctrlText ctrlsetfade 1;
       _ctrlText ctrlcommit _fadeTime;
   };
   _time = time + _delay;
   waituntil {time > _time};
} foreach _credits;

just stores all the names of players as a big string and uses the linebreak formatting so they aren't all jumbled together.

Share this post


Link to post
Share on other sites
And I don't know how they work, but they may be helpful, are the BIS functions regarding credits, just go to the following page and do a CTRL + F for "credits":

https://community.bistudio.com/wiki/Category:Arma_3:_Functions

Those commands aren't really helpful, I should know, I just finished adding all of the examples to this page. I went through them just a little while ago. The only one that could possible be helpful would be something like BIS_fnc_GUImessage and I did manage to do something pretty cool with it.

Example: (tested with test arrays, needs someone to run it in MP, but it should work out just fine)

_allPlayers = "composeText [";
{
if (isPlayer _x) then
{
	_allPlayers = format ["%1'%2'", _allPlayers, name _x];
	if (_forEachIndex < ((count playableUnits) - 1)) then
	{
		_allPlayers = format ["%1,linebreak,", _allPlayers];
	};
};
}forEach playableUnits;
_allPlayers = format ["%1];", _allPlayers];

_structuredText = call compile _allPlayers;

[_structuredText, "Mission Credits", "THANK YOU", "THANK YOU", findDisplay 46, false, true] spawn BIS_fnc_GUImessage;

Edited by DreadedEntity
forgot to change a few things back after testing

Share this post


Link to post
Share on other sites

thanks for the replies guys... going to wait until after the holidays before I give it a test But I'll let you know as soon as i get it working.

Happy Holidays

Claw

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  

×