freudo Posted May 14, 2015 Share Posted May 14, 2015 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
darhal Posted May 14, 2015 Share Posted May 14, 2015 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
freudo Posted May 15, 2015 Author Share Posted May 15, 2015 İ want set 0 value for all clans Link to comment
Walid Posted May 15, 2015 Share Posted May 15, 2015 İ 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
darhal Posted May 15, 2015 Share Posted May 15, 2015 (edited) İ 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 May 15, 2015 by Guest Link to comment
ALw7sH Posted May 15, 2015 Share Posted May 15, 2015 You have to use xmlSaveFile before unload the file Link to comment
darhal Posted May 15, 2015 Share Posted May 15, 2015 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
darhal Posted May 15, 2015 Share Posted May 15, 2015 Thx. İts working Nope you are welcome Link to comment
freudo Posted May 15, 2015 Author Share Posted May 15, 2015 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
ALw7sH Posted May 15, 2015 Share Posted May 15, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now