kev|GER Posted September 28, 2011 Share Posted September 28, 2011 Hey there, I'm dealing with some problem that I can't solve without help. I've got a script that saves a player's cash in a xml file. In another script, I need to somehow, import the player's cash from the xml file to do an if check. Can someone help me out? The xml file looks like that: <users> <user> <SERIAL_1948D27D64A12DD19329F2D5377717E3 points="78" cash="318" ></SERIAL_1948D27D64A12DD19329F2D5377717E3> <SERIAL_2631516CC240A88B3BBD41F466C11844 "></SERIAL_2631516CC240A88B3BBD41F466C11844> <SERIAL_E9A45949A1814608ADD0C7D9F2881B03 points="130" cash="10211"></SERIAL_E9A45949A1814608ADD0C7D9F2881B03> <SERIAL_00E6645D0EDE3AE58733D9E0D8DC24E4"></SERIAL_00E6645D0EDE3AE58733D9E0D8DC24E4> </user> </users> I hope I made myself understandable. Thanks in advance. Link to comment
Castillo Posted September 28, 2011 Share Posted September 28, 2011 Do you mean you want to use that data in another resource? you could make a exported function I think. Link to comment
kev|GER Posted September 28, 2011 Author Share Posted September 28, 2011 I want to use the data 'cash' in the xml file in another resource. How can I do an exported function? Link to comment
Castillo Posted September 28, 2011 Share Posted September 28, 2011 Well, I guess you have some function to get the cash from that resource already, right? Link to comment
kev|GER Posted September 28, 2011 Author Share Posted September 28, 2011 Well, I've got this: function getPlayerCash (player) loadPlayerData (player,"cash") end Link to comment
Castillo Posted September 28, 2011 Share Posted September 28, 2011 Then, loadPlayerData is your function to get the XML cash and that. Well, you must add this line in the meta.xml: <export function="loadPlayerData" type="server" /> Then to use that function in another resource do this: exports["YOUR_RESOURCE_NAME"]:loadPlayerData (player,"cash") Link to comment
kev|GER Posted September 29, 2011 Author Share Posted September 29, 2011 Then, loadPlayerData is your function to get the XML cash and that.Well, you must add this line in the meta.xml: <export function="loadPlayerData" type="server" /> Then to use that function in another resource do this: exports["YOUR_RESOURCE_NAME"]:loadPlayerData (player,"cash") I've done this in another resource: function testt (source) pMoneyz = exports["points"]:loadPlayerData (source,"cash") outputChatBox (pMoneyz, source) end addCommandHandler ("cha", testt) But in debugscript it outputs : 'ERROR: Call: failed to call 'points:loadPlayerData' [string "?"]' Thanks in advance. Link to comment
Castillo Posted September 30, 2011 Share Posted September 30, 2011 Well, maybe you have a error in your resource or you expecified it wrong (the resource name, i.e the function name). Also check if it's started. 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