Jump to content

[PROBLEM]expected element, got string


iFoReX

Recommended Posts

Im starting to use XML Functions :D, 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 
) 
  

Link to comment
Required Arguments

event: 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.

Link to comment

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 

Link to comment

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.

Link to comment
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 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...