RooT Posted November 10, 2012 Posted November 10, 2012 Hi, I have this script function loadPlayerData (player,datatype) local playerIP = getPlayerSerial (player) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. getPlayerSerial(player),0) if not (playerRootNode == false) then local playerData = xmlNodeGetAttribute (playerRootNode,datatype) if (playerData) then xmlUnloadFile (root) return playerData else xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end else local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. getPlayerSerial(player)) xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end end end end end function savePlayerData (player,datatype,newvalue) local playerIP = getPlayerSerial (player) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. getPlayerSerial(player),0) if not (playerRootNode == false) then local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue else local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. getPlayerSerial(player)) local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue end end end end end but I want have stats via login, not serial I try this, but don´t work function loadPlayerData (player,datatype) local playerIP = getAccountPlayer (player) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountPlayer(player),0) if not (playerRootNode == false) then local playerData = xmlNodeGetAttribute (playerRootNode,datatype) if (playerData) then xmlUnloadFile (root) return playerData else xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountPlayer(player)) xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end end end end end function savePlayerData (player,datatype,newvalue) local playerIP = getAccountPlayer (player) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountPlayer(player),0) if not (playerRootNode == false) then local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountPlayer(player)) local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue end end end end end Thanx for help and sorry for my bad english.
Castillo Posted November 10, 2012 Posted November 10, 2012 Topic moved to scripting. Use: getPlayerAccount getAccountName
RooT Posted November 10, 2012 Author Posted November 10, 2012 I tried this function loadPlayerData (player,account,datatype) local playerIP = getPlayerAccount (player) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountName(account),0) if not (playerRootNode == false) then local playerData = xmlNodeGetAttribute (playerRootNode,datatype) if (playerData) then xmlUnloadFile (root) return playerData else xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountName(account)) xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end end end end end function savePlayerData (player,account,datatype,newvalue) local playerIP = getPlayerAccount (thePlayer) if (playerIP) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountName(account),0) if not (playerRootNode == false) then local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountName(account)) local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue end end end end end but still don´t work. This is Spain village for me..
MIKI785 Posted November 14, 2012 Posted November 14, 2012 try: function loadPlayerData (player, datatype) local account = getPlayerAccount (player) if (account) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountName(account),0) if not (playerRootNode == false) then local playerData = xmlNodeGetAttribute (playerRootNode,datatype) if (playerData) then xmlUnloadFile (root) return playerData else xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountName(account)) xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) return 0 end end end end end function savePlayerData (player, datatype,newvalue) local account = getPlayerAccount (thePlayer) if (account) then local root = xmlLoadFile ("users.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"LOGIN_" .. getAccountName(account),0) if not (playerRootNode == false) then local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue else local playerRootNode = xmlCreateChild (usersNode,"LOGIN_" .. getAccountName(account)) local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) return newNodeValue end end end end end Don't copy and it's Ok... btw. using .xml files for this purpose is just stupid.
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