Jump to content

[Ayuda] Tengo dudas con el XML


DuFraN

Recommended Posts

Posted

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
Posted

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) 

Posted

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?

Posted
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)) 

  • Recently Browsing   0 members

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