Jump to content

Help xml refresh clans


freudo

Recommended Posts

I need help

283. line : destroyElement(v.team)

MSJd33M.png

function refreshClans() 
    if #clans>0 then 
        for _,v in ipairs(clans) do 
            destroyElement(v.team) 
        end 
    end 
    clans = {} 
    local xmlClan = xmlLoadFile("clans.xml") 
    local c = 0 
    local child 
    local tag,isim,r,g,b,team 
    while xmlFindChild(xmlClan,"clan",c) do 
        child = xmlFindChild(xmlClan,"clan",c) 
        tag = xmlNodeGetAttribute(child,"tag") 
        isim = xmlNodeGetAttribute(child,"isim") 
        r = xmlNodeGetAttribute(child,"r") 
        g = xmlNodeGetAttribute(child,"g") 
        b = xmlNodeGetAttribute(child,"b") 
        team = createTeam(tostring(isim),tonumber(r),tonumber(g),tonumber(b)) 
        table.insert ( clans,{["tag"]=tostring(tag),["isim"]=tostring(isim),["r"]=tonumber(r),["g"]=tonumber(g),["b"]=tonumber(b),["team"]=team}) 
        c=c+1 
    end 
    local acc 
    for _,v in ipairs(clans) do 
        for _,player in ipairs(getElementsByType("player")) do 
            acc = getPlayerAccount(player) 
            if not isGuestAccount(acc) then 
                if getAccountData(acc,"clan") == v.tag then 
                    setPlayerTeam(player,v.team) 
                end 
            end 
        end 
    end 
    local count=0 
    for _,v in ipairs(clans) do 
        count=0 
        for _,z in ipairs(getElementsByType("player")) do 
            if not isGuestAccount(getPlayerAccount(z))  then 
                if tostring(getAccountData(getPlayerAccount(z),"clan")) == tostring(v.tag) then 
                    count=1 
                    break 
                end 
            end 
        end 
        if count ~= 1 then 
            destroyElement(v.team) 
        end 
        count=0 
    end 
end 

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