#Al-Ha[J]aRii Posted June 17, 2013 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
blehmeh Posted June 17, 2013 Posted June 17, 2013 Use the newest functions: dbConnect dbQuery dbPoll dbExec dbFree
iPrestege Posted June 17, 2013 Posted June 17, 2013 Use the newest functions: dbConnect dbQuery dbPoll dbExec dbFree This is my sql .
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 .
iPrestege Posted June 17, 2013 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
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 ??
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 )
iPrestege Posted June 17, 2013 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 ) .
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 ?
iPrestege Posted June 17, 2013 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 .
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 ?
Castillo Posted June 17, 2013 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 )
#Al-Ha[J]aRii Posted June 17, 2013 Author 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
Castillo Posted June 17, 2013 Posted June 17, 2013 No, you just mixed my code with yours, it's just an example, you must study it.
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 ?
#Al-Ha[J]aRii Posted June 17, 2013 Author Posted June 17, 2013 Most of it, yes. SQL Also ? I said I wil not understund lua
Castillo Posted June 17, 2013 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.
iPrestege Posted June 17, 2013 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.
#Al-Ha[J]aRii Posted June 17, 2013 Author 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 ,? ,? )")
iPrestege Posted June 17, 2013 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 .
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