AGENT_STEELMEAT Posted February 17, 2011 Share Posted February 17, 2011 Hi all. I have this script that loads locations from an XML file. Apparently, there is a bad argument at line 3 (xmlRootGetChildren) so it wont return a table, triggering another error (expected tables, got nil). server.lua function getTaxiLocations() local root = getResourceConfig("locations.xml") local taxiNodes = xmlNodeGetChildren(root) for _,node in pairs(taxiNodes) do local atributes = xmlNodeGetAttributes(node) local id = atributes.id local name = atributes.name local price = atributes.price triggerClientEvent ( source, "sendTaxiLocations", source, id, name, price) end xmlUnloadFile(root) end addEvent( "getTaxiLocations", true ) addEventHandler( "getTaxiLocations", getRootElement(), getTaxiLocations) locations.xml <root> <location id="1" name="Some random street" price="10000" posX="2049.38671875" posY="1535.5419921875" posZ="10.671875" /> </root> Any advice would be appreciated. tysm Link to comment
AGENT_STEELMEAT Posted February 17, 2011 Author Share Posted February 17, 2011 I've tried that. Link to comment
Ryder! Posted February 17, 2011 Share Posted February 17, 2011 what is the error exactly? Link to comment
AGENT_STEELMEAT Posted February 17, 2011 Author Share Posted February 17, 2011 bad argument @ 'xmlNodeGetChildren' and bad argument #1 to "pairs" (expected table, got boolean) Link to comment
Ryder! Posted February 17, 2011 Share Posted February 17, 2011 is your xml file specified in the meta.xml? Link to comment
Ryder! Posted February 17, 2011 Share Posted February 17, 2011 i dont know why it is not working is your locations.xml in the root folder of the resource? Link to comment
AGENT_STEELMEAT Posted February 17, 2011 Author Share Posted February 17, 2011 its in the same sub-folder with all the other files, but not in the actual resources directory (the meta is correct, im sure) Link to comment
Castillo Posted February 17, 2011 Share Posted February 17, 2011 John, this was working when i gave it to you o_o P.S: Get on msn when you can. Link to comment
qaisjp Posted February 17, 2011 Share Posted February 17, 2011 should be " local root = getResourceConfig("/folder1/folder2/locations.xml") " I think. Just replace the folder1 and folder2 (and so on) with your folders and subfolders. Link to comment
Ryder! Posted February 18, 2011 Share Posted February 18, 2011 post a screenshot of the folder where your files are Link to comment
Castillo Posted February 18, 2011 Share Posted February 18, 2011 That's not required, i've helped him on MSN, i guess case close. Link to comment
Ryder! Posted February 18, 2011 Share Posted February 18, 2011 ok also, you should send to the clients all the "locations" table once and not separately, it's more efficient 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