Ulx sync sytem causing lag

So we have a slight issue with our ULX sync system.

When a new player joins, or a player that is in the user group joins once more, they are writting to a users.txt file as per the below.

local function LoadRank(player)
local load = false
local queryQ = ULXDB:query("SELECT * FROM `"..ULX_TABLE.."` WHERE `steam`='"..player:SteamID().."';")
queryQ.onData = function(Q,D)
  queryQ.onSuccess = function(q)
   Msg("Found "..player:GetName().." in database!
   load = true
queryQ.onerror = function(Q,E) print("LoadRank threw an error:") print(E) end

if (load == false) then

Take note of the “if (load == false) then

this causes a file write to users.txt for ULIB.

Which causes lag whenever a player joins (as the users.txt file get’s huge (500KB in a couple days) and lags when is read/written.

The purpose of this is to ensure ranks are synced, so if a player is not found in the database they are written to user, like if an admin was demoted for example.

Thoughts on ways to instead write to a database or a different fix to stop the lag?


Im having the same problem, anybody know how to fix this?

Comment out the area of which writes it to the users.txt,

ULX likes to do things the hard way.

Granted, if you were to use separate files for each user, it would cause MFT clutter, but that’s not much of a concern. Though seeing as you’re using MySQL you should be fine.

Unfortunately for them (All of us) , file.Read begins to cause issues around ~100kb (Depending on your hardware).

You COULD however create a seperate module of which writes data based on steamid. Using each steamid as an individual file. Then read / write / access those as needed.