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.