Jump to content

Help XML


undefined

Recommended Posts

Hi guys.

Im working on the shader panel.

But i have a problem on the save player options.

When the player's xml changed, the code is not delete file and not again started the getOption function.

It's not give error on warning on debug.

Where is the problem??? :oops:

local shaders = {"radialBlur","bloom","detailWater","contrast","detail","customTiles","carPaint","damageEffect","depthField","skinMods","vehicleMods","weaponMods","adjustWeapons"} 
  
function getOption() 
    local node = xmlLoadFile("shader/settings.xml") 
    if node then 
        for k, v in ipairs(xmlNodeGetChildren(node)) do 
            local name = xmlNodeGetAttribute(v, "name") 
            local toggle = xmlNodeGetAttribute(v, "use") 
            local value = xmlNodeGetAttribute(v, "value") 
            local enable 
            if not shaders[k] == name then 
                fileDelete("shader/settings.xml") 
                getOption() 
                return 
            end 
            outputChatBox("Test") 
            if toggle == "true" then 
                enable = true 
            elseif toggle == "false" then 
                enable = false  
            end 
             
        end 
    else 
        local childs = {} 
        local node = xmlCreateFile("shader/settings.xml", "settings") 
        childs[1] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[1], "name", "radialBlur") 
            xmlNodeSetAttribute(childs[1], "use", "true") 
        childs[2] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[2], "name", "bloom") 
            xmlNodeSetAttribute(childs[2], "use", "false") 
        childs[3] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[3], "name", "detailWater") 
            xmlNodeSetAttribute(childs[3], "use", "true") 
        childs[4] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[4], "name", "contrast") 
            xmlNodeSetAttribute(childs[4], "use", "false") 
        childs[5] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[5], "name", "detail") 
            xmlNodeSetAttribute(childs[5], "use", "false") 
        childs[6] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[6], "name", "customTiles") 
            xmlNodeSetAttribute(childs[6], "use", "true") 
        childs[7] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[7], "name", "carPaint") 
            xmlNodeSetAttribute(childs[7], "use", "true") 
        childs[8] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[8], "name", "damageEffect") 
            xmlNodeSetAttribute(childs[8], "use", "true") 
        childs[9] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[9], "name", "depthField") 
            xmlNodeSetAttribute(childs[9], "use", "true") 
        childs[10] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[10], "name", "skinMods") 
            xmlNodeSetAttribute(childs[10], "use", "true") 
        childs[11] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[11], "name", "vehicleMods") 
            xmlNodeSetAttribute(childs[11], "use", "true") 
        childs[12] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[12], "name", "weaponMods") 
            xmlNodeSetAttribute(childs[12], "use", "true") 
        childs[13] = xmlCreateChild(node, "shader") 
            xmlNodeSetAttribute(childs[13], "name", "adjustWeapons") 
            xmlNodeSetAttribute(childs[13], "use", "true") 
            xmlNodeSetAttribute(childs[13], "value", "100") 
        xmlSaveFile(node) 
        xmlUnloadFile(node)  
    end 
end 
addEventHandler("onClientResourceStart", resourceRoot, getOption) 

Thnx 8):)

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