[MT]Tobi Posted February 7, 2008 Share Posted February 7, 2008 Hello I need help, how can I script money to Classic Deathmatch on the cdm_ls.map ! I would buy things, gut without money it doesn't go! This is what i have created: function createBankAccount ( player, commandName ) cash = getPlayerMoney ( player ) -- playname = xmlLoadFile("playname.xml") info = xmlCreateFile ( "playname.xml", "info" ) -- create the file "playname.xml" which looks like "" xmlNodeSetAttribute ( info, "user" ) -- add a subnode , now we got "" local banknode = xmlFindSubNode(playname, "user", 0) xmlNodeSetAttribute(banknode, "bank", tostring(cash)) --xmlNodeSetValue ( bank, tostring( cash ) ) -- change the value, "0" --do not use xmlSaveFile ( info ) -- save the file xmlUnloadFile( info ) -- unload it after use outputChatBox ("Banking...") end addCommandHandler ("bank", createBankAccount ) Link to comment
Mr.Hankey Posted February 7, 2008 Share Posted February 7, 2008 I would recommend to simply create the xml file in the resource folder by hand because i still cant get the xmlCreateFile function work dunno why... If you do so just create a new text file save it as playname.xml so it becomes an xml file and then write the root node in it like this: <info> </info> and save the file. Also i noticed that you tried to create a sub note with xmlNodeSetAttribute but you have to use xmlCreateSubNode. I edited your code so it should work but i neither know if i understood everything you said in the comments right nor i know if this would work because i havent got the time to test it. Edited code: function createBankAccount ( player, commandName ) local cash = getPlayerMoney ( player ) playname = xmlLoadFile("playname.xml") local banknode = xmlCreateSubNode ( playname, "user" ) -- add a subnode <user>, now we got "<info><user></info>" xmlNodeSetAttribute(banknode, "bank", tostring(cash)) -- change the value, "<info><user bank="(playerMoney)"></info>" --do not use xmlSaveFile ( playname ) -- save the file xmlUnloadFile( playname ) -- unload it after use outputChatBox ("Banking...") end addCommandHandler ("bank", createBankAccount) i tested it and it seems to work pretty good. Here's the result <info> <user bank="50"/> </info> Link to comment
[MT]Tobi Posted February 7, 2008 Author Share Posted February 7, 2008 THX for help, but can you put it in an ZIP-Archive and send me? I have made it, but when I type /bank in tha chatbox stands "Banking..." but nothing changed! I have alway no money , please help, thanks..... Link to comment
XetaQuake Posted February 7, 2008 Share Posted February 7, 2008 nice mister eXo|Mr.Hankey and [MT]Tobi can someone modifi this script, so that users can "deposit" and "withdraw" her bank account on a bank location? best with GUI It would be great when someone make a public bank resource Link to comment
50p Posted February 7, 2008 Share Posted February 7, 2008 THX for help, but can you put it in an ZIP-Archive and send me?I have made it, but when I type /bank in tha chatbox stands "Banking..." but nothing changed! I have alway no money , please help, thanks..... You'll always have 0 until you give yourself money. It saves you money to the bank instead of giving you the money from bank. Link to comment
[MT]Tobi Posted February 7, 2008 Author Share Posted February 7, 2008 yes but where is the bank? or how can i create a bank on the map, like mabako-service?! 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