Jump to content
Sign in to follow this  
HeroesandvillainsOS

BIS_fnc_infotext plays fine in SP but too fast in MP

Recommended Posts

So I've added:

Sleep 5;
["Text","Text","Text"] spawn BIS_fnc_infoText;
To my init.sqf in my mission and it plays beautifully in SP. But on a dedicated server, although it works, the letters type and remove themselves so fast you can't even read them.

Not really sure why. Is there any way to slow it down for MP?

Share this post


Link to post
Share on other sites

I have this in my mission, since I thought that it fades away to quickly. Not exactly what you want but you can choose the delay yourself.

FRED_fnc_infoText = { 
	/*
	File: infoText.sqf
		Author: Karel Moricky
		Modified By: Fredrik Eriksson
	
		Description:
		Info with some effect.
	
		Parameter(s):
		0 : ARRAY
				- Array containing lines of text.
		1 : NUMBER
				- Seconds before text fades away.
	*/
	
	(["FRED_info"] call bis_fnc_rscLayer) cutrsc ["rscInfoText","plain"];
	
	//--- Separate lines
	_text = _this select 0;
	_textArrayUnicode = [];
	{_textArrayUnicode = _textArrayUnicode + [toarray _x]} foreach _text;
	
	_fadeDelay = if (count _this > 1) then {_this select 1} else {2};
	
	//--- Separate letters
	_textArrayLines = [];
	for "_i" from 0 to (count _textArrayUnicode - 1) do {
		_line = _textArrayUnicode select _i;
		_textArrayTemp = [];
		{_textArrayTemp = _textArrayTemp + [tostring [_x]]} foreach _line;
		_textArrayLines set [_i,_textArrayTemp];
	};
	
	
	//--- Merge arrays
	_textArray = [];
	_emptyArray = [];
	_nArrayTemp = [];
	_n = 0;
	{
		_line = _x;
		_textArray = _textArray + _line + ["\n"];
		{
			//_emptyArray = _emptyArray + [_line call bis_fnc_selectrandom]; //--- Shuffled text
			//_emptyArray = _emptyArray + [str floor random 2]; //--- Binary Solo
			//_emptyArray = _emptyArray + [""]; //--- Rolling text
			_emptyArray = _emptyArray + [" "]; //--- Space
			_nArrayTemp = _nArrayTemp + [_n];
			_n = _n + 1;
		} foreach _x;
		_n = _n + 1;
		_emptyArray = _emptyArray + ["\n"];
	} foreach _textArrayLines;
	_finalArray = _emptyArray;
	_text = composetext _finalArray;
	
	
	//--- Random order
	_nArray = [];
	while {count _nArrayTemp > 0} do {
		_element = _nArrayTemp select (floor random (count _nArrayTemp));
		_nArray = _nArray + [_element];
		_nArrayTemp = _nArrayTemp - [_element];
	};
	
	
	//--- Visualization
	disableserialization;
	_display = uinamespace getvariable "BIS_InfoText";
	_textControl = _display displayctrl 3101;
	
	
	_text = composetext _finalArray;
	_textControl ctrlsettext str _text;
	_textControl ctrlcommit 0.01;
	sleep 1;
	
	{
		_finalArray set [_x,_textArray select _x];
		_text = composetext _finalArray;
		_textControl ctrlsettext str _text;
		_textControl ctrlcommit 0.01;
		playsound "ReadoutClick";
		if (random 1 > 0.9) then {sleep 0.1};
		sleep 0.01;
	} foreach _nArray;
	
	sleep _fadeDelay;
	
	//--- Fade away
	{
		_finalArray set [_x," "];
		_text = composetext _finalArray;
		_textControl ctrlsettext str _text;
		_textControl ctrlcommit 0.01;
		playsound "ReadoutClick";
		//if (random 1 > 0.9) then {sleep 0.2};
		sleep 0.01;
	} foreach _nArray;
	
	
	(["FRED_info"] call bis_fnc_rscLayer) cuttext [" ","plain"];
};

So it would be called by: 

[["TEXT", "text", "TexT"], 10] spawn FRED_fnc_infoText;
  • Like 2

Share this post


Link to post
Share on other sites

As much as I appreciate the reply I can't figure this out. Obviously I need to rename some stuff to call this in the init.sqf but I don't know enough about these things to figure this out on my own.

In my mission root I made a file called "FRED_fnc_infoText.sqf". I pasted the first part in that and didn't change anything.

In my init.sqf, I wrote

[["TEXT", "text", "TexT"], 10] spawn FRED_fnc_infoText.sqf;
Not sure if that was what I was supposed to do or not. I'm getting an error in expression message.

I just tried BIS_fnc_typeText in my init.sqf too (which I like better!)...

