I'm in the process of modifying uTime to use an external database. Unfortunately my database is 4000 miles away from my gameservers so the latency is horrible, so I decided I'd stagger the updating of people's times to spread the queries out over time so people don't notice it so much. Here's the modified code:
function updateAll()
local players = player.GetAll()
for _, ply in ipairs( players ) do
if ply and ply:IsConnected() then
timer.Simple(5, updatePlayer, ply)
//updatePlayer( ply )
end
end
end
timer.Create( "UTimeTimer", 335, 0, updateAll )
But I'm unsure how it'd run. It could be (and this is the idea):
-Function updateAll is called.
-5 second wait.
-First player is updated.
-5 second wait.
-Second player is updated.
etc
But what I worry might actually be the case is the following.
-Function updateAll is called.
-5 second wait.
-Everybody is updated one after another with no pauses inbetween.
If that's the case I'll have to think of something else. In a previous discussion about the uban PHP viewer there was talk of using the gm_mysql module in non-blocking mode, which sure sounds attractive but I still haven't figured out how to do it.
Can anyone clarify for me?
Edit: Crap, just realised there's a developer's corner subforum. My mistake.