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") See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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 Script Trading Status Successful Trading : 26 Scam : 0 On Sale : Banking System SQL Based On Sale : Housing System MySQL Based Download and Support my new script on Community : http://community.mtasa.com/index.php?p=resources&s=details&id=11686 SQL Based Housing
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