ULX

Author Topic: Quick question about timer.Simple  (Read 2856 times)

0 Members and 1 Guest are viewing this topic.

Offline Lt.Smith

  • Newbie
  • *
  • Posts: 32
  • Karma: 4
Quick question about timer.Simple
« on: June 15, 2008, 03:45:47 AM »
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: [Select]
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.
« Last Edit: June 15, 2008, 03:52:12 AM by Lt.Smith »

An Error Has Occurred!

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