General > Developers Corner

Quick question about timer.Simple

(1/1)

Lt.Smith:
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:


--- 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 )
--- End code ---

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.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version