View Single Post
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 07-28-2018 , 21:50   Re: set_task not working when server is in pause
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
Well, the tasks are checked in the engine pfnStartFrame hook (game frame), so yeah, if the game is paused, this is not going to be executed. Anything related to the server physics will be paused.

If you look at the engine code:
Code:
void SV_Frame(void)
{
	if (!g_psv.active)
	{
		return;
	}

	gGlobalVariables.frametime = host_frametime;
	g_psv.oldtime = g_psv.time;

	SV_CheckCmdTimes();
	SV_ReadPackets();

	if (SV_IsSimulating())
	{
		SV_Physics();
		g_psv.time += host_frametime;
	}

	SV_QueryMovevarsChanged();
	SV_RequestMissingResourcesFromClients();
	SV_CheckTimeouts();
	SV_SendClientMessages();
	SV_CheckMapDifferences();
	SV_GatherStatistics();

	Steam_RunFrame();
}
SV_Physics won't be called if paused (pfnStartFrame/Think/Touch/etc).

The engine doesn't provide a global API function above, but it would be still possible to hook for example SV_ReadPackets with a signature.

That's said, I don't know if it makes sense to do that just for task.
Thanks for answer, for me this makes sense, set_task isn't doing his task as you showed in the code, according the docs "Calls a function after a specified time has elapsed".

Regarding antiflood's plugin, it also has the same problem, because it uses get_gametime().
Maybe it should be replaced with get_systime(), but this function only returns seconds and not miliseconds... What can be done to solve this problem?

I would like to contribute with this but unfortunately is out of my knowledge.
rtxa is offline