sleep 5;[ [ ["TEXT"], ["TEXT"], ["TEXT", "<t align = 'center' shadow = '1' size = '0.7' font='puristaMedium'>%1</t>", 70] ] , 0.8, 0.75, "<t align = 'center' shadow = '1' size = '1.0'>%1</t>" ] spawn BIS_fnc_typeText;
...and it's the same deal. It plays perfectly nice and slowly in SP but goes hyper-speed on a dedicated server. I wonder if BIS functions are just broken in a dedicated environment.

Share this post


Link to post
Share on other sites

You need to load the "FRED_fnc_infoText.sqf" first.

Either with:

#include "FRED_fnc_infoText.sqf";

or

call compileFinal preprocessFile "FRED_fnc_infoText.sqf";

personally i tend for the second.

then you can spawn it with

[["TEXT", "text", "TexT"], 10] spawn FRED_fnc_infoText;

Share this post


Link to post
Share on other sites

Yes, what na_palm said. I forgot to add that in my post, sorry. Anyway glad it worked out. :)

Share this post


Link to post
Share on other sites

So in my init.sqf:

call compileFinal processFile "FRED_fnc_infoText.sqf";

[["Text","Text","Text"], 10] spawn FRED_fnc_infoText.sqf;
And the file FRED_fnc_infoText.sqf in my mission root?If so thanks.

Is there anyway to slow down typeText at all? I like it better because it fits more letters. My mission title is too long for infoText. Or perhaps I can increase the amount of letters it allows?

Share this post


Link to post
Share on other sites
call compile preprocessFileLineNumbers "FRED_fnc_infoText.sqf";

That's what I use.

 

https://community.bistudio.com/wiki/BIS_fnc_typeText

#define DELAY_CHARACTER    0.06;
#define DELAY_CURSOR    0.04;

Don't really know where to put that, other than maybe in description.ext.

 

About increasing letter limit, no idea, want to know that with infoText also.

Share this post


Link to post
Share on other sites
call compile preprocessFileLineNumbers "FRED_fnc_infoText.sqf";
That's what I use.

https://community.bistudio.com/wiki/BIS_fnc_typeText

#define DELAY_CHARACTER	0.06;#define DELAY_CURSOR	0.04;
Don't really know where to put that, other than maybe in description.ext.

About increasing letter limit, no idea, want to know that with infoText also.

If that's all you use in the init.sqf where do you put the "text"?

Share this post


Link to post
Share on other sites

If that's all you use in the init.sqf where do you put the "text"?

 

Oh, I don't use it at the beginning but you can certainly have it like you have in your init.sqf. I guess I explained poorly.

 

I use mine later in the mission for side mission, but I'll probably add on one at the start of the mission as well.

call compile preprocessFileLineNumbers "FRED_fnc_infoText.sqf";

[["SIDE OPS", "BY: FREDRIK", format["11th July 2035, %1",([dayTime, "HH:MM"] call BIS_fnc_timeToString)]], 10] spawn FRED_fnc_infoText;

Something like that, Some name, my Name, and the current date and time. and I want it up for 10 seconds.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks man. Last question on this because I'm really liking typeText a lot better.

Would you know offhand in the typeText example I posted above if there's a variable in it for duration?

infoText would definitely work now (thanks to you guys) but like I said, it cuts off my mission title because I use too many characters. typeText does not and it just seems "cooler."

EDIT: I see you already addressed the time thing for typeText.

Yeah I saw that in the wiki and have no clue what to do with the define entries either. Lol

Share this post


Link to post
Share on other sites

After looking at the function in the functions viewer I can say that those lines being in the wiki is most likely a mistake, they're part of the function. I'm not sure how to rewrite that particular part to allow different values on those two though.

 

On the infoText part, you can use multiple lines to display your title. You can have 4 lines, before those are cut off by the boundary of the UI element infoText seem to be bound in.

Share this post


Link to post
Share on other sites

Nevermind the former post, I have now modified and successfully added both control over typing speed and time it is up on screen.

/*
	Author: Jiri Wainar
	Modified by: Fredrik Eriksson

	Description:
	Types a structured text on the screen, letter by letter, cursor blinking.

	Parameter(s):
		0 : NUMBER
			Typing Speed. DEFAULT: 0.06

		1 : NUMBER
			Delay in seconds before disappearing. 
				
		2 : ARRAY
			0 : ARRAY
				0 : ARRAY
					0 : STRING
						Your text here, multiple lines and structuring supported.
					1 : STRING
						Structuring and formatting here.
		
		3 : NUMBER
			X-position. DEFAULT: 0

		4 : NUMBER
			Y-position. DEFAULT: 0

	Remarks:
	* Every text block is an array of text and formatting tag.
	* Blocks don't have to span over whole line.

	Example:
	[
		0.06, 10,
		[
			[
				["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
				["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
				["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
			]
		],
		1,1
	] spawn FRED_fnc_typeText;
*/

