Jump to content

Xml data set to 0


freudo

Recommended Posts

hi

I Want change all clan points set to 0 with command

Exp: /cpremove

     
     
    "Number One" tag="~¨~" r="102" g="102" b="102" color="#666666" Points="4" 
    "SR" tag="[sR]" r="102" g="102" b="102" color="#666666" Points="5" 
  

  

Link to comment
function cpremoveCmd(plr, cmd, clan)  
    xml = xmlLoadFile ("clans.xml") 
    for index, childNode in pairs ( xmlNodeGetChildren (xml) ) do  
        local name  = xmlNodeGetAttribute  (childNode, "isim" ) 
        if name == clan  then 
            mlNodeSetAttribute(childNode, "Points", 0) 
            break; 
        end 
    end 
    xmlUnloadFile(xml) 
end 
addCommandHandler("cpremove", cpremoveCmd) 

Link to comment
İ want set 0 value for all clans

try this one

function cpremoveCmd(plr, cmd) 
    xml = xmlLoadFile ("clans.xml") 
    for index, childNode in pairs ( xmlNodeGetChildren (xml) ) do 
            xmlNodeSetAttribute(childNode, "Points", 0) 
            outputChatBox("Done",plr,0,255,0) 
            break; 
        end 
    xmlUnloadFile(xml) 
end 
addCommandHandler("cpremove", cpremoveCmd) 

Link to comment
İ want set 0 value for all clans

try this one

function cpremoveCmd(plr, cmd) 
    xml = xmlLoadFile ("clans.xml") 
    for index, childNode in pairs ( xmlNodeGetChildren (xml) ) do 
            xmlNodeSetAttribute(childNode, "Points", 0) 
            outputChatBox("Done",plr,0,255,0) 
            break; 
        end 
    xmlSaveFile(xml) 
    xmlUnloadFile(xml) 
end 
addCommandHandler("cpremove", cpremoveCmd) 

OMG puting the break here wil exsit the loop and only the first one will be done

so @Barikat try this code

  
function cpremoveCmd(plr, cmd) 
    xml = xmlLoadFile ("clans.xml") 
    for index, childNode in pairs ( xmlNodeGetChildren (xml) ) do 
            xmlNodeSetAttribute(childNode, "Points", 0) 
        end 
      xmlSaveFile(xml) 
    xmlUnloadFile(xml) 
end 
addCommandHandler("cpremove", cpremoveCmd) 
  

Edited by Guest
Link to comment

i forget that i always forget to save anyway thx alwa7sh :)

  
function cpremoveCmd(plr, cmd) 
    xml = xmlLoadFile ("clans.xml") 
    for index, childNode in pairs ( xmlNodeGetChildren (xml) ) do 
            xmlNodeSetAttribute(childNode, "Points", 0) 
        end 
     xmlSaveFile(xml) 
    xmlUnloadFile(xml) 
end 
addCommandHandler("cpremove", cpremoveCmd) 
  

Link to comment

I have one more question :)

How to I change my clan color change?

Client:

function renkDegstr(btn) 
    if btn == "left" then 
       local color = guiGetText(renkedit) 
       local r,g,b = getColorFromString(color) 
       triggerServerEvent("updateColor",localPlayer,{renk=color,r=r,g=g,b=b}) 
    end 
end 

Sever: Dont work

addEvent("updateColor",true) 
addEventHandler("updateColor",root, 
function(color) 
    local myClan = getAccountData(getPlayerAccount(source),"clan") 
    if myClan then 
        local xml = xmlLoadFile("clans.xml") 
        if xml then 
            for k,v in ipairs(xmlNodeGetChildren(xml)) do 
                if xmlNodeGetAttribute(v, "tag") == myClan then 
                xmlNodeSetAttribute(v,"r",color.r) 
                xmlNodeSetAttribute(v,"g",color.g) 
                xmlNodeSetAttribute(v,"b",color.b) 
                xmlNodeSetAttribute(v,"color",color.renk) 
                break 
                end 
            end 
        end 
    end 
end 
) 

Link to comment
addEvent("updateColor",true) 
addEventHandler("updateColor",root, 
function(color) 
    local myClan = getAccountData(getPlayerAccount(source),"clan") 
    if myClan then 
        local xml = xmlLoadFile("clans.xml") 
        if xml then 
            for k,v in ipairs(xmlNodeGetChildren(xml)) do 
                if xmlNodeGetAttribute(v, "tag") == myClan then 
                xmlNodeSetAttribute(v,"r",color.r) 
                xmlNodeSetAttribute(v,"g",color.g) 
                xmlNodeSetAttribute(v,"b",color.b) 
                xmlNodeSetAttribute(v,"color",color.renk) 
                break 
                end 
            end 
        xmlSaveFile(xml) 
        xmlUnloadFile(xml) 
        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...