[Griffin] Posted February 4, 2008 Share Posted February 4, 2008 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 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 Link to comment
Twig Posted February 4, 2008 Share Posted February 4, 2008 Have you considered using SQLite for this? it's probably better suited than an XML file. Link to comment
[Griffin] Posted February 4, 2008 Author Share Posted February 4, 2008 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. Link to comment
eAi Posted February 4, 2008 Share Posted February 4, 2008 xmlCreateSubNode returns an xmlnode, you should be using xmlNodeSetAttribute on that, not using xmlFindSubNode... Link to comment
[Griffin] Posted February 5, 2008 Author Share Posted February 5, 2008 thanks for the help 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