FRED_fnc_typeText = {
	private["_data","_posX","_posY","_rootFormat","_toDisplay"];
	private["_blocks","_block","_blockCount","_blockNr","_blockArray","_blockText","_blockTextF","_blockTextF_","_blockFormat","_formats","_inputData","_processedTextF","_char","_cursorInvis","_blinkCounts","_blinkCount"];
	
	_delayCharacter = 	_this select 0;
	_delayRemove = 		_this select 1;
	_data = 			_this select 2 param [0, [], [[]]];
	_rootFormat = 		_this select 2 param [1, "<t >%1</t>", [""]];
	_posX 		= 		_this select 3;
	_posY 		= 		_this select 4;
	
	
	_delayCursor = 0.04;
	_blockCount = count _data;
	
	_invisCursor = "<t color ='#00000000' shadow = '0'>_</t>";
	
	//process the input data
	_blocks 	= [];
	_formats 	= [];
	_blinkCounts 	= [];
	
	{
		_inputData = _x;
	
		_block 		= _inputData param [0, "", [""]];
		_format 	= _inputData param [1, "<t align = 'center' shadow = '1' size = '0.7'>%1</t><br/>", [""]];
		_blinkCount 	= _inputData param [2, 5, [123]];
	
		//convert strings into array of chars
		_blockArray = toArray _block;
		{_blockArray set [_forEachIndex, toString [_x]]} forEach _blockArray;
	
		_blocks  = _blocks + [_blockArray];
		_formats = _formats + [_format];
		_blinkCounts = _blinkCounts + [_blinkCount];
	} forEach _data;
	
	//do the printing
	_processedTextF  = "";
	
	{
		_blockArray  = _x;
		_blockNr     = _forEachIndex;
		_blockFormat = _formats select _blockNr;
		_blockText   = "";
		_blockTextF  = "";
		_blockTextF_ = "";
	
		{
			_char = _x;
	
			_blockText = _blockText + _char;
	
			_blockTextF  = format[_blockFormat, _blockText + _invisCursor];
			_blockTextF_ = format[_blockFormat, _blockText + "_"];
	
			//print the output
			_toDisplay = format[_rootFormat,_processedTextF + _blockTextF_];
			[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
	
			playSound "ReadoutClick";
	
			sleep _delayCharacter;
			_toDisplay = format[_rootFormat,_processedTextF + _blockTextF];
			[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
			sleep _delayCursor;
		} forEach _blockArray;
	
		_blinkCount = _blinkCounts select _forEachIndex;
	
		if (_blinkCount > 0) then
		{
			for "_i" from 1 to _blinkCount do
			{
				_toDisplay = format[_rootFormat,_processedTextF + _blockTextF_];
				[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
				sleep _delayCharacter;
				_toDisplay = format[_rootFormat,_processedTextF + _blockTextF];
				[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
				sleep _delayCursor;
			};
		};
	
		//store finished block
		_processedTextF  = _processedTextF + _blockTextF;
	} forEach _blocks;
	
	Sleep _delayRemove;
	//clean the screen
	["", _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
};

Spawn it with:

[
	0.06, 10,
	[
		[
			["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
			["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
			["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
		]
	],
	0,0
] spawn FRED_fnc_typeText;

Share this post


Link to post
Share on other sites

So I'm the init.sqf...

call compile preprocessFileLineNumbers "FRED_fnc_typeText.sqf";

[
	0.06, 10,
	[
		[
			["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
			["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
			["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
		]
	],
	0,0
] spawn FRED_fnc_typeText;
While renaming the file FRED_fnc_typeText.sqf?

Share this post


Link to post
Share on other sites

So I'm the init.sqf...

 

call compile preprocessFileLineNumbers "FRED_fnc_typeText.sqf";

[
	0.06, 10,
	[
		[
			["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
			["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
			["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
		]
	],
	0,0
] spawn FRED_fnc_typeText;
While renaming the file FRED_fnc_typeText.sqf?

 

 

Not necessary, but you can if you want, it's neater that way probably.

 

EDIT: Wait, yeah, if you Preprocess "FRED_fnc_typeText.sqf", you also need a file named so. Otherwise it compiles nothing.

However you can Compile a file with my function in it called "CRAP.sqf" if you want, the functions name is not tied to the filename.

Share this post


Link to post
Share on other sites

I just would like to know exactly what to put in my mission file if you wouldn't mind.

I don't know anything about sqf.

When you get a sec could you post exactly what to put in my mission (ex. Put this in your init.sqf, put this in your mission root, etc)? No hurry. Thanks for everything.

Share this post


Link to post
Share on other sites

Okay, so say you have a file named "FRED_fnc_typeText.sqf" in the folder functions (I put this in for educational purposes) in the mission root folder, the file contains the function.

/*
	Author: Jiri Wainar
	Modified by: Fredrik Eriksson

	Description:
	Types a structured text on the screen, letter by letter, cursor blinking.

	Parameter(s):
		0 : NUMBER
			Typing Speed.

		1 : NUMBER
			Delay before disappearing.
				
		2 : ARRAY
			0 : ARRAY
				0 : ARRAY
					0 : STRING
						Your text here, multiple lines and structuring supported.
					1 : STRING
						Structuring and formatting here.
		
		3 : NUMBER
			X-position.

		4 : NUMBER
			Y-position.

	Remarks:
	* Every text block is an array of text and formatting tag.
	* Blocks don't have to span over whole line.

	Example:
	[
		0.06, 10,
		[
			[
				["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
				["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
				["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
			]
		],
		1,1
	] spawn FRED_fnc_typeText;
*/

FRED_fnc_typeText = {
	private["_data","_posX","_posY","_rootFormat","_toDisplay"];
	private["_blocks","_block","_blockCount","_blockNr","_blockArray","_blockText","_blockTextF","_blockTextF_","_blockFormat","_formats","_inputData","_processedTextF","_char","_cursorInvis","_blinkCounts","_blinkCount"];
	
	_delayCharacter = 	_this select 0;
	_delayRemove = 		_this select 1;
	_data = 			_this select 2 param [0, [], [[]]];
	_rootFormat = 		_this select 2 param [1, "<t >%1</t>", [""]];
	_posX 		= 		_this select 3;
	_posY 		= 		_this select 4;
	
	
	_delayCursor = 0.04;
	_blockCount = count _data;
	
	_invisCursor = "<t color ='#00000000' shadow = '0'>_</t>";
	
	//process the input data
	_blocks 	= [];
	_formats 	= [];
	_blinkCounts 	= [];
	
	{
		_inputData = _x;
	
		_block 		= _inputData param [0, "", [""]];
		_format 	= _inputData param [1, "<t align = 'center' shadow = '1' size = '0.7'>%1</t><br/>", [""]];
		_blinkCount 	= _inputData param [2, 5, [123]];
	
		//convert strings into array of chars
		_blockArray = toArray _block;
		{_blockArray set [_forEachIndex, toString [_x]]} forEach _blockArray;
	
		_blocks  = _blocks + [_blockArray];
		_formats = _formats + [_format];
		_blinkCounts = _blinkCounts + [_blinkCount];
	} forEach _data;
	
	//do the printing
	_processedTextF  = "";
	
	{
		_blockArray  = _x;
		_blockNr     = _forEachIndex;
		_blockFormat = _formats select _blockNr;
		_blockText   = "";
		_blockTextF  = "";
		_blockTextF_ = "";
	
		{
			_char = _x;
	
			_blockText = _blockText + _char;
	
			_blockTextF  = format[_blockFormat, _blockText + _invisCursor];
			_blockTextF_ = format[_blockFormat, _blockText + "_"];
	
			//print the output
			_toDisplay = format[_rootFormat,_processedTextF + _blockTextF_];
			[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
	
			playSound "ReadoutClick";
	
			sleep _delayCharacter;
			_toDisplay = format[_rootFormat,_processedTextF + _blockTextF];
			[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
			sleep _delayCursor;
		} forEach _blockArray;
	
		_blinkCount = _blinkCounts select _forEachIndex;
	
		if (_blinkCount > 0) then
		{
			for "_i" from 1 to _blinkCount do
			{
				_toDisplay = format[_rootFormat,_processedTextF + _blockTextF_];
				[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
				sleep _delayCharacter;
				_toDisplay = format[_rootFormat,_processedTextF + _blockTextF];
				[_toDisplay, _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
				sleep _delayCursor;
			};
		};
	
		//store finished block
		_processedTextF  = _processedTextF + _blockTextF;
	} forEach _blocks;
	
	Sleep _delayRemove;
	//clean the screen
	["", _posX, _posY, 5, 0, 0, 90] spawn BIS_fnc_dynamicText;
};

Like so.

 

After in init.sqf you have this at the top:

call compile preprocessFileLineNumbers "functions\FRED_fnc_typeText.sqf";

And whenever you want the typeText to appear you put this ie. in init.sqf under the line above:

[
	0.5, 10,
	[
		[
			["TEXTTEXTTEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
			["MORETEXT","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t><br/>"],
			["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"],
			["ANDSOMEMORE","<t align = 'center' shadow = '1' size = '1.0' font='PuristaBold'>%1</t><br/>"]
		]
	],
	1,1
] spawn FRED_fnc_typeText;

You can change the structuring yourself, I'm not sure about this one, I have not read much into it. But you can find more information here: https://community.bistudio.com/wiki/Structured_Text

  • Like 1

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  

×