alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
494 stars 197 forks source link

Use EngFunc_Time instead of get_gametime() in Anti-flood plugin #852

Open rtxa opened 4 years ago

rtxa commented 4 years ago

Description

This change will not have side-effects and it will benefit a lot for Half-Life servers that uses MiniAG. When you are playing a match (let's say a 2v2), sometimes a players gets disconnect and they need to pause the match, problem comes when server is paused, get_gametime() isn't working anymore, so players will not be able to chat anymore when they trigger the flood messages limit.

To fix this behaviour we can use instead EngFunc_Time:

Code

stock Float:GetServerUpTime() {
    return Float:engfunc(EngFunc_Time);
}

Replacing get_gametime() with this function in this line should be enough (it's only referenced one time) https://github.com/alliedmodders/amxmodx/blob/6ef40779e7f88dde2202fd554ebebc5500f0eea4/plugins/antiflood.sma#L36

Update: Only side-effect I found is that after 4 months running on and the server is never restarted, the time will overflow.

Still, you should restart your server every night. The engine itself will become out of sync with high tickcount values due to increasing floating point errors which will lead to all kind of problems.

dystopm commented 4 years ago

It makes sense