Jump to content

Help with nodes


[Griffin]

Recommended Posts

Posted

Hi, i was expirimenting with nodes with this /bank command. i want it to save the amount of money to a node with xmlNodeSetAttribute but cant seem to get it working :S

to look like this in the playname.xml

function createBankAccount ( player, commandName ) 
    cash = getPlayerMoney ( player ) 
    -- 
    playname = xmlLoadFile("playname.xml") 
    info = xmlCreateFile ( "playname.xml", "info" ) -- create the file "playname.xml" which looks like "<info/>" 
    xmlCreateSubNode ( info, "user" ) -- add a subnode <bank>, now we got "<info><user/></info>" 
    local banknode = xmlFindSubNode(playname, "user", 0) 
    xmlNodeSetAttribute(banknode, "bank", tostring(cash)) 
    --xmlNodeSetValue ( bank, tostring( cash ) ) -- change the value, "<info><bank>0</bank></info>" --do not use 
    xmlSaveFile ( info ) -- save the file 
    xmlUnloadFile( info ) -- unload it after use 
    outputChatBox ("Banking...") 
end 
addCommandHandler ("bank", createBankAccount ) 

Please help

visit weboverload.net for web hosting.

Posted

hmm no i havent. but i was using this script as a way of getting to know xml. and i need to know whats going wrong.

visit weboverload.net for web hosting.

Posted

xmlCreateSubNode returns an xmlnode, you should be using xmlNodeSetAttribute on that, not using xmlFindSubNode...

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