Jump to content
JohnKalo

Modules Lag when Mission does not

Recommended Posts

A few months ago we started creating a campaign. And all is good. All apart from this one thing. The modules creating tasks take aboout 0,5 to 1 minute to be completed. Actually even a module unlocking a door took 0,5 to 1 minute to be activated.

 

In short here is the description of the situation:

 

1.] We are talking about high end PCs.

 

2.] The mission does not lag.

3.] Triggers do not lag.

4.] Task modules lag up to a minute. The task completed panel appears 0,5 to 1 minute after completion to both the host and the clients.

5.] To the host even when the task appears to be completed, the tab showing "Task Completed" also lags. The clients have no such lag.

6.] Even modules unlocking a door lags up to a minute.

7.] A script showing text at the start of the mission lags only on the host. It is a script running through the initPlayerLocal.sqf so why?

 

8.] Testing modules while the map is empty has no lag. The lag takes place once the mission is in its final satges of development.

9.] We are talking about missions with intros, outros and much more.

 

10.] Sometimes I use safety triggers because the mission refuses to place playable units in vehicles. I just place the same trigger 2 or 3 times and all good...

 

So up to episode 04 there was not an issue. The tasks did lag but cleverly I hidded that lag. In episode 04 however I cannot hide it. So for episode 04 and the next WHAT IS GOING ON???

 

 

Addons used:

 

CBA,

ASR AI3,

Hellenic Armed Forces mod,

Lythium Map,

Vanilla DLCs

 

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, JohnKalo said:

Sometimes I use safety triggers because the mission refuses to place playable units in vehicles.

 

Might this behaviour is from a certain script?

ASR for example?

Have you test this without the mod?

 

16 minutes ago, JohnKalo said:

5.] A script showing text at the start of the mission lags only on the host

 

About lag , might be a server issue cause of low Fps ?

Is it a dedicated or local host , with the hoster playing as well?

 

  • Like 1

Share this post


Link to post
Share on other sites
Quote

 

Might this behaviour is from a certain script?

ASR for example?

Have you test this without the mod?

 

 

Well I cannot test any of these missions without the ASR activated because it is a dependency.

 

When I use task modules in an empty Lythium map they do not lag. As the mission moves on however task modules lag gets worse and worse. If I recall correctly the lag also took place at other maps when the mission was at its final stages. If it was from a simple script it would not lag more and more logically speaking.

 

So the ASR could be the issue but I cannot test it and in previous missions where other game and script versions were present there wasn't an isssue. Even in missions with even more task modules and such.

 

I mean using scripts to make tasks could be possible but since the script showing text lags too, it might be a huge effort with no success.

 


 

Quote

 

About lag , might be a server issue cause of low Fps ?

Is it a dedicated or local host , with the hoster playing as well?

 

 

But that is the thing. The FPS are fine. The only thing lagging is the modules and the text script. It is a Hosted Server. Not a dedicated one.

  • Like 1

Share this post


Link to post
Share on other sites
38 minutes ago, JohnKalo said:

It is a Hosted Server. Not a dedicated one.

 

Might be some script that loops  ( more than it should be  )  in the whole mission ?

  • Like 1

Share this post


Link to post
Share on other sites

A nice possibility. However, only two custom scripts loop, they are non existent in the other campaign missions and they are not activated at the start of the mission.

The rest of the scripts are used in all missions, like the dragBody sript and such but they never caused any lag.

 

This is really mysterious because what would cause only the modules and the text script to lag? Eveything else works fine.

  • Like 1

Share this post


Link to post
Share on other sites

Show code and upload your mission.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
49 minutes ago, HazJ said:

Show code and upload your mission.

 

This.

Points 2-10 are only speculation without seeing scripts and/or mission.

Point 1 is irrelevant if there's funky stuff running in a while true loop without sleep (or similar).

 

"Lagging" tasks and units not being placed inside vehicles sounds like there's something off.

Try it without mods and see if the issue persists.

 

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, JohnKalo said:

 

Well I cannot test any of these missions without the ASR activated because it is a dependency.

This is why I always make a vanilla version of my missions.

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
11 minutes ago, Harzach said:

This is why I always make a vanilla version of my missions.

:yeahthat:...and I learned that the hard way.

  • Like 3
  • Thanks 1
  • Haha 2

Share this post


Link to post
Share on other sites
Just now, zagor64bz said:

:yeahthat:...and I learned that the hard way.

#metoo

  • Thanks 1
  • Haha 4

Share this post


Link to post
Share on other sites
4 hours ago, JohnKalo said:

 

Well I cannot test any of these missions without the ASR activated because it is a dependency.

 

You could remove ASR AI as a dependency, manually, in the mission.sqm file of your mission folder. To do so you would have to save your mission without binarization. You ought to create a backup of your mission file should something happen though. I did test this a few minutes ago with four soldiers placed down in the VR map and it turned out fine.

