3B00DG4MER Posted August 1, 2014 Share Posted August 1, 2014 (edited) Hi Guys today i've make xampp localhost i've make database,table..... and yea,i tried to connect lua script with database and it's works but i have a small problem i tried to make a test : Selects all things in table and show them in a gridlist help plz Here is Server: connection = dbConnect( "mysql", "dbname=cir;host=localhost", "mtaserver", "game2020", "share=1" ) dbExec( connection, "INSERT INTO names VALUES (?,?)", 4, "test2" ) local allnames = dbExec( connection, "SELECT * FROM names") triggerClientEvent(getRootElement(),"onStart",allnames) Client: function testing( allnames ) local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) for player in ipairs(allnames) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) end end addEvent("onStart",true) addEventHandler("onStart",localPlayer,testing) Edited August 4, 2014 by Guest Link to comment
xXMADEXx Posted August 1, 2014 Share Posted August 1, 2014 You need to use dbQuery and dbPoll Link to comment
3B00DG4MER Posted August 1, 2014 Author Share Posted August 1, 2014 You need to use dbQuery and dbPoll i used them and it's tell me when i try to trigger: triggerClientEvent [Expected Element at Argument 3, got table] i changed server: function testsql() connection = dbConnect( "mysql", "dbname=cir;host=localhost", "mtaserver", "game2020", "share=1" ) dbExec( connection, "INSERT INTO names VALUES (?,?)", 4, "test2" ) local allnames = dbQuery( connection, "SELECT * FROM names") local result = dbPoll(allnames, -1) triggerClientEvent(getRootElement(),"onStart",result) end addCommandHandler("testmysql",testsql) Link to comment
MIKI785 Posted August 1, 2014 Share Posted August 1, 2014 Can you read? It clearly says that 3rd argument is supposed to be element, that is the base element (the source), just put root there... the table (result) is the 4th argument. Link to comment
3B00DG4MER Posted August 1, 2014 Author Share Posted August 1, 2014 Can you read? It clearly says that 3rd argument is supposed to be element, that is the base element (the source), just put root there... the table (result) is the 4th argument. i fixed it Now it's shows me 1 2 3 ..... i want to show the table things ex: in db table 1 Unknown 2 Gamer 3 Player i want to show those in a gridlist plz help Link to comment
3B00DG4MER Posted August 1, 2014 Author Share Posted August 1, 2014 Can you read? It clearly says that 3rd argument is supposed to be element, that is the base element (the source), just put root there... the table (result) is the 4th argument. i fixed it Now it's shows me 1 2 3 ..... i want to show the table things ex: in db table 1 Unknown 2 Gamer 3 Player i want to show those in a gridlist plz help Link to comment
Et-win Posted August 2, 2014 Share Posted August 2, 2014 guiCreateGridList guiGridListAddRow guiGridListSetItemText Look on the wiki for Grid List code's, if that isn't too much work for you, instead of letting us do all the work: https://wiki.multitheftauto.com/wiki/El ... I/Gridlist Link to comment
3B00DG4MER Posted August 2, 2014 Author Share Posted August 2, 2014 guiCreateGridList guiGridListAddRow guiGridListSetItemText Look on the wiki for Grid List code's, if that isn't too much work for you, instead of letting us do all the work: https://wiki.multitheftauto.com/wiki/El ... I/Gridlist Plz Fix it If you fix it i'm going to save and next time i won't do the wrong again plz fix it Link to comment
Et-win Posted August 3, 2014 Share Posted August 3, 2014 Plz Fix itIf you fix it i'm going to save and next time i won't do the wrong again plz fix it Ehum, no. Link to comment
3B00DG4MER Posted August 3, 2014 Author Share Posted August 3, 2014 Ehum, no. your Heart is So Black Man fix it plz Link to comment
Saml1er Posted August 3, 2014 Share Posted August 3, 2014 function testsql(p) connection = dbConnect( "mysql", "dbname=cir;host=localhost", "mtaserver", "game2020", "share=1" ) dbExec( connection, "INSERT INTO names VALUES (?,?)", 4, "test2" ) local allnames = dbQuery( connection, "SELECT * FROM names") local result = dbPoll(allnames, -1) if #result ~= 0 then triggerClientEvent(p,"onStart",p,result) end end addCommandHandler("testmysql",testsql) Link to comment
Et-win Posted August 3, 2014 Share Posted August 3, 2014 Ehum, no. your Heart is So Black Again: Ehum, no. EDIT: Ow, didn't see that you already had posted your grid list. Thought you meant to let us make the whole thing. So, what's the problem with it? Link to comment
3B00DG4MER Posted August 3, 2014 Author Share Posted August 3, 2014 function testsql(p) connection = dbConnect( "mysql", "dbname=cir;host=localhost", "mtaserver", "game2020", "share=1" ) dbExec( connection, "INSERT INTO names VALUES (?,?)", 4, "test2" ) local allnames = dbQuery( connection, "SELECT * FROM names") local result = dbPoll(allnames, -1) if #result ~= 0 then triggerClientEvent(p,"onStart",p,result) end end addCommandHandler("testmysql",testsql) There is Problem i told you i want to show rows as a Gridlist yours show me Numbers in the gridlist Anyone HELP ME !!! @_@ Link to comment
Saml1er Posted August 3, 2014 Share Posted August 3, 2014 function testing( allnames ) local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) for k,v in pairs(allnames) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, v[1], false, false ) end end addEvent("onStart",true) addEventHandler("onStart",localPlayer,testing) Link to comment
3B00DG4MER Posted August 4, 2014 Author Share Posted August 4, 2014 function testing( allnames ) local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) for k,v in pairs(allnames) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, v[1], false, false ) end end addEvent("onStart",true) addEventHandler("onStart",localPlayer,testing) Near To Work But there is Error Client: Line 7: Expected string at Argument 4,got Nil Link to comment
Addlibs Posted August 4, 2014 Share Posted August 4, 2014 dbExec( connection, "CREATE TABLE names (column1 TEXT, column2 TEXT)") dbExec( connection, "INSERT INTO names (column1, column2) VALUES (?,?)", 4, "test2" ) function testing( allnames ) local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) for k,v in pairs(allnames) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, v["column2"], false, false ) end end addEvent("onStart",true) addEventHandler("onStart",localPlayer,testing) Link to comment
3B00DG4MER Posted August 4, 2014 Author Share Posted August 4, 2014 dbExec( connection, "CREATE TABLE names (column1 TEXT, column2 TEXT)") dbExec( connection, "INSERT INTO names (column1, column2) VALUES (?,?)", 4, "test2" ) function testing( allnames ) local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) for k,v in pairs(allnames) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, v["column2"], false, false ) end end addEvent("onStart",true) addEventHandler("onStart",localPlayer,testing) Ty but i fixed before you talk But anyone THANKS !! Link to comment
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