Jump to content

Destroy All Xml Teams data


freudo

Recommended Posts

Hey I have this code this code only destroy localplayer clan

I want /removeallclans Remove the all clans xml

Code:

function clanKapat() 
    local myacc = getPlayerAccount(source) 
    local kurucu = getAccountData(myacc,"clankurucu") 
    local tag = getAccountData(myacc,"clan") 
    local isim 
    for _,v in ipairs(clans) do 
        if v.tag == tag then 
            isim = v.isim 
            break 
        end 
    end 
    if tonumber(kurucu) ~= 1 then 
        outputChatBox("#31cccc* Clanı kapatmak için clan kurucusu olmalısınız.",source,255,0,true) 
    else 
        local xmlFile = xmlLoadFile("clans.xml") 
        local c = 0 
        while xmlFindChild(xmlFile,"clan",c) do 
            local node = xmlFindChild(xmlFile,"clan",c) 
            local tags = xmlNodeGetAttribute(node,"tag") 
            if tags == tag then 
                xmlDestroyNode(node) 
                break 
            end 
            c=c+1 
        end 
        xmlSaveFile(xmlFile) 
        -- 
        local p 
        for _,v in ipairs(getAccounts()) do 
            if getAccountData(v,"clan")==tag then 
                setAccountData(v,"clan","0") 
                setAccountData(v,"clankurucu","0") 
                setAccountData(v,"clanyetkili","0") 
                p = getAccountPlayer(v) 
                if p then 
                    setPlayerTeam(p,nil) 
                end 
            end 
        end 
        outputChatBox("#31cccc*#ff3333 "..tag.." "..isim.." #31ccccadlı clan kapatılmıştır.",getRootElement(),255,0,0,true) 
        for k,v in ipairs(clans) do 
            if v.tag == tag then 
                destroyElement(v.team) 
                table.remove(clans,k) 
            end 
        end 
        triggerClientEvent(source,"clanPanelCikisYap",source) 
    end 
end 
addEvent("clanKapat",true) 
addEventHandler("clanKapat",getRootElement(),clanKapat) 

Link to comment

Try using this (not tested)

function clanKapat() 
    local myacc = getPlayerAccount(source) 
    local kurucu = getAccountData(myacc,"clankurucu") 
    local tag = getAccountData(myacc,"clan") 
    local isim 
    for _,v in ipairs(clans) do 
        if v.tag == tag then 
            isim = v.isim 
            break 
        end 
    end 
    if tonumber(kurucu) ~= 1 then 
        outputChatBox("#31cccc* Clanı kapatmak için clan kurucusu olmalısınız.",source,255,0,true) 
    else 
        local xmlFile = xmlLoadFile("clans.xml") 
        local c = 0 
        while xmlFindChild(xmlFile,"clan",c) do 
            local node = xmlFindChild(xmlFile,"clan",c) 
            local tags = xmlNodeGetAttribute(node,"tag") 
            if tags == tag then 
                xmlDestroyNode(node) 
                break 
            end 
            c=c+1 
        end 
        xmlSaveFile(xmlFile) 
        xmlUnloadFile ( xmlFile ); 
        -- 
        local p 
        for _,v in ipairs(getAccounts()) do 
            if getAccountData(v,"clan")==tag then 
                setAccountData(v,"clan","0") 
                setAccountData(v,"clankurucu","0") 
                setAccountData(v,"clanyetkili","0") 
                p = getAccountPlayer(v) 
                if p then 
                    setPlayerTeam(p,nil) 
                end 
            end 
        end 
        outputChatBox("#31cccc*#ff3333 "..tag.." "..isim.." #31ccccadlı clan kapatılmıştır.",getRootElement(),255,0,0,true) 
        for k,v in ipairs(clans) do 
            if v.tag == tag then 
                destroyElement(v.team) 
                table.remove(clans,k) 
            end 
        end 
        triggerClientEvent(source,"clanPanelCikisYap",source) 
    end 
end 
addEvent("clanKapat",true) 
addEventHandler("clanKapat",getRootElement(),clanKapat) 
  
  
  
addEventHandler ( "removeallclans", root, function ( player ) 
     
    if ( not fileDelete ( "clans.xml" ) ) then  
        outputChatBox ( "Unable to delete clans.xml", player ) 
        return false; 
    end  
     
    local f = fileCreate ( "clans.xml" ); 
    fileWrite ( f, "" ); 
    fileClose ( f ); 
     
    for _, p in ipairs ( getElementsByType ( "player" ) ) do  
        local a = getPlayerAccount ( p ) 
        if ( a and not isGuestAccount ( a ) ) then  
            setAccountData(a,"clan", nil ) 
            setAccountData(a,"clankurucu", nil ) 
            setAccountData(a,"clanyetkili", nil ) 
        end  
    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...