This what the required addons would look like in the mission.sqm file:

 

addons[]=
{
	"A3_Characters_F",
	"asr_ai3_skills"
};


 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

 You just point at the 3 ms scheduler's limit. Probably too many scripts running at this time or a bad one looping for nuts.

Does this occur at start (I guess not) or during heavy fights with mods supposed to manage AIs' behavior? Re-think your scenario. Use the garbage management and the dynamic (or module) simulation.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for helping guys. Had a class and could not reply earlier. Now,

 

@HazJ

@Grumpy Old Man

The mission is already uploaded in a .pbo format here:

It is the direct download link to Episode 04. If you cannot turn it into a .sqf I will upload it again.

 

@Harzach

@zagor64bz

Indeed, cannot try without addons due to dependencies. Creating a vanilla mission is hard because I use CBA modules, Hellenic Armed Forces units and weapons, the ASR I believe works best if enabled while editing and more.

 

@SpaceHippo

Thank you but ASR is not the only dependency. Removing dependencies will mean deleting way too many things.

 

@pierremgi

I have no idea what the ms scheduler's limit is. The issue as mentioned but not entirely cleared is that, apart from the modules, only the text script seems to lag. Other scripts causing many things do not lag.

 

When opening the sqf format you will see most scripts in the same place. They are there because when I try to place a path for the scripts or some of the images it says script or image not found. Strange because the paths work for ready scripts, sounds, audio and some images.

Also the use of modules in the mission makes the mission hard to understand to any person who has not edited it. Please remember I have got next to no scripting skills but all missions work in the end. Thanks to all of you who will try. 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

So while I am recharging my Arma 3 editing batteries, the text script that lags only on the host is called via the initPlayerLocal.sqf like this:
 

null = [["Defying the Odds","By GreekEditor","Day 4 - 7/22/2020"], 0.1, 10] execVM "infoText.sqf";

and it is this one:


 

/*Install info:
- place this .sqf file into your mission folder
- see examples below for script calling syntax*/
/*
    File: infoText.sqf
    Author: Karel Moricky
    
    edited ver. by Feuerex (extended customization)
    Description:
    Info with some effect.

    Parameter(s):
    _this select 0: array of strings containing text.
    _this select 1: rate at which individual letters appear (0-99)
    _this select 2: pause after constructing the text until deconstructing it (0-99)
    _this select 3: X coordinates (0-1)*, optional
    _this select 4: Y coordinates (0-1)*, optional
    * values may differ for different screen resolutions. I recommend using SafeZone.
    
    Handle = [["Text", "Text(optional)", "Text(optional)"], individual letters rate, overall pause, X, Y] execVM "infoText.sqf";
    
    examples:
    null = [["First line","Second line","Third line"], 0.01, 6] execVM "infoText.sqf";
    text appears on it's default position (arguments for X, Y aren't used), stays for 6 seconds.
    
    null = [["First line","Second line","Third line"], 0.01, 5, 0.5,0.8] execVM "infoText.sqf";
    text appears very quickly and then hangs for 5 seconds before it starts to disappear.
    
    null = [["Mission name","By: Author name","Date"], 0.03, 4, SafeZoneX, SafeZoneY/1.5] execVM "infoText.sqf";
    text is appearing a bit more slowly and hangs for 4 seconds before disappearing.
    */

(["BIS_fnc_infoText"] call bis_fnc_rscLayer) cutRsc ["rscInfoText","plain"];

//---Parameters
_text = _this select 0;
_rate = _this select 1;
_pause = _this select 2;

//---Time related restrictions
_minTime = 0;
_maxTime = 99;
if (_rate < _minTime || _rate > _maxTime) exitWith {
["InfoText - Time value out of range", _rate] call BIS_fnc_errorMsg};

//--- Separate lines
_textArrayUnicode = [];
{_textArrayUnicode = _textArrayUnicode + [toarray _x]} foreach _text;

//--- 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;
if (count _this > 4) then {
_textControl ctrlsetPosition [_this select 3,_this select 4];};
_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";
    //hintsilent str _text;
    if (random 1 > 0.9) then {sleep 0.1};
    sleep _rate;
} foreach _nArray;

sleep _pause;


//--- Fade away
{
    _finalArray set [_x," "];
    _text = composetext _finalArray;
    _textControl ctrlsettext str _text;
    _textControl ctrlcommit 0.01;
    //playsound "ReadoutClick";
        //hintsilent str _text;
    //if (random 1 > 0.9) then {sleep 0.2};
    sleep _rate;
} foreach _nArray;


([] call bis_fnc_rscLayer) cuttext ["","plain"];

 

 

So far nobody could explain why the modules lag but maybe someone can explain why the above script lags on the host. Tested on two different host computers. Clients never lagged.

  • Like 1

