Jump to content

xmlLoadFile problem


met94

Recommended Posts

My server version is 1.4.0.6812

I want to use xml files to save vehicles on my server. Saving all info to xml files works fine, it generates about 34kb xml file but when I try to load it with xmlLoadFile, function fails. If I cut out like 90% of xml file, xmlLoadFile starts to work. Is there any workaround to make xmlLoadFile load big files?

Thanks.

Edit:

my xml file looks like that http://pastebin.com/ZW4z19LX

Link to comment

DayZ login.lua:

  
function createVehicleOnServerStart() 
    local vehmanager_resource = getResourceFromName("addon_vehicleManager") 
    local IsRunning = false 
    if vehmanager_resource then IsRunning = ((getResourceState(vehmanager_resource) or "none") == "running") end 
    if not vehmanager_resource or not IsRunning then 
        setTimer(createVehicleOnServerStart, 1000, 1) 
        return 
    end 
    exports.addon_vehicleManager:createVehicleOnServerStart() 
end 
addEventHandler("onResourceStart", resourceRoot, createVehicleOnServerStart) 

addon_vehicleManager server.lua:

 RootNodeCars = false 
  
function createVehicleOnServerStart() 
    if not RootNodeCars then 
        RootNodeCars = xmlLoadFile("backups/cars_backup.xml") 
        if RootNodeCars then 
            local vehicleamount = tonumber(xmlNodeGetAttribute(RootNodeCars, "vehicleamount")) 
            for index = 0, (vehicleamount-1) do 
                local wastedVehicle = false 
                local carNode = xmlFindChild(RootNodeCars, "car", index) 
                local itemsNode = xmlFindChild(carNode, "items", 0) 
                        end 
            if xmlUnloadFile(RootNodeCars) then 
                RootNodeCars = false 
            end 
        else 
            outputDebugString("Failed to load backups/cars_backup.xml") 
        end 
    end 
end 

addon_vehicleManager meta.xml:

  
<meta> 
     <info author="met94" version="1.0" name="vehicleManager" type="script" /> 
  
    <script src="server.lua" type="server"/> 
    <export function="createVehicleOnServerStart" type="server" /> 
     
</meta> 
  

I get "Failed to load backups/cars_backup.xml" in console

backups folder screen http://i61.tinypic.com/2ywwj0n.png

Edit:

Thread can be closed.

My problem was caused by setting attributes with spaces in name.

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