SirniNamaz Posted October 9, 2012 Share Posted October 9, 2012 (edited) client if (guiGetVisible(guiEventManager) == true) then local xmlElements = xmlLoadFile("elements.xml") for i=0,149 do local xmlOldChild = xmlFindChild(xmlElements,"element",i) local attrs = xmlNodeGetAttributes(xmlOldChild) if not (attrs == false) then guiGridListClear(grdElementsList) local newRow = guiGridListAddRow(grdElementsList) for name,value in pairs(attrs) do outputChatBox(name .. " = " .. value) if (name == "item") then if (tonumber(value) == 4) then guiGridListSetItemText(grdElementsList,newRow,colElement2,"Knife",false,false) end end if (name == "x") then guiGridListSetItemText(grdElementsList,newRow,colElement2X,value,false,false) end if (name == "y") then guiGridListSetItemText(grdElementsList,newRow,colElement2Y,value,false,false) end if (name == "z") then guiGridListSetItemText(grdElementsList,newRow,colElement2Z,value,false,false) end if (name == "left") then guiGridListSetItemText(grdElementsList,newRow,colElement2Left,value,false,false) end end end end end xml "8066072" type="weapon" item="4" x="2486.3376464844" y="-1663.841796875" z="13.335947036743" left="1"> "7858149" type="weapon" item="4" x="2469.3784179688" y="-1667.8182373047" z="13.302844047546" left="1"> the error is : Bad argument @ 'xmlNodeGetAttributes' Edited October 9, 2012 by Guest Link to comment
dzek (varez) Posted October 9, 2012 Share Posted October 9, 2012 Be patient, bumping after 1-2 hours and nagging people via PM is NOT nice, really. for i=0,149 do local xmlOldChild = xmlFindChild(xmlElements,"element",i) Why are you assuming there's always 149 elements? With your xml example you will get 147 errors about bad argument @ xmlNodeGetAttributes, because xmlFindChild returns false for them. Checking if xmlOldChild is false before doing next actions could be good idea, but even better idea would be to use xmlNodeGetChildren, which just gets all children so you don't have to guess how many of them exists. Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 there is one element, but it doesn't get returned in gridlist (i am currently ignoring the 149 errors or xmlFindChild command, but i get 150 of them, it cant even load the first one into gridlist) Link to comment
dzek (varez) Posted October 9, 2012 Share Posted October 9, 2012 im not suprised that some later code fails, when there's error 20 lines above. fix it first, THEN take care about any gui functions Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 function eventFiveSec() if (guiGetVisible(guiEventManager) == true) then local xmlElements = xmlLoadFile("elements.xml") for i=0,149 do local xmlOldChild = xmlFindChild(xmlElements,"element",i) local attrs = xmlNodeGetAttributes(xmlOldChild) if (attrs == false) then return else guiGridListClear(grdElementsList) local newRow = guiGridListAddRow(grdElementsList) for name,value in pairs(attrs) do outputChatBox(name .. " = " .. value) if (name == "item") then if (tonumber(value) == 4) then guiGridListSetItemText(grdElementsList,newRow,colElement2,"Knife",false,false) end end if (name == "x") then guiGridListSetItemText(grdElementsList,newRow,colElement2X,value,false,false) end if (name == "y") then guiGridListSetItemText(grdElementsList,newRow,colElement2Y,value,false,false) end if (name == "z") then guiGridListSetItemText(grdElementsList,newRow,colElement2Z,value,false,false) end if (name == "left") then guiGridListSetItemText(grdElementsList,newRow,colElement2Left,value,false,false) end end end end end end It now only returns one line of error, but it doesn't get exported to gridlist. Link to comment
Anderl Posted October 9, 2012 Share Posted October 9, 2012 Can't you figure out? Use the brain and interprete this knowing that "xmlOldChild" returns false: local xmlOldChild = xmlFindChild(xmlElements,"element",i) local attrs = xmlNodeGetAttributes(xmlOldChild) if (attrs == false) then return Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 i figured it out and it is just above your post on line 5-8, but my problem is that it doesnt get exported to gridlist. Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 Can i rather PM it to you, i don't want it to be stolen. Link to comment
Anderl Posted October 9, 2012 Share Posted October 9, 2012 You already showed it before, why not show again. Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 This is not the full code, this is only the part which doesn't work. Link to comment
Anderl Posted October 9, 2012 Share Posted October 9, 2012 SirniNamaz said: This is not the full code, this is only the part which doesn't work. I didn't ask for the full code, anyway. Link to comment
SirniNamaz Posted October 9, 2012 Author Share Posted October 9, 2012 I still need help with this 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