Jump to content

Need a help!


Scripting

Recommended Posts

Posted

Hi All,

I want ask how i can use Xml Files for Load and Save text in it.

exemple:

text1 = guiGetText(edit) 
xmlLoadFile("xml1") 

how i can save the text1 in xml file 1 and Save it and thx .

Posted

Ok my exemple that work??

the xml file:

60

60

tab

1

in client-side:

function ClientResourceStart () 
text1 = guiGetText(edit1) 
xmlRootTree = xmlLoadFile ( "userSettings.xml" ) 
if xmlRootTree then 
xmlNodeSetValue (xmlCreateChild ( xmlHudBranch, "IconSizeX"), "" .. text1 .. "" ) 
end 
addEventHandler ( "onClientResourceStart", root, ClientResourceStart ) 

Posted

Solidrsnake

I have a exemple,

if i want save the money of the players in a xml file,

server-side:

addEventHandler(onPlayerQuit,root, 
function () 
money = getPlayerMoney(source) 

how i can save the money in a one Child??!

Posted

We wont tell you how to do it, you will have to learn it yourself, if you come up with a somewhat code, we'll be able to help you.

But, like solidsnake said, you should really try something easier.

Posted

You can at least show an example, Solidsnaka:

text    = guiCreateEdit      ( 500, 500, 100, 70, '', false ); 
button  = guiCreateButton    ( 650, 500, 80, 80, 'Get', false ); 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if ( source == button ) then 
            local text1 = guiGetText ( text ); 
            local fText = xmlCreateFile ( 'test.xml', 'root' ); 
            local child = xmlCreateChild ( fText, 'myText' ); 
            xmlNodeSetValue ( child, tostring ( text1 ) ); 
            xmlSaveFile ( fText ); 
        end 
    end 
) 

This will create a edit and a button, when you press the button, it will get edit text, create a xml file with a 'root' node and create a new child 'myText' and set his text to edit text then save the file and end.

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