Jump to content
kaleb c0d3

CBA_fnc_addPerFrameHandler vs spawn

Recommended Posts

Sup! I want to ask what do you think about these two blocks of code, performance wise. It's a 'side process' on client that fires an event on a dedicated server. My first approach was using a spawn-while-loop, but after some research (https://ace3mod.com/wiki/development/arma-3-scheduler-and-our-practices.html) I want to try another approach. I'm using CBA_A3 by the way.

 

Using spawn-while-loop:

// from some other piece of code --> fwp_saveInterval = 30
[] spawn {
	while {true} do {
		["FWP_EH_serverUnitSave", [player, getPlayerUID player]] call CBA_fnc_serverEvent;

		// skip interval
		sleep fwp_saveInterval;
	};
};

 

Using CBA_fnc_addPerFrameHandler:

// from other piece of code --> fwp_saveInterval = 30
fwp_clientAutosavePFH = [
	{
		["FWP_EH_serverUnitSave", [player, getPlayerUID player]] call CBA_fnc_serverEvent;
	}, fwp_saveInterval, []
] call CBA_fnc_addPerFrameHandler;

Thanks in advance 😄

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

×