Share this post


Link to post
Share on other sites

Perhaps, the former version could be fine for your aim:

bis_fnc_infoText

You can try also to compile your sqf then spawn your function:

 

This should work:


 

fn_infoText = compileFinal "
  _text = _this select 0;
  _rate = _this select 1;
  _pause = _this select 2;
  _minTime = 0;
  _maxTime = 99;
  if (_rate < _minTime || _rate > _maxTime) exitWith {
    ['InfoText - Time value out of range', _rate] call BIS_fnc_errorMsg
  };
  (['someLayerName'] call bis_fnc_rscLayer) cutrsc ['rscInfoText','plain'];
  _textArrayUnicode = [];
  {_textArrayUnicode = _textArrayUnicode + [toarray _x]} foreach _text;
  _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];
  };
  _textArray = [];
  _emptyArray = [];
  _nArrayTemp = [];
  _n = 0;
  {
    _line = _x;
    _textArray = _textArray + _line + ['\n'];
    {
       _emptyArray = _emptyArray + [' '];  
       _nArrayTemp = _nArrayTemp + [_n];
       _n = _n + 1;
    } foreach _x;
    _n = _n + 1;
    _emptyArray = _emptyArray + ['\n'];
  } foreach _textArrayLines;
  _finalArray = _emptyArray;
  _text = composetext _finalArray;
  _nArray = [];
  while {count _nArrayTemp > 0} do {
    _element = _nArrayTemp select (floor random (count _nArrayTemp));
    _nArray = _nArray + [_element];
    _nArrayTemp = _nArrayTemp - [_element];
  };
  disableserialization;
  _display = uinamespace getvariable 'BIS_InfoText';
  _textControl = _display displayctrl 3101;
  _text = composetext _finalArray;
  _textControl ctrlsettext str _text;
  if (count _this > 4) then {
    _textControl ctrlsetPosition [_this select 3,_this select 4];
  };
  _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 _rate;
  } foreach _nArray;
  sleep _pause;
  {
    _finalArray set [_x,' '];
    _text = composetext _finalArray;
    _textControl ctrlsettext str _text;
    _textControl ctrlcommit 0.01;
    sleep _rate;
  } foreach _nArray;
  (['someLayerName'] call bis_fnc_rscLayer) cuttext ['','plain'];
";

null = [["Defying the Odds","By GreekEditor","Day 4 - 7/22/2020"], 0.1, 10] spawn fn_infoText;

 

 

 

 

  • Thanks 1

Share this post


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

You can try also to compile your sqf then spawn your function

execVM is the same as spawn compile preprocessFileLineNumbers.

So your code is doing the same thing as execVM is doing.

 

14 hours ago, GEORGE FLOROS GR said:

John try:


if (!isServer) then { //run on all player clients incl. headless clients but not player host };

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

So to fix the script lagging. You are proposing to just not run the script at all? How's that supposed to help?

 

 

 

If your script is lagging because it's too slow, you should optimize your script.

You guys are all trying to fight the symptoms instead of fighting the cause.

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

_emptyArray = _emptyArray + [" "]; //--- Space

_nArrayTemp = _nArrayTemp + [_n];

instead of the + use pushBack or append.

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

_element = _nArrayTemp select (floor random (count _nArrayTemp));

We have the selectRandom command for that.

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

_nArray = [];

while {count _nArrayTemp > 0} do {

_element = _nArrayTemp select (floor random (count _nArrayTemp));

_nArray = _nArray + [_element];

_nArrayTemp = _nArrayTemp - [_element];

};

You want to randomize the order of that array?

Why not just use https://community.bistudio.com/wiki/BIS_fnc_arrayShuffle instead of trying to build your own? I'm quite sure the BIS function is more efficient. But I'm also sure it's not the most efficient.

That one might be more efficient: https://github.com/CBATeam/CBA_A3/blob/master/addons/arrays/fnc_shuffle.sqf

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

{_textArrayTemp = _textArrayTemp + [tostring [_x]]} foreach _line;

->

private _textArrayTemp = _line apply {toString [_x]};

 

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

//--- 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];

};

->

private _textArrayLines = _textArrayUnicode  apply { _x apply {toString [_x]} }

 

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

//--- Separate lines

_textArrayUnicode = [];

{_textArrayUnicode = _textArrayUnicode + [toarray _x]} foreach _text;

->

private _textArrayUnicode = _text apply { toArray _x };

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

_text = _this select 0;

_rate = _this select 1;

_pause = _this select 2;

->

params ["_text", "_rate", "_pause"];

 

 

This script looks like it's 10 years old :D

You can refer to https://community.bistudio.com/wiki/Code_Optimisation for more useful tips.

 

 

On 8.10.2018 at 9:28 AM, JohnKalo said:

but maybe someone can explain why the above script lags on the host

