#Al-Ha[J]aRii Posted June 17, 2013 Share Posted June 17, 2013 (edited) how I wil use this with sql lite im suck with gridlist this is Image for the mode im trying to make it's help please. ------------------------------------- how did I wil put the player name that's one I want to know it's ! Edited June 17, 2013 by Guest Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 You can use : executeSQLQuery SQL Lite . Link to comment
blehmeh Posted June 17, 2013 Share Posted June 17, 2013 Use the newest functions: dbConnect dbQuery dbPoll dbExec dbFree Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 Use the newest functions: dbConnect dbQuery dbPoll dbExec dbFree This is my sql . Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 You can use : executeSQLQuery SQL Lite . yea I know . put my proplem how wil put the table sql into grid list . Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 You can use : executeSQLQuery SQL Lite . yea I know . put my proplem how wil put the table sql into grid list . triggerClientEvent guiGridListSetItemText Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 You can use : executeSQLQuery SQL Lite . yea I know . put my proplem how wil put the table sql into grid list . triggerClientEvent guiGridListSetItemText it's be with xml folder when I put name in him ?? Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 No, You're using sql there's no need for xml . Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 No, You're using sql there's no need for xml . is getPlayerName work because I want name put in grid list thos name's in table name = { "Alone", "BH", "KSA" } addEventHandler('onResourceStart',resourceRoot, function () local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( name)") if ( Tabel ) then outputDebugString( "Create Table xAlhajarii done") local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",name ) if ( Results == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",name) else executeSQLQuery('UPDATE `xAlhajarii` SET PlayerName =?',name) triggerClientEvent ("CallSQLPUT", getRootElement()) end end end ) Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 You're getting the results on start Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) . Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 You're getting the results on start Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) . so I wil put results in event PlayerJoin ? and take it when player open the gui window with the bindkey trigger to results ? Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 You're getting the results on start Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) . so I wil put results in event PlayerJoin ? and take it when player open the gui window with the bindkey trigger to results ? Insert the results when a player press the button and get the results when a player show a gui . Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 You're getting the results on start Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) . so I wil put results in event PlayerJoin ? and take it when player open the gui window with the bindkey trigger to results ? Insert the results when a player press the button and get the results when a player show a gui . Server : function Results() local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",getPlayerName ( name ) ) if ( Results == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",getPlayerName(name)) else executeSQLQuery('UPDATE `xAlhajarii` SET PlayerName =?',getPlayerName(name)) end end addEvent("gResults",true) addEventHandler("gResults",root,Results) ------------------------------------------------------------------------------------------------------------------ addEvent("AreYouOpen?",true) addEventHandler("AreYouOpen?",root, function() Results() end Client : name = { "Alone", "BH", "KSA" } addEventHandler("onClientGUIClick",root, function() if ( source == vote) then triggerServerEvent("gResults",gPlayer) --- i make it gPlayer for i made ( local gPlayer == getLocalPlayer() ) end end ) --------------------------------------------------------- bindKey(Key,"down", function () guiSetVisible( wnd , not guiGetVisible(wnd)) showCursor(guiGetVisible(wnd)) triggerServerEvent("AreYouOpen?",gPlayer) end end ) ? how I wil trigger table name from client to server ? Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 This is a simple on how to send/add to gridlist the content of a table: -- client side: addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) myGridList = guiCreateGridList ( 50, 50, 100, 100, false ) -- Create a GUI gridlist triggerServerEvent ( "getTableContent", localPlayer ) -- Trigger a server side event to get the data end ) addEvent ( "returnTableContent", true ) addEventHandler ( "returnTableContent", root, function ( content ) for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. guiGridListSetItemText ( myGridList, guiGridListAddRow ( myGridList ), 1, text, false, false ) -- Add it to the gridlist. end end ) -- server side: myTable = -- Define the table. { "Hello", "World" } addEvent ( "getTableContent", true ) addEventHandler ( "getTableContent", root, function ( ) triggerClientEvent ( client, "returnTableContent", client, myTable ) -- Send the 'myTable' content to the client side. end ) Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 (edited) This is a simple on how to send/add to gridlist the content of a table:-- client side: addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) myGridList = guiCreateGridList ( 50, 50, 100, 100, false ) -- Create a GUI gridlist triggerServerEvent ( "getTableContent", localPlayer ) -- Trigger a server side event to get the data end ) addEvent ( "returnTableContent", true ) addEventHandler ( "returnTableContent", root, function ( content ) for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. guiGridListSetItemText ( myGridList, guiGridListAddRow ( myGridList ), 1, text, false, false ) -- Add it to the gridlist. end end ) -- server side: myTable = -- Define the table. { "Hello", "World" } addEvent ( "getTableContent", true ) addEventHandler ( "getTableContent", root, function ( ) triggerClientEvent ( client, "returnTableContent", client, myTable ) -- Send the 'myTable' content to the client side. end ) Client : ------------------------------------------------------- addEventHandler("onClientGUIClick",root, function() if ( source == vote) then triggerServerEvent("gResults",gPlayer) --- i make it gPlayer for i made ( local gPlayer == getLocalPlayer() ) end end ) --------------------------------------------------------- local Key = "F5" bindKey(Key,"down", function () guiSetVisible( wnd , not guiGetVisible(wnd)) showCursor(guiGetVisible(wnd)) triggerServerEvent("AreYouOpen?",gPlayer) end end ) ------------------------------------------------------------- addEvent ( "returnTableContent", true ) addEventHandler ( "returnTableContent", root, function ( content ) for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. guiGridListSetItemText ( GridList, guiGridListAddRow ( GridList ), 1, text, false, false ) -- Add it to the gridlist. end end ) Server : name = { "Alone", "BH", "KSA" } addEvent ( "getTableContent", true ) addEventHandler ( "getTableContent", root, function ( ) triggerClientEvent ( client, "returnTableContent", client, name ) -- Send the 'myTable' content to the client side. end ) local root = getRootElement() addEventHandler('onResourceStart',resourceRoot, function () local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( name )") if ( Tabel ) then outputDebugString( "Create Table xAlhajarii done") end end end ) ------------------------------------------------------------------------------------------------------------ function Results() local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",getPlayerName ( name ) ) if ( Results == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",getPlayerName(name)) else executeSQLQuery('UPDATE `xAlhajarii` SET PlayerName =?',getPlayerName(name)) end end addEvent("gResults",true) addEventHandler("gResults",root,Results) ------------------------------------------------------------------------------------------------------------------ addEvent("AreYouOpen?",true) addEventHandler("AreYouOpen?",root, function() Results() end) ? Edited June 17, 2013 by Guest Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 No, you just mixed my code with yours, it's just an example, you must study it. Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 No, you just mixed my code with yours, it's just an example, you must study it. so my code all wrong ? Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 Most of it, yes. SQL Also ? I said I wil not understund lua Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 Yes, you are using column names which doesn't exist. Eg: "PlayerName", but your column is "name". Also, you are inserting for 4 columns, but your table has just one. Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 Never say i will not learn if you said that you're in the wrong section . P.S : Good tut : https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203. Link to comment
#Al-Ha[J]aRii Posted June 17, 2013 Author Share Posted June 17, 2013 Yes, you are using column names which doesn't exist.Eg: "PlayerName", but your column is "name". Also, you are inserting for 4 columns, but your table has just one. but I need just 1 column Never say i will not learn if you said that you're in the wrong section .P.S : Good tut : https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203. bro in this example there is function for sql are canceled I learn it but I can't to take column 1 just or I wil put like this ? local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( PlayerName ,? ,? )") Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 Doesn't matter it's both . addEventHandler('onResourceStart',getResourceRootElement ( getThisResource ( ) ), function ( ) executeSQLQuery ( 'CREATE TABLE IF NOT EXISTS `Like UnLike System` ( MyCoulmn[1],MyCoulmn[2],MyCoulmn[3] )' ) end ) You can add \ remove column . 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