Shepard9 1 Posted April 9, 2021 (edited) Hey, I am working on a Arma3 scripting Project and stumbled upon a behavior I cant explain: [player1, [ "Action1", { params ["_target", "_caller", "_actionId", "_arguments"]; []spawn{ ["doSomething.sqf"] remoteExecCall ["BIS_fnc_execVM",2]; //This is the line where it goes wrong sleep 5; createDialog "tutorialDialog"; ctrlSetText [1001, missionNamespace getVariable ["storedString",""]]; }; }, nil, 1.5, true, true, "", "true", // _target, _this, _originalTarget -1, false, "", "" ]] remoteExec ["addAction",0]; When I try to execute the action on the unit, it creates the dialog without any issues, so I know the script is spawning in correctly, but the remoteExecCall line is not doing what it should (changing the value stored in "storedString"). If I run the line. ["doSomething.sqf"] remoteExecCall ["BIS_fnc_execVM",2]; in the debug console as Local,Global or Server it works perfectly fine. Can someone explayin to me why that is? To provide some more context: The addAction is called in the init.sqf of my mission. Thanks in advance for any replies. Edited April 9, 2021 by Shepard9 Fixed/Closed Share this post Link to post Share on other sites
pierremgi 4753 Posted April 9, 2021 Inside an addAction code, you are already in a scheduled environment. So, spawning might be useless, especially for "calling" a remote execution,... for execVM an sqf! If your ["doSomething.sqf"] remoteExecCall ["BIS_fnc_execVM",2] line works (from a client-not server console), you probably reach the scheduler limitation of 3ms per frame. 1st: DON'T remoteExecCall for nuts, use remoteExec . Spoiler BIKI: The code sent by remoteExecCall MUST NOT contain any delays and SHOULD NOT be too complex and CPU demanding. 2nd: instead of execVM sqfs , think about your own functions. Spawning a function is faster than execVM an sqf (which means preprocessing the sqf string, then compiling it, then spawning it) 3rd (as reminder): an sqf (or a function), is usually made of several commands. (an sqf with a unique command is ridiculous). Remote exectuting several commands at once is unreliable, and sometimes counterproductive because each command has its own requirement for arguments and effects. Some of them must not be remote executed, some of them doesn't care but it's just a waste of net resource, some of them must be remote executed. 2 Share this post Link to post Share on other sites
Shepard9 1 Posted April 9, 2021 First of all: thanks for the reply @pierremgi Much appreciated. So, let me assure you, the things I want this .sqf to do are more than just one line (70 lines in the one and 245 lines in the other one) and also pretty heavy on ressources. Thanks for the reminder tho. As the actions I am performing in both of the scripts rely on spawning in units/deleting them I also have to remoteExec the code on the Server somehow. You might be right about those functions but as all of my code is really demanding and not made to run smooth at all I didnt really consider the small optimisation I could get from this improvement. Question is, how can I run my 250 lines of code on server while having it added to the addAction? Share this post Link to post Share on other sites
Shepard9 1 Posted April 9, 2021 Follow up: I was too stupid to initialize the addAction properly in my init, the actions I had were just relics of some testing I forgot about. After fixing the addActions my code worked like a carm. Thank you for your help tho. I was just too dumb xD. Closed. Share this post Link to post Share on other sites
pierremgi 4753 Posted April 9, 2021 Question is, how can I run my 250 lines of code on server while having it added to the addAction? You can run the code on server, just waiting for a variable to be (existent) or set to true. Then in your addAction, you just have to set the variable (and public server it). Something like: - on server, your sqf with: waituntil {!isNil "blahblah"}; - in addAction: blahblah = TRUE; publicVariableServer "blahblah"; Share this post Link to post Share on other sites