iPrestege Posted April 2, 2013 Share Posted April 2, 2013 Hello guys i need some help in my script the problem when i press delete selected item the text dont deleted why not deleted that fuck text? -- server side -- addEvent("RemoveAccount", true) addEventHandler("RemoveAccount", root, function(Serial,Account,row) if executeSQLQuery("DELETE FROM `Protection_System` WHERE `Serial` = '" .. tostring(Serial) .. "' AND Account = '" .. tostring(Account) .. "'") then triggerClientEvent("RemoveAccountFromClient",root,tonumber(row)); end; end ); -- client side -- addEvent ( "RemoveAccountFromClient" , true) addEventHandler ( "RemoveAccountFromClient:" ,root, function ( id ) guiGridListRemoveRow ( GUIEditor.gridlist[1], tonumber( id ) ) end ) where do you think the problem? thank's in advance ! Link to comment
tosfera Posted April 2, 2013 Share Posted April 2, 2013 Hello guys i need some help in my script the problem when i press delete selected item the text dont deleted why not deleted that text?-- server side -- addEvent("RemoveAccount", true) addEventHandler("RemoveAccount", root, function(Serial,Account,row) if executeSQLQuery("DELETE FROM `Protection_System` WHERE `Serial` = '" .. tostring(Serial) .. "' AND Account = '" .. tostring(Account) .. "'") then triggerClientEvent("RemoveAccountFromClient",root,tonumber(row)); end; end ); -- client side -- addEvent ( "RemoveAccountFromClient" , true) addEventHandler ( "RemoveAccountFromClient:" ,root, function ( id ) guiGridListRemoveRow ( GUIEditor.gridlist[1], tonumber( id ) ) end ) where do you think the problem? thank's in advance ! Did you already try the easiest thing as a query? executeSQLQuery("DELETE FROM `Protection_System` WHERE `Serial` = ? AND Account = ?", tostring(Serial), tostring(Account) ) Link to comment
iPrestege Posted April 2, 2013 Author Share Posted April 2, 2013 Yes : executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Protection_System (Serial,Account)" ); Link to comment
tosfera Posted April 2, 2013 Share Posted April 2, 2013 Okee so the thing is, you can't remove it from your database, am I right? Okee so lets move on. You are converting both values to a string to prevert errors. Wont be wrong on that part. Can you tell me, what are these values that are placed into the Serial and Account? (Just comment the delete query and make an outputChatBox for the Serial + Account. Tell me the results.) Link to comment
iPrestege Posted April 2, 2013 Author Share Posted April 2, 2013 addEventHandler("onClientGUIClick",root, function ( ) local Serial = guiGetText(Serial) local Account = guiGetText(Account); local row = guiGridListGetSelectedItem(GUIEditor.gridlist[1]) if ( source == GUIEditor.button[1] ) then guiBringToFront(Add.Wnd); guiSetVisible(Add.Wnd,true); showCursor(true); elseif ( source == GUIEditor.button[2] ) then if ( guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == -1 ) then return outputChatBox("* Please Choose Account To Remove it!",255,0,0,true) end; triggerServerEvent("RemoveAccount",localPlayer,Serial,Account,row); elseif ( source == GUIEditor.button[3] ) then guiSetVisible(Main.Wnd,false); showCursor(false); elseif ( source == GUIEditor.button[4] ) then if ( Serial == "" or Serial == " " or Serial == " " or Account == "" or Account == " " or Account == " ") then return outputChatBox("* Check All Spaces !",255,0,0,true); end; triggerServerEvent("AddNewAccount",localPlayer,Serial,Account); guiSetVisible(Add.Wnd,false); end; end ); Link to comment
tosfera Posted April 2, 2013 Share Posted April 2, 2013 Btw, you have an overloaded method. You are requesting the account AND serial, but a serial is an unique value and bounded to a account/IP. So if you just delete the account with the serial, does that work? Link to comment
iPrestege Posted April 2, 2013 Author Share Posted April 2, 2013 I do not think this is because I've try it this way and did not succeed, but what's the problem in my script it works SolidSnake has fix it , but I do not know what's the problem now this really boring me and stop my work -_-"! Link to comment
Castillo Posted April 2, 2013 Share Posted April 2, 2013 It removes the SQL row but not the one on the gridlist? if so, post how do you trigger: "RemoveAccount". Link to comment
iPrestege Posted April 2, 2013 Author Share Posted April 2, 2013 ok full script client : GUIEditor = { gridlist = {}, button = {}, label = {}, edit = {}, } Main = {} Add = {} Main.Wnd = guiCreateWindow(393, 195, 594, 325, "Protection System Accounts ", false); guiSetVisible(Main.Wnd,false); guiWindowSetSizable(Main.Wnd, false); guiSetAlpha(Main.Wnd, 1.00); guiSetProperty(Main.Wnd, "CaptionColour", "FF00EFFF"); GUIEditor.gridlist[1] = guiCreateGridList(9, 23, 577, 233, false, Main.Wnd); guiGridListAddColumn(GUIEditor.gridlist[1], "#", 0.3); guiGridListAddColumn(GUIEditor.gridlist[1], "Account", 0.3); guiGridListAddColumn(GUIEditor.gridlist[1], "Serial", 0.3); GUIEditor.button[1] = guiCreateButton(25, 274, 124, 25, "Manage Account's", false, Main.Wnd); guiSetFont(GUIEditor.button[1], "default-bold-small"); guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF03ACFB"); GUIEditor.button[2] = guiCreateButton(226, 274, 150, 27, "Delete Selected Account", false, Main.Wnd); guiSetFont(GUIEditor.button[2], "default-bold-small"); guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFEFFE00"); GUIEditor.button[3] = guiCreateButton(493, 293, 91, 22, "Close Window", false, Main.Wnd); guiSetFont(GUIEditor.button[3], "default-bold-small"); guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFFE0000"); GUIEditor.label[1] = guiCreateLabel(421, 268, 159, 21, "Created By : Mr.Pres[T]ege", false, Main.Wnd); guiSetFont(GUIEditor.label[1], "default-bold-small"); guiLabelSetColor(GUIEditor.label[1], 41, 254, 0); Add.Wnd = guiCreateWindow(512, 327, 303, 219, "Protection System Accounts ( Add Account )", false); guiSetVisible(Add.Wnd,false); guiWindowSetSizable(Add.Wnd, false); guiSetAlpha(Add.Wnd, 1.00); guiSetProperty(Add.Wnd, "CaptionColour", "FF00B3FE"); GUIEditor.label[2] = guiCreateLabel(9, 22, 327, 25, "To Add account please full all the spaces :", false, Add.Wnd); guiSetFont(GUIEditor.label[2], "default-bold-small"); guiLabelSetColor(GUIEditor.label[2], 254, 0, 0); GUIEditor.label[3] = guiCreateLabel(7, 52, 267, 20, "The name of the account to be protected :", false, Add.Wnd); guiSetFont(GUIEditor.label[3], "default-bold-small"); guiLabelSetColor(GUIEditor.label[3], 233, 254, 0); Account = guiCreateEdit(9, 74, 266, 24, "", false, Add.Wnd); GUIEditor.label[4] = guiCreateLabel(10, 108, 267, 20, "The serial of the account to be protected :", false, Add.Wnd); guiSetFont(GUIEditor.label[4], "default-bold-small"); guiLabelSetColor(GUIEditor.label[4], 233, 254, 0); Serial = guiCreateEdit(10, 138, 266, 24, "", false, Add.Wnd); GUIEditor.button[4] = guiCreateButton(9, 173, 284, 28, "Protect the account!", false, Add.Wnd); guiSetFont(GUIEditor.button[4], "default-bold-small"); guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF66F805"); addEventHandler("onClientGUIClick",root, function ( ) local Serial = guiGetText(Serial) local Account = guiGetText(Account); local row = guiGridListGetSelectedItem(GUIEditor.gridlist[1]) if ( source == GUIEditor.button[1] ) then guiBringToFront(Add.Wnd); guiSetVisible(Add.Wnd,true); showCursor(true); elseif ( source == GUIEditor.button[2] ) then if ( guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == -1 ) then return outputChatBox("* Please Choose Account To Remove it!",255,0,0,true) end; triggerServerEvent("RemoveAccount",localPlayer,Serial,Account,row); elseif ( source == GUIEditor.button[3] ) then guiSetVisible(Main.Wnd,false); showCursor(false); elseif ( source == GUIEditor.button[4] ) then if ( Serial == "" or Serial == " " or Serial == " " or Account == "" or Account == " " or Account == " ") then return outputChatBox("* Check All Spaces !",255,0,0,true); end; triggerServerEvent("AddNewAccount",localPlayer,Serial,Account); guiSetVisible(Add.Wnd,false); end; end ); addEvent ( "AddDataSerialAccount", true ) addEventHandler ( "AddDataSerialAccount", root, function ( Serial,Account ) local row = guiGridListAddRow ( GUIEditor.gridlist[1] ) local count = guiGridListGetRowCount ( GUIEditor.gridlist[1] ) + 1 guiGridListSetItemText( GUIEditor.gridlist[1], row, 1,''..count..'-',false,false ); guiGridListSetItemText ( GUIEditor.gridlist[1], row, 3, tostring ( Serial ), false, false ); guiGridListSetItemText ( GUIEditor.gridlist[1], row, 2, tostring ( Account ), false, false ); guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 255, 255, 0 ); guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 2, 255, 0, 0 ); guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 3, 0, 255, 0 ); end ); addEvent ( "AddSerialName", true ) addEventHandler ( "AddSerialName", root, function ( onClientSqlList ) guiGridListClear ( GUIEditor.gridlist[1] ) for k, v in ipairs ( onClientSqlList ) do row = guiGridListAddRow ( GUIEditor.gridlist[1] ) guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, tostring ( ''..k..'-' ), false, false ) guiGridListSetItemText ( GUIEditor.gridlist[1], row, 3, tostring ( v.Serial ), false, false ) guiGridListSetItemText ( GUIEditor.gridlist[1], row, 2, tostring ( v.Account ), false, false ) guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 255, 255, 0 ) guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 2, 255, 0, 0 ) guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 3, 0, 255, 0 ) end end ) addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) triggerServerEvent ( "Rferesh", localPlayer ); end ); addEvent( 'LogOutSetVisible', true ) addEventHandler( 'LogOutSetVisible', root, function() if guiGetVisible(Main.Wnd) then guiSetVisible( Main.Wnd, false ); showCursor( false ); end; end ); addEvent ( "RemoveAccountFromClient" , true) addEventHandler ( "RemoveAccountFromClient:" ,root, function ( row ) guiGridListRemoveRow ( GUIEditor.gridlist[1], tonumber( row ) ) end ) bindKey("F10","down", function ( ) if getElementData(localPlayer,"isAdmin") == true then guiSetVisible(Main.Wnd,not guiGetVisible(Main.Wnd)); showCursor(not isCursorShowing()); else outputChatBox("* Access Denied!",255,0,0,true); end; end ); server : addEventHandler ( "onResourceStart", resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Protection_System (Serial,Account)" ); outputDebugString("SQL Protection_System Loaded!!",0,0,255,0,0); for i, player in ipairs( getElementsByType( 'player' ) ) do if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Console" ) ) then setElementData( player, 'isAdmin', true); else setElementData( player, 'isAdmin', nil); end end end ); function setProtection_System ( Serial,Account ) return executeSQLQuery ( "INSERT INTO `Protection_System` ( `Serial`, `Account` ) VALUES ( ?,? )", tostring(Account),tostring(Serial) ); end; function SelectFromSql ( ) local data = executeSQLQuery ( "SELECT * FROM Protection_System" ) 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, "AddSerialName", element, Upsql ); end; addEvent ( "Rferesh", true ) addEventHandler ( "Rferesh", root, function ( ) UpDateListInSql ( source ); end ) addEvent ( "AddNewAccount", true ) addEventHandler ( "AddNewAccount", root, function ( Serial,Account ) setProtection_System ( Serial,Account ); triggerClientEvent ( root, "AddDataSerialAccount", root,Serial,Account ); end ); addEvent("RemoveAccount", true) addEventHandler("RemoveAccount", root, function(Serial,Account,row) if executeSQLQuery("DELETE FROM `Protection_System` WHERE `Serial` = '" .. tostring(Serial) .. "' AND Account = '" .. tostring(Account) .. "'") then triggerClientEvent("RemoveAccountFromClient",root,tonumber(row)) end; end ) addEventHandler( 'onPlayerLogin', root, function( _, acc ) if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( "Console" ) ) then setElementData( source, 'isAdmin', true); else setElementData( source, 'isAdmin', nil); end; end ); addEventHandler( 'onPlayerLogout', root, function( _, acc ) triggerClientEvent( source,'LogOutSetVisible',root); setElementData( source, 'isAdmin', nil); end ); Can you tell me what's the problem? Link to comment
Castillo Posted April 2, 2013 Share Posted April 2, 2013 Well, the first problem is that you are getting Serial and Account values from edit boxes instead of from selected item. local Serial = guiGetText(Serial) local Account = guiGetText(Account); Do this instead: local Serial = guiGridListGetItemText ( GUIEditor.gridlist[1], row, 3 ) local Account = guiGridListGetItemText ( GUIEditor.gridlist[1], row, 2 ) triggerServerEvent("RemoveAccount",localPlayer,Serial,Account,row); And here: addEvent ( "RemoveAccountFromClient" , true) addEventHandler ( "RemoveAccountFromClient:" ,root, function ( row ) guiGridListRemoveRow ( GUIEditor.gridlist[1], tonumber( row ) ) end ) You put: "RemoveAccountFromClient:" See the: ":" ? Link to comment
iPrestege Posted April 2, 2013 Author Share Posted April 2, 2013 Well, the first problem is that you are getting Serial and Account values from edit boxes instead of from selected item. local Serial = guiGetText(Serial) local Account = guiGetText(Account); Do this instead: local Serial = guiGridListGetItemText ( GUIEditor.gridlist[1], row, 3 ) local Account = guiGridListGetItemText ( GUIEditor.gridlist[1], row, 2 ) triggerServerEvent("RemoveAccount",localPlayer,Serial,Account,row); And here: addEvent ( "RemoveAccountFromClient" , true) addEventHandler ( "RemoveAccountFromClient:" ,root, function ( row ) guiGridListRemoveRow ( GUIEditor.gridlist[1], tonumber( row ) ) end ) You put: "RemoveAccountFromClient:" See the: ":" ? Thank's work's . Link to comment
Castillo Posted April 2, 2013 Share Posted April 2, 2013 Is not for anything, it was a typo on his script. Link to comment
tosfera Posted April 2, 2013 Share Posted April 2, 2013 What is ':' for ? Its an unknown symbol for a namespace, so it wont run. If you use this; main::getCharInfo(); you'll get the function getCharInfo out of the class main 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