iFoReX Posted June 19, 2012 Posted June 19, 2012 Im starting to use XML Functions , and I want do a report GUI system XML, but I have a problem in debugging, the XML File doesnt create, and in debugscript appear triggerServerEvent bad argument 2 , expected element, got string 'the text of the Edit 1' here the codes cl-side GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(290,102,773,586,"Reportes GUI",false) GUIEditor_Label[1] = guiCreateLabel(21,39,514,21,"Bueno amigos esta GUI esta echa para que pongan sus reportes y pedidos acerca del server",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(18,66,406,22,"Tu numero de reportes es .. xmlNodeGetAttribute( reportes, \"numero\" )",false,GUIEditor_Window[1]) GUIEditor_Grid[1] = guiCreateGridList(13,100,743,417,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"#",0.1) guiGridListAddColumn(GUIEditor_Grid[1],"Motivo",0.4) guiGridListAddColumn(GUIEditor_Grid[1],"Estado",0.1) guiGridListAddColumn(GUIEditor_Grid[1],"Creador",0.3) GUIEditor_Button[1] = guiCreateButton(471,527,135,47,"Cancelar",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(610,527,135,47,"Crear nuevo reporte",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(12,522,139,55,"Leer Reporte",false,GUIEditor_Window[1]) GUIEditor_Window[2] = guiCreateWindow(445,252,493,344,"Creacion del reporte",false) GUIEditor_Label[3] = guiCreateLabel(220,32,37,18,"Motivo",false,GUIEditor_Window[2]) GUIEditor_Edit[1] = guiCreateEdit(25,59,436,31,"",false,GUIEditor_Window[2]) GUIEditor_Label[4] = guiCreateLabel(209,106,61,20,"Descripcion",false,GUIEditor_Window[2]) GUIEditor_Memo[1] = guiCreateMemo(24,139,437,125,"",false,GUIEditor_Window[2]) GUIEditor_Button[4] = guiCreateButton(333,275,121,49,"Crear !",false,GUIEditor_Window[2]) GUIEditor_Button[5] = guiCreateButton(205,275,121,49,"Cancelar",false,GUIEditor_Window[2]) GUIEditor_Window[3] = guiCreateWindow(456,228,482,353,"xmlNodeGetAttribute( reportes, 'motivo' )",false) GUIEditor_Memo[2] = guiCreateMemo(18,105,442,192,"",false,GUIEditor_Window[3]) guiMemoSetReadOnly(GUIEditor_Memo[2],true) GUIEditor_Button[6] = guiCreateButton(311,305,142,32,"Volver",false,GUIEditor_Window[3]) GUIEditor_Button[7] = guiCreateButton(169,309,131,26,"Borrar",false,GUIEditor_Window[3]) GUIEditor_Edit[3] = guiCreateEdit(20,48,436,33,"",false,GUIEditor_Window[3]) guiEditSetReadOnly(GUIEditor_Edit[3],true) guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],false) guiSetVisible(GUIEditor_Window[3],false) guiSetVisible(GUIEditor_Button[3],false) showCursor(false) addCommandHandler("reportar", function() guiSetVisible(GUIEditor_Window[1],true) showCursor(true) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[1] then guiSetVisible(GUIEditor_Window[1],false) showCursor(false) elseif source == GUIEditor_Button[2] then guiSetVisible(GUIEditor_Window[2],true) guiSetVisible(GUIEditor_Window[1],false) elseif source == GUIEditor_Button[4] then local motivo = guiGetText(GUIEditor_Edit[1]) local descripcion = guiGetText(GUIEditor_Memo[1]) local yo = getLocalPlayer() triggerServerEvent("crear:Report", motivo, descripcion, yo) elseif source == GUIEditor_Button[5] then guiSetVisible(GUIEditor_Window[1],true) guiSetVisible(GUIEditor_Window[2],false) end end ) sv-side addEvent("crear:Report",true) addEventHandler("crear:Report",root,function( motivo, descripcion, yo) local reporteXML = xmlCreateFile( ":reportGUI/reportes/"..motivo..".xml", "reporte" ) local contenido = xmlCreateChild( reporteXML, "reporte:" ) local motivoXML = xmlNodeSetAttribute( contenido, "motivoR", motivo ) local descripcionXML = xmlNodeSetAttribute( contenido, "descripcionR", descripcion ) local creadorXML = xmlNodeSetAttribute( contenido, "creadorR", getPlayerName( yo ) ) local estadoXML = xmlNodeSetAttribute( contenido, "estadoR", 'no leido' ) xmlSaveFile(reporteXML) if ( reporteXML ) then outputChatBox("Reporte Creado Exitosamente",source) end end )
Castillo Posted June 19, 2012 Posted June 19, 2012 Required Argumentsevent: The name of the event to trigger server-side. You should register this event with addEvent and add at least one event handler using addEventHandler. theElement: The element that is the source of the event. This could be another player, or if this isn't relevant, use the root element. The second argument must be a element, not a string.
Edikosh998 Posted June 19, 2012 Posted June 19, 2012 ok. Then I need use root ? or what ? ...I thought you have learnt that. rootELEMENT .... yes is an element. But perhaps you need localPlayer
iFoReX Posted June 19, 2012 Author Posted June 19, 2012 now what is bad in it ? I have bad argument in lines : 21, 22, 23, 24, 25 server-side script codes cl-side GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Grid = {} numeroR = 0 GUIEditor_Window[1] = guiCreateWindow(290,102,773,586,"Reportes GUI",false) GUIEditor_Label[1] = guiCreateLabel(21,39,514,21,"Bueno amigos esta GUI esta echa para que pongan sus reportes y pedidos acerca del server",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(18,66,406,22,"Tu numero de reportes es .. xmlNodeGetAttribute( reportes, \"numero\" )",false,GUIEditor_Window[1]) GUIEditor_Grid[1] = guiCreateGridList(13,100,743,417,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) CNumero = guiGridListAddColumn(GUIEditor_Grid[1],"#",0.1) CMotivo = guiGridListAddColumn(GUIEditor_Grid[1],"Motivo",0.4) CEstado = guiGridListAddColumn(GUIEditor_Grid[1],"Estado",0.1) CCreador = guiGridListAddColumn(GUIEditor_Grid[1],"Creador",0.3) GUIEditor_Button[1] = guiCreateButton(471,527,135,47,"Cancelar",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(610,527,135,47,"Crear nuevo reporte",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(12,522,139,55,"Leer Reporte",false,GUIEditor_Window[1]) GUIEditor_Window[2] = guiCreateWindow(445,252,493,344,"Creacion del reporte",false) GUIEditor_Label[3] = guiCreateLabel(220,32,37,18,"Motivo",false,GUIEditor_Window[2]) GUIEditor_Edit[1] = guiCreateEdit(25,59,436,31,"",false,GUIEditor_Window[2]) GUIEditor_Label[4] = guiCreateLabel(209,106,61,20,"Descripcion",false,GUIEditor_Window[2]) GUIEditor_Memo[1] = guiCreateMemo(24,139,437,125,"",false,GUIEditor_Window[2]) GUIEditor_Button[4] = guiCreateButton(333,275,121,49,"Crear !",false,GUIEditor_Window[2]) GUIEditor_Button[5] = guiCreateButton(205,275,121,49,"Cancelar",false,GUIEditor_Window[2]) GUIEditor_Window[3] = guiCreateWindow(456,228,482,353,"xmlNodeGetAttribute( reportes, 'motivo' )",false) GUIEditor_Memo[2] = guiCreateMemo(18,105,442,192,"",false,GUIEditor_Window[3]) guiMemoSetReadOnly(GUIEditor_Memo[2],true) GUIEditor_Button[6] = guiCreateButton(311,305,142,32,"Volver",false,GUIEditor_Window[3]) GUIEditor_Button[7] = guiCreateButton(169,309,131,26,"Borrar",false,GUIEditor_Window[3]) GUIEditor_Edit[3] = guiCreateEdit(20,48,436,33,"",false,GUIEditor_Window[3]) guiEditSetReadOnly(GUIEditor_Edit[3],true) guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Window[2],false) guiSetVisible(GUIEditor_Window[3],false) guiSetVisible(GUIEditor_Button[3],false) showCursor(false) addCommandHandler("reportar", function() guiSetVisible(GUIEditor_Window[1],true) showCursor(true) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[1] then guiSetVisible(GUIEditor_Window[1],false) showCursor(false) elseif source == GUIEditor_Button[2] then guiSetVisible(GUIEditor_Window[2],true) guiSetVisible(GUIEditor_Window[1],false) elseif source == GUIEditor_Button[4] then local motivo = guiGetText(GUIEditor_Edit[1]) local descripcion = guiGetText(GUIEditor_Memo[1]) local yo = getLocalPlayer() if motivo ~= '' or descripcion ~= '' then triggerServerEvent("crear:Report", localPlayer, motivo, descripcion, yo) addEventHandler("onClientGUIClick",root,crearReporte) elseif motivo == '' or descripcion == '' then outputChatBox("porfavor completa todos los espacios", yo) end elseif source == GUIEditor_Button[5] then guiSetVisible(GUIEditor_Window[1],true) guiSetVisible(GUIEditor_Window[2],false) end end ) function crearReporte() local motivo = guiGetText(GUIEditor_Edit[1]) local descripcion = guiGetText(GUIEditor_Memo[1]) if source == GUIEditor_Button[4] and motivo ~= '' and descripcion ~= '' then triggerServerEvent("crearRow", localPlayer, motivo) addEventHandler("crear:Reporte:",root, obtenerXML) end end addEvent("crear:Reporte:",true) function obtenerXML(motivoXML,creadorXML,estadoXML) if ( triggerServerEvent("crearRow", localPlayer,motivoXML,creadorXML,estadoXML) ) then local row = guiGridListAddRow( GUIEditor_Grid[1] ) local setText1 = guiGridListSetItemText(GUIEditor_Grid[1], row, CNumero, numeroR+1, false, false) local setText2 = guiGridListSetItemText(GUIEditor_Grid[1], row, CMotivo, motivoXML, false, false) local setText3 = guiGridListSetItemText(GUIEditor_Grid[1], row, CCreador, creadorXML, false, false) local setText4 = guiGridListSetItemText(GUIEditor_Grid[1], row, CEstado, estadoXML, false, false) if setText1 and setText2 and setText3 and setText4 then outputChatBox("el Row se ha creado exitosamente", getLocalPlayer()) end end end sv-side addEvent("crear:Report",true) addEventHandler("crear:Report",root,function( motivo, descripcion, yo) local reporteXML = xmlCreateFile( ":reportGUI/reportes/"..motivo..".xml", "reporte" ) local contenido = xmlCreateChild( reporteXML, "reporte:" ) local motivoXML = xmlNodeSetAttribute( contenido, "motivoR", motivo ) local descripcionXML = xmlNodeSetAttribute( contenido, "descripcionR", descripcion ) local creadorXML = xmlNodeSetAttribute( contenido, "creadorR", getPlayerName( yo ) ) local estadoXML = xmlNodeSetAttribute( contenido, "estadoR", 'no leido' ) xmlSaveFile(reporteXML) if ( reporteXML ) then outputChatBox("Reporte Creado Exitosamente, poniendolo en la lista de reportes...",source) addEventHandler("crearRow", root, crearRowF) end end ) addEvent("crearRow",true) function crearRowF(motivo) local reporte = xmlLoadFile( ":reportGUI/reportes/"..motivo..".xml") if ( reporte ) then local contenido = xmlFindChild( reporte, "reporte:" ) local motivoXML = xmlNodeGetAttribute( contenido, "motivoR" ) local descripcionXML = xmlNodeGetAttribute( contenido, "descripcionR" ) local creadorXML = xmlNodeGetAttribute( contenido, "creadorR" ) local estadoXML = xmlNodeGetAttribute( contenido, "estadoR" ) end end
Stanley Sathler Posted June 19, 2012 Posted June 19, 2012 I think that there is a mistake in line 21. You are using "reporte:". The ":" character is allowed in a node name? I do not know, but I think not.
iFoReX Posted June 19, 2012 Author Posted June 19, 2012 local contenido = xmlCreateChild( reporteXML, "reporte:" ) yeh it is with ':' local contenido = xmlFindChild( reporte, "reporte:" )
iFoReX Posted June 19, 2012 Author Posted June 19, 2012 Ok , here is it motivoTest.xml "motivoTest" descripcionR="descripcionTest" creadorR="ElMota" estadoR="no leido">
Stanley Sathler Posted June 19, 2012 Posted June 19, 2012 I think your XML sintax is wrong. Try my example: <reporte> <motivoR>motivoTest</motivoR> <descripcionR>descripcionTest</descripcionR> <creadorR>ElMota</creadoR> <estadoR>no leido</estadoR> </reporte> --Fix the function local contenido = xmlCreateChild( reporteXML, "reporte" ) ---- @EDIT Your XML was made automatically by your script. So, I think my example will not return good results.
iFoReX Posted June 19, 2012 Author Posted June 19, 2012 now I have bad arguments in 4-5-6-7-8-9 lines XML, ( the child and attributes lines )
Castillo Posted June 19, 2012 Posted June 19, 2012 addEvent("crear:Report",true) addEventHandler("crear:Report",root,function( motivo, descripcion, yo) local reporteXML = xmlCreateFile( ":reportGUI/reportes/"..motivo..".xml", "reporte" ) local contenido = xmlCreateChild( reporteXML, "reporte" ) local motivoXML = xmlNodeSetAttribute( contenido, "motivoR", motivo ) local descripcionXML = xmlNodeSetAttribute( contenido, "descripcionR", descripcion ) local creadorXML = xmlNodeSetAttribute( contenido, "creadorR", getPlayerName( yo ) ) local estadoXML = xmlNodeSetAttribute( contenido, "estadoR", 'no leido' ) xmlSaveFile(reporteXML) if ( reporteXML ) then outputChatBox("Reporte Creado Exitosamente, poniendolo en la lista de reportes...",source) addEventHandler("crearRow", root, crearRowF) end end ) addEvent("crearRow",true) function crearRowF(motivo) local reporte = xmlLoadFile( ":reportGUI/reportes/"..motivo..".xml") if ( reporte ) then local contenido = xmlFindChild( reporte, "reporte" ) local motivoXML = xmlNodeGetAttribute( contenido, "motivoR" ) local descripcionXML = xmlNodeGetAttribute( contenido, "descripcionR" ) local creadorXML = xmlNodeGetAttribute( contenido, "creadorR" ) local estadoXML = xmlNodeGetAttribute( contenido, "estadoR" ) end end
Stanley Sathler Posted June 19, 2012 Posted June 19, 2012 local contenido = xmlCreateChild( reporteXML, "reporte" ) Try put it on your line 4 (without the ":" character). ---- @EDIT Solidsnake already posted. Sorry, I had not read.
iFoReX Posted June 20, 2012 Author Posted June 20, 2012 solid bad argument lines 21,22,23,24,25 sv-side
iFoReX Posted June 20, 2012 Author Posted June 20, 2012 "BryaaanLOL usa hack" descripcionR="bueno amigos BryaanLOL usa hack." creadorR="ElMota" estadoR="no leido"> it name is a random name for the motivoR
Kenix Posted June 20, 2012 Posted June 20, 2012 xmlFindChild( reporte, "reporte" ) It's wrong. ( Line 21 ) Should be local contenido = xmlFindChild( reporte, "reporte", 0 )
Castillo Posted June 20, 2012 Posted June 20, 2012 Yeah, that's right, I guess I was too sleepy when did it.
iFoReX Posted June 22, 2012 Author Posted June 22, 2012 I dont have problem in debugscript 3, but the report doesnt create in the gridList :c
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