Raised This Month: $12 Target: $400
 3% 

set_task not working when server is in pause


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 07-28-2018 , 02:41   set_task not working when server is in pause
Reply With Quote #1

Hello, I'm running into a trouble in my plugin for Half-Life 1. I have a vote system, where for example, you do a vote to change mp_footsteps to 1, if after 30 seconds the vote doesn't get enough votes, it will be denied. I use set_task for that, the problem is when someone pause the server, the vote is never denied.

Same thing happens when you flood the chat (antiflood plugin that comes with amxx), the blocking never frees.

I'm using amxx 1.8.3 dev 5141, hlds 7561 and latest metamod-p.

If you need more information, you can check yourself in the source code on line 1705.
https://github.com/rtxa/agmodx/blob/...ing/agmodx.sma

Last edited by rtxa; 07-28-2018 at 02:47.
rtxa is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-28-2018 , 06:21   Re: set_task not working when server is in pause
Reply With Quote #2

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.
__________________
Arkshine is offline
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
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-29-2018 , 12:01   Re: set_task not working when server is in pause
Reply With Quote #4

Is strange since: "Anything related to the server physics will be paused."
Why a code shoud be executed in a function when all other things is paused?

ie. Change team or doing any action related with players when all things are paused?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 08-16-2018, 13:21
OciXCrom
This message has been deleted by asherkin. Reason: Don't reply to the fucking spam.
rtxa
Senior Member
Join Date: Mar 2018
Location: Argentina
Old 03-29-2020 , 10:59   Re: set_task not working when server is in pause
Reply With Quote #5

Quote:
Originally Posted by ^SmileY View Post
Is strange since: "Anything related to the server physics will be paused."
Why a code shoud be executed in a function when all other things is paused?

ie. Change team or doing any action related with players when all things are paused?
It's not about that, a vote is showing on the screen for 30 seconds while the sv is in pause, and of course, it needs to be updated, and also I don't want to show it anymore after that time.

Anyway, I found a functions (thanks BulliT) that stills running. Hook with fakemeta AllowLagCompensation(), create your own timer and whoala.
__________________
rtxa is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode