-.Paradox.- Posted May 14, 2014 Posted May 14, 2014 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.
.:HyPeX:. Posted May 14, 2014 Posted May 14, 2014 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.
Ab-47 Posted May 15, 2014 Posted May 15, 2014 You can start by learning https://wiki.multitheftauto.com/wiki/Se ... _functions MTA wiki provides all kinds of information relating SQL.
-.Paradox.- Posted May 15, 2014 Author Posted May 15, 2014 I know but it's too advanced for me. That's why i'm trying to do it with XML functions.
.:HyPeX:. Posted May 15, 2014 Posted May 15, 2014 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/
MIKI785 Posted May 16, 2014 Posted May 16, 2014 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.
-.Paradox.- Posted May 16, 2014 Author Posted May 16, 2014 You don't understand. I'm trying to output every logged in player's data into "data.xml" not save them and load etc..
Snow-Man Posted May 16, 2014 Posted May 16, 2014 use xmlLoadFile xmlCreateFile xmlCreateChild xmlSaveFile
-.Paradox.- Posted May 16, 2014 Author Posted May 16, 2014 Thanks, And how i can use getElementData exactly to get some element data of the players?
-.Paradox.- Posted May 16, 2014 Author Posted May 16, 2014 I already know that-.- The problem is where i shall locate it.
.:HyPeX:. Posted May 16, 2014 Posted May 16, 2014 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 But i myself cant simply explain XML since i dont handle it so well.
-.Paradox.- Posted May 16, 2014 Author Posted May 16, 2014 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 :]
.:HyPeX:. Posted May 17, 2014 Posted May 17, 2014 Simple, but it will be very laggy each access and search into that database to save/load the values.
-.Paradox.- Posted May 17, 2014 Author Posted May 17, 2014 Omg. I don't want to load them from XML. I just want output the logged in players data every 30 seconds.
.:HyPeX:. Posted May 17, 2014 Posted May 17, 2014 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.
Karuzo Posted May 18, 2014 Posted May 18, 2014 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.
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