Jump to content

XML - Testing.


Taalasmaa

Recommended Posts

Yo,

I'm very and I mean very newbie in XML.

I can script lua very well, but I'm not ever practised XML's.

I'm just testing this:

function test2(thePlayer)
mission = xmlLoadFile("test.xml")
local newFinish = xmlCreateChild(mission, "newMission" );
x,y,z = getElementPosition(thePlayer)
xmlNodeSetAttribute( newFinish, "posX", x );
xmlNodeSetAttribute( newFinish, "posY", y );
xmlNodeSetAttribute( newFinish, "posZ", z );
end
addCommandHandler("test", test2)

Why this isn't working.

In debugscript it's giving Bad Arguement @ xmlCreateChild, Bad Arguement @ xmlNodeSetAttribute

Thanks.

Link to comment

xmlNodeSetAttribute fails because xmlCreateChild fails.

xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory?

Link to comment
xmlNodeSetAttribute fails because xmlCreateChild fails.

xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory?

test.xml is in the same directory than the script itself.

Name is test.xml

And I got the file, so far. Also I checked that test.xml doesn't have any big letters like "Test.xml"-

Link to comment

Really weird.. I added

resourceRoot = getResourceRootElement( getThisResource( ) )
addEventHandler("onResourceStart", resourceRoot,
function( )
local mission = xmlCreateFile ( "test.xml", "root" );
outputChatBox("test.xml created succesfully")
end
)

and removed old test.xml for test, but it's not EVEN creating new test.xml :o

Link to comment
This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists.
function test2()
if not xmlLoadFile( "test.xml" ) then
local mission = xmlCreateFile ( "test.xml", "root" );
local new1 = xmlCreateChild( mission, "newFinish" );
xmlSaveFile( mission );
end
end
addCommandHandler("test", test2)

Tried this too. It only Gives

<root/>

To test.xml file. It's not creating "newFinish".

Link to comment
function test2()
if not xmlLoadFile( "test.xml" ) then
local mission = xmlCreateFile ( "test.xml", "root" );
local new1 = xmlCreateChild( mission, "Car" );
vehicle = getPedOccupiedVehicle(source)
xmlNodeSetAttribute( new1, "Veh", vehicle );
xmlSaveFile( mission );
end
end
addCommandHandler("test", test2)

Okay, tried this1 too, now. It's not giving ANY errors in debugscript.. Just shows in test.xml.

And, I was in a car, lol.

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