Jump to content

Exporting data


kev|GER

Recommended Posts

Posted

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.

Posted

Do you mean you want to use that data in another resource? you could make a exported function I think.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Well, I guess you have some function to get the cash from that resource already, right?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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") 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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