iPrestege Posted March 23, 2013 Share Posted March 23, 2013 (edited) Hi Guys , Is there a way to save the text in the gridlist? Using the database? Such as this as an example? xMainFunctions_ = function ( ) local Row = guiGridListAddRow(Panel.gridlist[1]) local ServerName = guiGetText(Panel.edit[1]) local ServerIP = guiGetText(Panel.edit[2]) local ServerPort = guiGetText(Panel.edit[3]) local ServerType = guiGetText(Panel.edit[4]) local theText = guiGridListGetItemText(Panel.gridlist[1],Row,1) local theTextt = guiGridListGetItemText(Panel.gridlist[1],Row,2) local theTexttt = guiGridListGetItemText(Panel.gridlist[1],Row,3) if ( source == Panel.button[4] ) then if ( ServerName ~= "" and ServerIP ~= "" and ServerPort ~= "" and ServerType ~= "" ) then guiGridListSetItemText(Panel.gridlist[1],Row,1,ServerName,false,false) guiGridListSetItemText(Panel.gridlist[1],Row,2,ServerIP,false,false) guiGridListSetItemText(Panel.gridlist[1],Row,3,ServerPort,false,false) guiGridListSetItemText(Panel.gridlist[1],Row,4,ServerType,false,false) guiGridListSetItemColor(Panel.gridlist[1],Row,1,255,255,0) guiGridListSetItemColor(Panel.gridlist[1],Row,2,255,0,0) guiGridListSetItemColor(Panel.gridlist[1],Row,3,0,255,0) guiGridListSetItemColor(Panel.gridlist[1],Row,4,0,255,255) guiSetFont(Panel.gridlist[1],Font) triggerServerEvent("Save:To:Data:Base",localPlayer,theText,theTextt,theTexttt) else outputChatBox("* There was an error check spaces !!",255,0,0,true) end end end addEventHandler("onClientGUIClick",root,xMainFunctions_) i mean there's way to save it if player quit and join again or restart the resource?even the "XML" I don't like it . I want that functions should i use it to save it use "SQL" and events that i need . Thanks Guys . Edited March 23, 2013 by Guest Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 executeSQLQuery Or: dbExec dbQuery dbPoll Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 Thank you that I need . Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 SolidSnake what's the wrong in my script : server : addEventHandler("onResourceStart", resourceRoot, function() executeSQLQuery("CREATE TABLE IF NOT EXISTS MySql (ServerName,ServerIP,ServerPort,ServerType)") end ) function setMySql(ServerName,ServerIP,ServerPort,ServerType) return executeSQLQuery("INSERT INTO `MySql` ('ServerName','ServerIP','ServerPort',ServerType') VALUES ('" .. tostring(ServerName) .. "', '" .. tostring(ServerIP) .. "', '" .. tostring(ServerPort) .. ", '" .. tostring(ServerType) .. "'')") end function SelectFromSql() local data = executeSQLQuery("SELECT * FROM MySql") if (type(data) == "table" and #data == 0) or not data then return {} else return data end end function UpDateListInSql(element) if not isElement(element) then return end local Upsql = SelectFromSql() local onClientSqlList = {} for i,UpDateSql in ipairs(Upsql) do table.insert(onClientSqlList, {ServerName = UpDateSql.ServerName, ServerIP = UpDateSql.ServerIP, ServerPort = UpDateSql.ServerPort, ServerType = UpDateSql.ServerType}) end triggerClientEvent(element,"Add",element,onClientSqlList) end addEvent("UpDateAdd", true) addEventHandler("UpDateAdd", root, function() UpDateListInSql(source) end ) addEvent("Save:To:Data:Base", true) addEventHandler("Save:To:Data:Base", root, function(ServerName,ServerIP,ServerPort,ServerType) setMySql(ServerName,ServerIP,ServerPort,ServerType) for i,players in ipairs(getElementsByType("player")) do triggerClientEvent(players,"AddTextToGridList", players,ServerName,ServerIP,ServerPort,ServerType) end end ) -- Client -- Panel = { gridlist = {}, button = {}, label = {}, edit = {}, Window = {}, } local Font = guiCreateFont("font.ttf",11) Panel.Window[1] = guiCreateWindow(37, 109, 420, 358, "==[ R|S ]==", false) guiWindowSetSizable(Panel.Window[1], false) guiSetAlpha(Panel.Window[1], 1.00) guiSetProperty(Panel.Window[1], "CaptionColour", "FFEFFF00") Panel.gridlist[1] = guiCreateGridList(9, 21, 402, 278, false, Panel.Window[1]) guiGridListAddColumn(Panel.gridlist[1], "ServerName", 0.2) guiGridListAddColumn(Panel.gridlist[1], "IP", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Port", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Type", 0.2) Panel.button[1] = guiCreateButton(11, 311, 114, 29, "R", false, Panel.Window[1]) guiSetFont(Panel.button[1], "default-bold-small") guiSetProperty(Panel.button[1], "NormalTextColour", "FF00B9FF") Panel.button[2] = guiCreateButton(154, 311, 114, 29, "Add", false, Panel.Window[1]) guiSetFont(Panel.button[2], "default-bold-small") guiSetProperty(Panel.button[2], "NormalTextColour", "FF65FF00") Panel.button[3] = guiCreateButton(308, 311, 102, 29, "Delete", false, Panel.Window[1]) guiSetFont(Panel.button[3], "default-bold-small") guiSetProperty(Panel.button[3], "NormalTextColour", "FFFF0000") Panel.Window[2] = guiCreateWindow(523, 122, 354, 390, "==[ Add New S ]==", false) guiWindowSetSizable(Panel.Window[2], false) guiSetAlpha(Panel.Window[2], 1.00) guiSetProperty(Panel.Window[2], "CaptionColour", "FF00FFA7") Panel.label[2] = guiCreateLabel(11, 34, 342, 28, "Server Name", false, Panel.Window[2]) guiSetFont(Panel.label[2], "default-bold-small") guiLabelSetColor(Panel.label[2], 255, 0, 0) ServerName = guiCreateEdit(9, 69, 338, 32, "", false, Panel.Window[2]) Panel.label[3] = guiCreateLabel(10, 112, 341, 28, "Server IP", false, Panel.Window[2]) guiSetFont(Panel.label[3], "default-bold-small") guiLabelSetColor(Panel.label[3], 251, 254, 0) ServerIP = guiCreateEdit(10, 145, 333, 32, "", false, Panel.Window[2]) Panel.label[4] = guiCreateLabel(9, 186, 315, 28, "Server Port", false, Panel.Window[2]) guiSetFont(Panel.label[4], "default-bold-small") guiLabelSetColor(Panel.label[4], 0, 209, 254) ServerPort = guiCreateEdit(10, 224, 331, 32, "", false, Panel.Window[2]) Panel.label[5] = guiCreateLabel(13, 263, 305, 28, "Server Type", false, Panel.Window[2]) guiSetFont(Panel.label[5], "default-bold-small") guiLabelSetColor(Panel.label[5], 35, 254, 0) ServerType = guiCreateEdit(10, 291, 331, 32, "", false, Panel.Window[2]) Panel.button[4] = guiCreateButton(27, 338, 290, 37, "Add Server #", false, Panel.Window[2]) guiSetFont(Panel.button[4], "default-bold-small") guiSetProperty(Panel.button[4], "NormalTextColour", "FF00A7FE") xMainFunctions_ = function ( ) if ( source == Panel.button[4] ) then if ( ServerName ~= "" and ServerIP ~= "" and ServerPort ~= "" and ServerType ~= "" ) then triggerServerEvent("Save:To:Data:Base",localPlayer,guiGetText(ServerName),guiGetText(ServerIP),guiGetText(ServerPort),guiGetText(ServerType)) else outputChatBox("* There was an error check spaces !!",255,0,0,true) end end end addEventHandler("onClientGUIClick",root,xMainFunctions_) addEvent("AddTextToGridList", true) addEventHandler("AddTextToGridList", root, function() local row = guiGridListAddRow(Panel.gridlist[1]) guiGridListSetItemText(Panel.gridlist[1], row, 1, tostring(ServerName), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 2, tostring(ServerIP), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 3, tostring(ServerPort), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 3, tostring(ServerType), false, false) guiGridListSetItemColor(Panel.gridlist[1], row, 1, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 2, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 3, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 4, 0, 255, 255) end ) addEvent("Add", true) addEventHandler("Add", root, function(onClientSqlList) guiGridListClear(Panel.gridlist[1]) for k,v in ipairs(onClientSqlList) do local row = guiGridListAddRow(Panel.gridlist[1]) guiGridListSetItemText(Panel.gridlist[1], row, 1, tostring(ServerName), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 2, tostring(ServerIP), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 3, tostring(ServerPort), false, false) guiGridListSetItemText(Panel.gridlist[1], row, 4, tostring(ServerType), false, false) guiGridListSetItemColor(Panel.gridlist[1], row, 1, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 2, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 3, 0, 255, 255) guiGridListSetItemColor(Panel.gridlist[1], row, 4, 0, 255, 255) end end ) addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("UpDateAdd", localPlayer) end ) Database queary failed near "") VALUES ("": syntax error My friend help me some what . but i need help from you guys too am new in sql . Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 executeSQLQuery ( "INSERT INTO `MySql` ( `ServerName`, `ServerIP`, `ServerPort`, `ServerType` ) VALUES ( ?, ?, ?, ? )", ServerName, ServerIP, ServerPort, ServerType ) Try that. Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 executeSQLQuery ( "INSERT INTO `MySql` ( `ServerName`, `ServerIP`, `ServerPort`, `ServerType` ) VALUES ( ?, ?, ?, ? )", ServerName, ServerIP, ServerPort, ServerType ) Try that. No error's but when i press the button that should add the text to the grid i get this in the grid : userdata: 00020626 what's the wrong | = . Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 -- client side: Panel = { gridlist = {}, button = {}, label = {}, edit = {}, Window = {}, } local Font = guiCreateFont("font.ttf",11) Panel.Window[1] = guiCreateWindow(37, 109, 420, 358, "==[ R|S ]==", false) guiWindowSetSizable(Panel.Window[1], false) guiSetAlpha(Panel.Window[1], 1.00) guiSetProperty(Panel.Window[1], "CaptionColour", "FFEFFF00") Panel.gridlist[1] = guiCreateGridList(9, 21, 402, 278, false, Panel.Window[1]) guiGridListAddColumn(Panel.gridlist[1], "ServerName", 0.2) guiGridListAddColumn(Panel.gridlist[1], "IP", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Port", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Type", 0.2) Panel.button[1] = guiCreateButton(11, 311, 114, 29, "R", false, Panel.Window[1]) guiSetFont(Panel.button[1], "default-bold-small") guiSetProperty(Panel.button[1], "NormalTextColour", "FF00B9FF") Panel.button[2] = guiCreateButton(154, 311, 114, 29, "Add", false, Panel.Window[1]) guiSetFont(Panel.button[2], "default-bold-small") guiSetProperty(Panel.button[2], "NormalTextColour", "FF65FF00") Panel.button[3] = guiCreateButton(308, 311, 102, 29, "Delete", false, Panel.Window[1]) guiSetFont(Panel.button[3], "default-bold-small") guiSetProperty(Panel.button[3], "NormalTextColour", "FFFF0000") Panel.Window[2] = guiCreateWindow(523, 122, 354, 390, "==[ Add New S ]==", false) guiWindowSetSizable(Panel.Window[2], false) guiSetAlpha(Panel.Window[2], 1.00) guiSetProperty(Panel.Window[2], "CaptionColour", "FF00FFA7") Panel.label[2] = guiCreateLabel(11, 34, 342, 28, "Server Name", false, Panel.Window[2]) guiSetFont(Panel.label[2], "default-bold-small") guiLabelSetColor(Panel.label[2], 255, 0, 0) ServerName = guiCreateEdit(9, 69, 338, 32, "", false, Panel.Window[2]) Panel.label[3] = guiCreateLabel(10, 112, 341, 28, "Server IP", false, Panel.Window[2]) guiSetFont(Panel.label[3], "default-bold-small") guiLabelSetColor(Panel.label[3], 251, 254, 0) ServerIP = guiCreateEdit(10, 145, 333, 32, "", false, Panel.Window[2]) Panel.label[4] = guiCreateLabel(9, 186, 315, 28, "Server Port", false, Panel.Window[2]) guiSetFont(Panel.label[4], "default-bold-small") guiLabelSetColor(Panel.label[4], 0, 209, 254) ServerPort = guiCreateEdit(10, 224, 331, 32, "", false, Panel.Window[2]) Panel.label[5] = guiCreateLabel(13, 263, 305, 28, "Server Type", false, Panel.Window[2]) guiSetFont(Panel.label[5], "default-bold-small") guiLabelSetColor(Panel.label[5], 35, 254, 0) ServerType = guiCreateEdit(10, 291, 331, 32, "", false, Panel.Window[2]) Panel.button[4] = guiCreateButton(27, 338, 290, 37, "Add Server #", false, Panel.Window[2]) guiSetFont(Panel.button[4], "default-bold-small") guiSetProperty(Panel.button[4], "NormalTextColour", "FF00A7FE") xMainFunctions_ = function ( ) if ( source == Panel.button[4] ) then if ( ServerName ~= "" and ServerIP ~= "" and ServerPort ~= "" and ServerType ~= "" ) then triggerServerEvent("Save:To:Data:Base",localPlayer,guiGetText(ServerName),guiGetText(ServerIP),guiGetText(ServerPort),guiGetText(ServerType)) else outputChatBox("* There was an error check spaces !!",255,0,0,true) end end end addEventHandler("onClientGUIClick",root,xMainFunctions_) addEvent ( "AddTextToGridList", true ) addEventHandler ( "AddTextToGridList", root, function ( ServerName, ServerIP, ServerPort, ServerType ) local row = guiGridListAddRow ( Panel.gridlist[1] ) guiGridListSetItemText ( Panel.gridlist[1], row, 1, tostring ( ServerName ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 2, tostring ( ServerIP ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( ServerPort ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( ServerType ), false, false ) guiGridListSetItemColor ( Panel.gridlist[1], row, 1, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 2, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 3, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 4, 0, 255, 255 ) end ) addEvent ( "Add", true ) addEventHandler ( "Add", root, function ( onClientSqlList ) guiGridListClear ( Panel.gridlist[1] ) for _, v in ipairs ( onClientSqlList ) do local row = guiGridListAddRow ( Panel.gridlist[1] ) guiGridListSetItemText ( Panel.gridlist[1], row, 1, tostring ( v.ServerName ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 2, tostring ( v.ServerIP ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( v.ServerPort ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 4, tostring ( v.ServerType ), false, false ) guiGridListSetItemColor ( Panel.gridlist[1], row, 1, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 2, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 3, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 4, 0, 255, 255 ) end end ) addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) triggerServerEvent ( "UpDateAdd", localPlayer ) end ) -- server side: addEventHandler ( "onResourceStart", resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS MySql (ServerName,ServerIP,ServerPort,ServerType)" ) end ) function setMySql ( ServerName, ServerIP, ServerPort, ServerType ) return executeSQLQuery ( "INSERT INTO `MySql` ( `ServerName`, `ServerIP`, `ServerPort`, `ServerType` ) VALUES ( ?, ?, ?, ? )", ServerName, ServerIP, ServerPort, ServerType ) end function SelectFromSql ( ) local data = executeSQLQuery ( "SELECT * FROM MySql" ) if ( type ( data ) == "table" and #data == 0) or not data then return { } else return data end end function UpDateListInSql ( element ) if ( not isElement ( element ) ) then return end local Upsql = SelectFromSql ( ) triggerClientEvent ( element, "Add", element, Upsql ) end addEvent ( "UpDateAdd", true ) addEventHandler ( "UpDateAdd", root, function ( ) UpDateListInSql ( source ) end ) addEvent ( "Save:To:Data:Base", true ) addEventHandler ( "Save:To:Data:Base", root, function ( ServerName, ServerIP, ServerPort, ServerType ) setMySql ( ServerName, ServerIP, ServerPort, ServerType ) triggerClientEvent ( root, "AddTextToGridList", root, ServerName, ServerIP, ServerPort, ServerType ) end ) Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 -- client side: Panel = { gridlist = {}, button = {}, label = {}, edit = {}, Window = {}, } local Font = guiCreateFont("font.ttf",11) Panel.Window[1] = guiCreateWindow(37, 109, 420, 358, "==[ R|S ]==", false) guiWindowSetSizable(Panel.Window[1], false) guiSetAlpha(Panel.Window[1], 1.00) guiSetProperty(Panel.Window[1], "CaptionColour", "FFEFFF00") Panel.gridlist[1] = guiCreateGridList(9, 21, 402, 278, false, Panel.Window[1]) guiGridListAddColumn(Panel.gridlist[1], "ServerName", 0.2) guiGridListAddColumn(Panel.gridlist[1], "IP", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Port", 0.2) guiGridListAddColumn(Panel.gridlist[1], "Type", 0.2) Panel.button[1] = guiCreateButton(11, 311, 114, 29, "R", false, Panel.Window[1]) guiSetFont(Panel.button[1], "default-bold-small") guiSetProperty(Panel.button[1], "NormalTextColour", "FF00B9FF") Panel.button[2] = guiCreateButton(154, 311, 114, 29, "Add", false, Panel.Window[1]) guiSetFont(Panel.button[2], "default-bold-small") guiSetProperty(Panel.button[2], "NormalTextColour", "FF65FF00") Panel.button[3] = guiCreateButton(308, 311, 102, 29, "Delete", false, Panel.Window[1]) guiSetFont(Panel.button[3], "default-bold-small") guiSetProperty(Panel.button[3], "NormalTextColour", "FFFF0000") Panel.Window[2] = guiCreateWindow(523, 122, 354, 390, "==[ Add New S ]==", false) guiWindowSetSizable(Panel.Window[2], false) guiSetAlpha(Panel.Window[2], 1.00) guiSetProperty(Panel.Window[2], "CaptionColour", "FF00FFA7") Panel.label[2] = guiCreateLabel(11, 34, 342, 28, "Server Name", false, Panel.Window[2]) guiSetFont(Panel.label[2], "default-bold-small") guiLabelSetColor(Panel.label[2], 255, 0, 0) ServerName = guiCreateEdit(9, 69, 338, 32, "", false, Panel.Window[2]) Panel.label[3] = guiCreateLabel(10, 112, 341, 28, "Server IP", false, Panel.Window[2]) guiSetFont(Panel.label[3], "default-bold-small") guiLabelSetColor(Panel.label[3], 251, 254, 0) ServerIP = guiCreateEdit(10, 145, 333, 32, "", false, Panel.Window[2]) Panel.label[4] = guiCreateLabel(9, 186, 315, 28, "Server Port", false, Panel.Window[2]) guiSetFont(Panel.label[4], "default-bold-small") guiLabelSetColor(Panel.label[4], 0, 209, 254) ServerPort = guiCreateEdit(10, 224, 331, 32, "", false, Panel.Window[2]) Panel.label[5] = guiCreateLabel(13, 263, 305, 28, "Server Type", false, Panel.Window[2]) guiSetFont(Panel.label[5], "default-bold-small") guiLabelSetColor(Panel.label[5], 35, 254, 0) ServerType = guiCreateEdit(10, 291, 331, 32, "", false, Panel.Window[2]) Panel.button[4] = guiCreateButton(27, 338, 290, 37, "Add Server #", false, Panel.Window[2]) guiSetFont(Panel.button[4], "default-bold-small") guiSetProperty(Panel.button[4], "NormalTextColour", "FF00A7FE") xMainFunctions_ = function ( ) if ( source == Panel.button[4] ) then if ( ServerName ~= "" and ServerIP ~= "" and ServerPort ~= "" and ServerType ~= "" ) then triggerServerEvent("Save:To:Data:Base",localPlayer,guiGetText(ServerName),guiGetText(ServerIP),guiGetText(ServerPort),guiGetText(ServerType)) else outputChatBox("* There was an error check spaces !!",255,0,0,true) end end end addEventHandler("onClientGUIClick",root,xMainFunctions_) addEvent ( "AddTextToGridList", true ) addEventHandler ( "AddTextToGridList", root, function ( ServerName, ServerIP, ServerPort, ServerType ) local row = guiGridListAddRow ( Panel.gridlist[1] ) guiGridListSetItemText ( Panel.gridlist[1], row, 1, tostring ( ServerName ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 2, tostring ( ServerIP ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( ServerPort ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( ServerType ), false, false ) guiGridListSetItemColor ( Panel.gridlist[1], row, 1, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 2, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 3, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 4, 0, 255, 255 ) end ) addEvent ( "Add", true ) addEventHandler ( "Add", root, function ( onClientSqlList ) guiGridListClear ( Panel.gridlist[1] ) for _, v in ipairs ( onClientSqlList ) do local row = guiGridListAddRow ( Panel.gridlist[1] ) guiGridListSetItemText ( Panel.gridlist[1], row, 1, tostring ( v.ServerName ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 2, tostring ( v.ServerIP ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 3, tostring ( v.ServerPort ), false, false ) guiGridListSetItemText ( Panel.gridlist[1], row, 4, tostring ( v.ServerType ), false, false ) guiGridListSetItemColor ( Panel.gridlist[1], row, 1, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 2, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 3, 0, 255, 255 ) guiGridListSetItemColor ( Panel.gridlist[1], row, 4, 0, 255, 255 ) end end ) addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) triggerServerEvent ( "UpDateAdd", localPlayer ) end ) -- server side: addEventHandler ( "onResourceStart", resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS MySql (ServerName,ServerIP,ServerPort,ServerType)" ) end ) function setMySql ( ServerName, ServerIP, ServerPort, ServerType ) return executeSQLQuery ( "INSERT INTO `MySql` ( `ServerName`, `ServerIP`, `ServerPort`, `ServerType` ) VALUES ( ?, ?, ?, ? )", ServerName, ServerIP, ServerPort, ServerType ) end function SelectFromSql ( ) local data = executeSQLQuery ( "SELECT * FROM MySql" ) if ( type ( data ) == "table" and #data == 0) or not data then return { } else return data end end function UpDateListInSql ( element ) if ( not isElement ( element ) ) then return end local Upsql = SelectFromSql ( ) triggerClientEvent ( element, "Add", element, Upsql ) end addEvent ( "UpDateAdd", true ) addEventHandler ( "UpDateAdd", root, function ( ) UpDateListInSql ( source ) end ) addEvent ( "Save:To:Data:Base", true ) addEventHandler ( "Save:To:Data:Base", root, function ( ServerName, ServerIP, ServerPort, ServerType ) setMySql ( ServerName, ServerIP, ServerPort, ServerType ) triggerClientEvent ( root, "AddTextToGridList", root, ServerName, ServerIP, ServerPort, ServerType ) end ) Thank You Work's Great You Are The Best SolidSnake ( ; Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 @ Solid Snake sorry for that but i have problem here : addEvent("RemoveServer", true) addEventHandler("RemoveServer", root, function(Name,IP,Port,Type) executeSQLQuery("DELETE FROM `MySql` WHERE `ServerName` = '" .. tostring(Name) .. "' AND ServerIP = '" .. tostring(IP) .. "' AND ServerPort = '" .. tostring(Port) .. " ' AND ServerType = '" .. tostring(Type) .. "'") end ) debugscript say nothing ? Client : xMainFunctions_ = function ( ) local row = guiGridListAddRow(Panel.gridlist[1]) local Name = guiGridListGetItemText(Panel.gridlist[1],row,1) local IP = guiGridListGetItemText(Panel.gridlist[1],row,2) local Port = guiGridListGetItemText(Panel.gridlist[1],row,3) local Type = guiGridListGetItemText(Panel.gridlist[1],row,4) if ( source == Panel.button[1] ) then triggerServerEvent("RedictPlayer",localPlayer,IP,Port) elseif ( source == Panel.button[2] ) then guiSetVisible(Panel.Window[1],false) guiSetVisible(Panel.Window[2],true) showCursor(true) elseif ( source == Panel.button[3] ) then triggerServerEvent("RemoveServer",localPlayer) elseif ( source == Panel.button[4] ) then if ( ServerName ~= "" and ServerIP ~= "" and ServerPort ~= "" and ServerType ~= "" ) then triggerServerEvent("Save:To:Data:Base",localPlayer,guiGetText(ServerName),guiGetText(ServerIP),guiGetText(ServerPort),guiGetText(ServerType)) guiSetVisible(Panel.Window[2],false) showCurosr(false) else outputChatBox("* There was an error check spaces !!",255,0,0,true) end end end addEventHandler("onClientGUIClick",root,xMainFunctions_) Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 triggerServerEvent("RemoveServer",localPlayer) You aren't passing the arguments. Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 triggerServerEvent("RemoveServer",localPlayer) You aren't passing the arguments. I Change it to : triggerServerEvent("RemoveServer",localPlayer,Name,IP,Port,Type) but not work not delete the text from the gridlist . Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 You aren't getting the data from the selected item, you are adding a new row. Use: guiGridListGetSelectedItem Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 This is right? local Name = guiGridListGetItemText(Panel.gridlist[1], guiGridListGetSelectedItem(Panel.gridlist[1]), 1) local IP = guiGridListGetItemText(Panel.gridlist[1], guiGridListGetSelectedItem(Panel.gridlist[1]), 2) local Port = guiGridListGetItemText(Panel.gridlist[1], guiGridListGetSelectedItem(Panel.gridlist[1]), 3) local Type = guiGridListGetItemText(Panel.gridlist[1], guiGridListGetSelectedItem(Panel.gridlist[1]), 4) because its not working too no errors Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 No, that doesn't make any sense, read about the function at the wiki. Link to comment
iPrestege Posted March 23, 2013 Author Share Posted March 23, 2013 No, that doesn't make any sense, read about the function at the wiki. Fixed Thank's SolidSnake! 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