Maybe the host just has more scripts running, More work for the scheduler, less time to be spent on every script as the scheduler is limited to 3ms.

If the scheduler doesn't have time to run your script every frame, it won't. Thus it will lag.

 

 

On 9.9.2018 at 8:41 PM, JohnKalo said:

Other scripts causing many things do not lag.


Do you actually KNOW that they do not lag? Or do you think they do not lag because you can't see it?

The text script makes the lagging quite obvious, as you can directly see it.

 

 

Edit:

Just did a little research into what that function actually is.

It's the info text at mission start that's shown at bottom right. And it's the old crappy Arma 2 version which has never been updated. I still remember back from playing DayZ Mod how the text would often take half a minute to fully appear and it would lag like hell. Now I know why. That script is just pure garbage if you look at all the modern script commands we have now.

Share this post


Link to post
Share on other sites

Thanks all for the help on the script!

As it seems I will have to modernize the script if I am to have a fully workable and lag free solution. The other suggestions are also nice and I will also use them. I have some media to create and then I shall try them.

 

@Dedmen Yep I know that other scripts do not lag because they play videos or bring effects in play. And it is also why it is a mystery that the task modules lag when triggers and scripts do not.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

i took time to write you a working script. Have you the same lag?

 

6 hours ago, Dedmen said:

execVM is the same as spawn compile preprocessFileLineNumbers.

So your code is doing the same thing as execVM is doing.

 

No, if you compile at start and spawn your code later, that's not the same as execVM an sqf doing that in the same operation. Looks like the "preload" of the arsenal, when trying it with and without this option.

 

6 hours ago, Dedmen said:

So to fix the script lagging. You are proposing to just not run the script at all? How's that supposed to help?

 

 

Ridiculous! I wrote a working script (and corrected some errors of initial JohnKalo one, btw) which doesn't lag for me. So don't harass with stupid comment.

 

  • Like 1

Share this post


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

Ridiculous! I wrote a working script

I don't see a difference between the original and yours. Besides all the comments being removed in yours.

33 minutes ago, pierremgi said:

No, if you compile at start and spawn your code later, that's not the same as execVM an sqf doing that in the same operation.

Yes, it affects the initial start time. But not the runtime inside the script.

 

34 minutes ago, pierremgi said:

Ridiculous!

Check again who I quoted and answered with that comment.

Share this post


Link to post
Share on other sites
5 hours ago, Dedmen said:

I don't see a difference between the original and yours. Besides all the comments being removed in yours.

 

Check again also. :f:

Share this post


Link to post
Share on other sites

@pierremgi Ehmmmmm, it did not work. It said fn_infotext could not be found for some reason. I copy pasted from your post so I did not change anything. Oh, I discovered more bis_fnc_infoText functions that do not lag so I will use them. I will have to change the missions' intros logic but that is a motivation to enhance intros as a whole so .... why not?

Share this post


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

@pierremgi Ehmmmmm, it did not work. It said fn_infotext could not be found for some reason. I copy pasted from your post so I did not change anything. Oh, I discovered more bis_fnc_infoText functions that do not lag so I will use them. I will have to change the missions' intros logic but that is a motivation to enhance intros as a whole so .... why not?

The code works... or we don't have the same Arma! ... or you didn't run in the right order. So, some reason is on your side. Do you need a video just for copying/pasting it in a true trigger as example?

Share this post


Link to post
Share on other sites

You did not tell me to place it in a trigger. I replaced the code in the script with yours and I called it via a trigger. That did not work. So I will try to copy paste the whole thing in a trigger.

By the way, I had decided to use the bis_fnc_infoText functions. But I said hey this guy spend time writing a script so I should try his too. Not moral to ditch a script you asked for just because you found another solution. So no I do not need a video.

Share this post


Link to post
Share on other sites
5 hours ago, JohnKalo said:

You did not tell me to place it in a trigger. I replaced the code in the script with yours and I called it via a trigger. That did not work. So I will try to copy paste the whole thing in a trigger.

By the way, I had decided to use the bis_fnc_infoText functions. But I said hey this guy spend time writing a script so I should try his too. Not moral to ditch a script you asked for just because you found another solution. So no I do not need a video.

Trigger or else (init.sqf, initPlayerLocal.sqf), running for clients you want, when you want....

But if you split the code (mine) in fn_infoText, on one hand, and the calling line:

null = [["Defying the Odds","By GreekEditor","Day 4 - 7/22/2020"], 0.1, 10] spawn fn_infoText;

on the other hand, just be sure to load (compile here) the function before calling it!

You have to cope with initialization order, as usual. You can't avoid that with my code or any other one. Sometimes you should prefer to run all the stuff in an unique sqf... the order is already good! but you can experience lags, especially with a lot of heavy scripts (and a lack of priority).

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

×