xyz Posted May 17, 2016 Posted May 17, 2016 I'm in progress of making an update script that works with SQL, I have done everything else, uploading into the database and etc. But I can't figure out how to get the text from the database. Client function addUpdatesFromDB_c(o) guiSetText(updates_memo, string.gsub(o)) end addEvent("addUpdatesFromDatabase", true) addEventHandler("addUpdatesFromDatabase", getRootElement(), addUpdatesFromDB_c) Server function loadDatabase(qh) local res = dbPoll(qh, 0) for i, o in pairs(res) do triggerClientEvent("addUpdatesFromDatabase", root, o) end end dbQuery(loadDatabase, {}, connect, "SELECT u_txt FROM updates_table") Everything else works, uploading etc.
Anubhav Posted May 18, 2016 Posted May 18, 2016 function loadDatabase(qh) local res = dbPoll(qh, 0) for i, o in ipairs(res) do local result = o.u_text triggerClientEvent("addUpdatesFromDatabase", root, result) end end dbQuery(loadDatabase, {}, connect, "SELECT * FROM updates_table")
xyz Posted May 18, 2016 Author Posted May 18, 2016 bad argument #1 to 'gsub' (string expected, got nil)
Cadell Posted May 18, 2016 Posted May 18, 2016 this is example you can do something like this function sendData(player) local query = dbQuery(handler,"select * from table") if #query > 0 then for i,k in ipairs(query) do triggerClientEvent(player,"eventName",getRootElement(),k.colName1,k.colName2, . . .,k.colNamen) end end end Hope it will help you
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now