DuFraN Posted February 15, 2014 Posted February 15, 2014 Hola nuevamente, tengo un problema con esto, me da error en la linea 14 no sé por que. function datae(playerSource, command, r) Raiz = xmlCreateFile("ranking.xml"," Raiz") Sub = xmlCreateChild(Raiz, "Puntos") success = xmlNodeSetValue ( Sub, r ) xmlSaveFile(Raiz) end addCommandHandler("crear", datae) function dataer(playerSource, command, d) Raiz = xmlLoadFile("ranking.xml") wea = xmlFindChild ( Raiz, "Raiz", 0 ) optionsnode2 = xmlFindChild ( wea, "Puntos", 0 ) -- esto me da error, dice bad argument success = xmlNodeSetValue ( optionsnode2, d ) xmlSaveFile(Raiz) end addCommandHandler("num", dataer)
MTA Team 0xCiBeR Posted February 15, 2014 MTA Team Posted February 15, 2014 Postea el contenido de tu xml.
MTA Team 0xCiBeR Posted February 16, 2014 MTA Team Posted February 16, 2014 Prueba esto: function dataer(playerSource, command, d) Raizz = xmlLoadFile("ranking.xml") wea = xmlFindChild ( Raizz, "Raiz", 0 ) optionsnode2 = xmlFindChild ( wea, "Puntos", 0 ) -- esto me da error, dice bad argument success = xmlNodeSetValue ( optionsnode2, d ) xmlSaveFile(Raizz) end addCommandHandler("num", dataer)
DuFraN Posted February 16, 2014 Author Posted February 16, 2014 Ya solucione el problema, pero ahora tengo otro. local success = xmlNodeSetValue ( bus,tostring(xmlNodeGetValue(bus)+60)) Como hago para sumar?, me da este error "attemp to perform arithmetic on string value", que hice mal?
Sasu Posted February 16, 2014 Posted February 16, 2014 Ya solucione el problema, pero ahora tengo otro. local success = xmlNodeSetValue ( bus,tostring(xmlNodeGetValue(bus)+60)) Como hago para sumar?, me da este error "attemp to perform arithmetic on string value", que hice mal? xmlNodeGetValue devuelve un string por lo tanto es obvio que no puedes hacer operaciones matematicas con un string. Primero lo debes convertir en numero con tonumber, luego sumarlo y convertirlo en string con tostring. Quedaria asi: local success = xmlNodeSetValue ( bus,tostring(tonumber(xmlNodeGetValue(bus))+60))
Recommended Posts