Jump to content

xmlCreateFile


Woovie

Recommended Posts

My code

function createBankAccount ( player, commandName, playname ) 
cash = getPlayerMoney ( player ) 
xmlCreateFile ( playname.xml, info ) 
xmlCreateSubNode ( info, bank ) 
xmlSaveFile ( info ) 
outputChatBox ("BANK SOON ?") 
xmlNodeSetValue ( bank, 0 ) 
end 
addCommandHandler ("cba", createBankAccount ) 

I did "/cba woovie" as a command and received this.

It does say "BANK SOON ?" though. Once it hits the XML stuff none of it works...

[17:40:08] WARNING: bank.lua: Bad argument @ 'xmlCreateFile' - Line: 3

[17:40:08] WARNING: bank.lua: Bad argument @ 'xmlCreateSubNode' - Line: 4

[17:40:08] WARNING: bank.lua: Bad argument @ 'xmlSaveFile' - Line: 5

[17:40:08] WARNING: bank.lua: Bad argument @ 'xmlNodeSetValue' - Line: 7

Link to comment
function createBankAccount ( player, commandName, playname ) 
    cash = getPlayerMoney ( player ) 
    -- 
    info = xmlCreateFile ( "playname.xml", "info" ) -- create the file "playname.xml" which looks like "<info/>" 
    xmlCreateSubNode ( info, "bank" ) -- add a subnode <bank>, now we got "<info><bank/></info>" 
    xmlNodeSetValue ( bank, 0 ) -- change the value, "<info><bank>0</bank></info>" 
    xmlSaveFile ( info ) -- save the file 
    xmlUnloadFile( info ) -- unload it after use 
    outputChatBox ("BANK SOON ?") 
end 
addCommandHandler ("cba", createBankAccount ) 

cba = can't be arsed :')

I should have an idea what I'm doing with XML at least, my houseeditor for pen1:legends is based on XML, so are my accounts files... etc.

Link to comment
function createBankAccount ( player, commandName, playname ) 
    cash = getPlayerMoney ( player ) 
    -- 
    infofile = xmlCreateFile ( "playname.xml", "info" ) -- create the file "playname.xml" which looks like "" 
    banknode = xmlCreateSubNode ( infofile, "bank" ) -- add a subnode , now we got "" 
    xmlNodeSetValue ( banknode, 0 ) -- change the value, "0" 
    xmlSaveFile ( infofile ) -- save the file 
    xmlUnloadFile( infofile ) -- unload it after use 
    outputChatBox ("BANK SOON ?") 
end 
addCommandHandler ("cba", createBankAccount ) 

Does the work?

Link to comment

ah I see

change

xmlCreateSubNode ( info, "bank" ) -- add a subnode <bank>, now we got "<info><bank/></info>" 
xmlNodeSetValue ( bank, 0 ) -- change the value, "<info><bank>0</bank></info>" 

to

local subnode = xmlCreateSubNode ( info, "bank" ) -- add a subnode <bank>, now we got "<info><bank/></info>" 
  
xmlNodeSetValue ( subnode, 0 ) -- change the value, "<info><bank>0</bank></info>" 

Link to comment

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