Jump to content

Save data into a xml file


Recommended Posts

Hello guys, Can somebody how i can use XML Functions to save players in a xml file like example"data.xml" and in that file it should output the nick and some element data's(from my choice) everytime the player login or join.

Thanks in advance.

P.S:It would be cool if there is a function to refresh the xml file data's every minute.

Link to comment

They are right, do it through SQL because XML isnt fast enough. If you have small server with few players.. maybe. I had it done thru XML as well at the start but when the number of accounts was about 1000 it started to lag.. and every time it had to load/save XML it lagged as hell.. so i went for MySQL.. today i have about 10k accounts in there and no lags at all. XML is just not supposed to be used fpr databases but more like config files.

Link to comment

I know you're good at scripting, could you show us some small part of the code so we get what you actually want to do? Or if you're going to start one, please specify a little better how you want to use/save the element data :D

But i myself cant simply explain XML since i dont handle it so well.

Link to comment

You need to load the file to edit it, it doesnt matter if you take values out from it or not.

I'd suggest you using down fileCreate functions for this instead. Check at how i managed to save registers down:

  
function onPlayerGuiRegister(user,pass) 
local result = addAccount(user, pass) 
if result == false then 
triggerClientEvent(source, "onClientGuiClickReturn", source, "Register", "false") 
else 
triggerClientEvent(source, "onClientGuiClickReturn", source, "Register", "true") 
if not fileExists("accounts.txt") then 
MyFile = fileCreate("accounts.txt") 
FileLength = fileGetSize(MyFile) 
fileSetPos(MyFile, FileLength) 
fileWrite(MyFile, "\n | Player: '"..getPlayerName(source).."' :^: User: "..user.."' :^: Pass: '"..pass.."' |") 
fileClose(MyFile) 
else 
MyFile = fileOpen("accounts.txt") 
FileLength = fileGetSize(MyFile) 
fileSetPos(MyFile, FileLength) 
fileWrite(MyFile, "\n | Player: '"..getPlayerName(source).."' :^: User: '"..user.."' :^: Pass: '"..pass.."' |") 
fileClose(MyFile) 
end 
end 
end 
addEvent("onGuiPlayerRegister", true) 
addEventHandler("onGuiPlayerRegister", root, onPlayerGuiRegister) 

You could edit this down easily and use it.

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...