Jump to content

Save data into a xml file


Recommended Posts

Posted

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.

Posted

You could use fileCreate functions, i find them pretty interesting.. i dont like xml tbh honest, and at a refresh of every min, you'll need something faster, where i'd suggest MTA's SQL integrated functions.

Posted
I know but it's too advanced for me.

That's why i'm trying to do it with XML functions.

Trust me, XML will only cause problems, and it isnt that hard to learn SQL compared to XML either. (I myself have hard times at XML)

If you need some help about SQL/JQery, just check this webpage, its pretty awesome. http://www.w3schools.com/

Posted

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.

Posted

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.

Posted

Trying to output every logged in player data(level, xp, rank, acl, challenges) in a xml file called"data.xml" only. And make it refresh every time a player login.

Simple :]

Posted

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.

Posted
Simple, but it will be very laggy each access and search into that database to save/load the values.

^This.

You should really use SQL.

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