Hey!
So I have connected my server to an external mysql database using the mysqloo9 module and have populated it with information such as player steamids.
I also want to log the ULX rank/user group on this database to help keep track, however I have run into an issue with the code.
Here is the code:
function DBULXRank (ply, currentulxrank)
local query2 = DB_RP:query( "SELECT ulx_rank FROM playerinformation WHERE steam_id = '" .. ply:SteamID() .. "';") -- checking current data
query2.onSuccess = function()
if (#query2:getData() != ply:GetUserGroup()) then -- if the data does not equal the in-game usergroup
local query = DB_RP:query("UPDATE playerinformation SET ulx_rank = '".. currentulxrank .."' WHERE steam_id = '" .. ply:SteamID() .. "';") --update the database column called ulx_rank
query.onSuccess = function()
MsgC( Color (0, 0, 255), "[SQL] The new player's rank " .. currentulxrank .. " was logged! \n")
end
query.onError = function(db, err)
MsgC( Color (255, 0, 0), "[SQL] (Add Player) - Error: ", err)
end
query:start()
end
end
query2:start()
end
hook.Add("PlayerInitialSpawn", "UpdateULXrole", function(ply)
DBULXRank(ply:GetUserGroup())
end)
What I want this function to do is when the player spawns in/connects, i want to check the database if the ULX rank is the correct one that is in-game, if not then update it.
The error is:
attempt to index a string value with bad key ('SteamID' is not part of the string library)
How can I fix this? Let me know if you need more information.
Please keep in mind that I am new to lua so if theres an obvious problem please let me know how to solve it!
Thanks in advance