Jump to content

Opening clientside XML


DiSaMe

Recommended Posts

Posted

For some reason I can't open clientside XML. This is part of meta.xml:

src="enex.map" />="enex.lua" type="client" />

Both files enex.map and enex.lua are successfully downloaded.

Part of enex.lua:

    local enex_file = xmlLoadFile("enex.map") 
    if enex_file then 
        setTimer(outputChatBox,2000,1,"opened file") 
    else 
        setTimer(outputChatBox,2000,1,"failed to open file") 
    end 

When I join, it writes: "failed to open file". This means that enex.map file isn't loaded! There are no errors in it. It starts with and ends with . What's wrong?

Posted
... You're trying to load a .map with a XML function... Might be the problem?

No. It's in XML format. Only file type is .map.

Posted
... You're trying to load a .map with a XML function... Might be the problem?

No. It's in XML format. Only file type is .map.

But does MTA know that? Answer: no. Every program doing this checks for the extension, before checking the contents. So although it is in XML format, MTA doesn't think so, and thus returns NIL.

You may want to wait for an expert to come online to explain more and talk about a possible solution. I only tell my own experiences and things for as far as I know.

What MIGHT help: http://development.mtasa.com/index.php?title=FileOpen

Not for configuration files... .map is no configuration, right?

Posted
... You're trying to load a .map with a XML function... Might be the problem?

No. It's in XML format. Only file type is .map.

But does MTA know that? Answer: no. Every program doing this checks for the extension, before checking the contents. So although it is in XML format, MTA doesn't think so, and thus returns NIL.

You may want to wait for an expert to come online to explain more and talk about a possible solution. I only tell my own experiences and things for as far as I know.

What MIGHT help: http://development.mtasa.com/index.php?title=FileOpen

Not for configuration files... .map is no configuration, right?

But does MTA need to know that? Answer: no. xmlLoadFile doesn't check if file extension is XML. It only checks if that file content is XML format. It just needs to find the file independently of extension. Otherwise my server-side random car placer that I put into gamemode I'm working on wouldn't work.

Posted

I don't think so. This is the content:

>    x="2229.63" y="-1721.63" z="12.6529" 2x="2229.13" 2y="-1722.13" 2z="12.6529" ang="497" int="0" />>

Or maybe I'm blind a little bit :)

edit: wait, it looks like node attributes starting with numbers are separated into numbers and letters. And not in notepad++. Maybe that's the reason?

edit2: oh, yeah, it works! Thanks for making me post the content and see what's wrong :)

Posted

no0b mistake! everyone knows an xml element or attribute can't start with a number! ;)

don't worry though, I'm sure I'll make an equally silly mistake somewhere down the line :)

Posted
no0b mistake! everyone knows an xml element or attribute can't start with a number! ;)

Lol, except for that one failed experiment I never tried XML. So I didn't know. ^^

Posted
Its a common rule that variables should not begin with numbers.... :wink:

Yeah, I know this, but I didn't think about that. But when I saw the name separated, I remembered that quickly :)

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