ULX MySQL (ULib.ucl.addUser)

[lua]
function LoadUsers( pl )
local steamID = pl:SteamID()
local rank = tmysql.query(“SELECT ulx FROM ranks WHERE steam_id = '” … steamID … “’”)
ULib.ucl.authed[ pl ] = nil
if (rank) then
pl:ChatPrint("Loading " … pl:Nick() … "'s account
")
ULib.ucl.addUser( pl:Nick(), “steamid”, pl:SteamID(), { tostring(rank) } )
pl:ChatPrint("Loaded " … pl:Nick() … "'s rank.
")
ULib.ucl.probe( pl )
end
end
hook.Add( “PlayerInitialSpawn”, “LoadUserRank”, LoadUsers )
[/lua]

Think I’m doing this wrong. Pretty sure its on line 7. I get no errors.

tmysql is threaded, isn’t it? You need to use a callback function instead of just using the return value.

tmysql v2 is. I have had problems with v3 in the past.

[editline]26th October 2010[/editline]

[lua]
function callbackfunc(result, status, error)
print("Callback function started
")
print("Status: " … status … "
Error: " … error … "
")
end

function LoadUsers( pl )
local steamID = pl:SteamID()
local rank = tmysql.query(“SELECT ulx FROM ranks WHERE SteamID = '” … steamID … “’”, callbackfunc)
ULib.ucl.authed[ pl ] = nil
if (rank) then
pl:ChatPrint("Loading " … pl:Nick() … "'s account
")
ULib.ucl.addUser( pl:Nick(), “steamid”, pl:SteamID(), { tostring(rank) } )
pl:ChatPrint("Loaded " … pl:Nick() … "'s rank.
")
ULib.ucl.probe( pl )
end
end
hook.Add( “PlayerInitialSpawn”, “LoadUserRank”, LoadUsers )
[/lua]

Seems to to even be query-ing.

[lua]local function addUser( pl, res, status, err )
pl:ChatPrint("Loading " … pl:Nick() … "'s account
")

-- Add error checking

ULib.ucl.addUser( pl:Nick(), "steamid", pl:SteamID(), {
	res[1].ulx
} )

pl:ChatPrint("Loaded " .. pl:Nick() .. "'s rank.

")

ULib.ucl.probe( pl )

end

local function LoadUsers( pl )
local steamID = pl:SteamID()
ULib.ucl.authed[ pl ] = nil

tmysql.query(
	"SELECT ulx FROM ranks WHERE SteamID = '" .. steamID .. "'",
	AddUser,
	nil,
	pl
)

end
hook.Add( “PlayerInitialSpawn”, “LoadUserRank”, LoadUsers )
[/lua]

According to tmysql3 docs. This is only example code though, don’t expect it to work as copypasta.

-snip-
I need some sleep and I noticed some shit.