-.Paradox.- Posted May 14, 2014 Share 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. Link to comment
.:HyPeX:. Posted May 14, 2014 Share 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. Link to comment
-.Paradox.- Posted May 15, 2014 Author Share Posted May 15, 2014 I have no SQL knowledge.. Link to comment
Ab-47 Posted May 15, 2014 Share 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. Link to comment
-.Paradox.- Posted May 15, 2014 Author Share 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. Link to comment
.:HyPeX:. Posted May 15, 2014 Share 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/ Link to comment
MIKI785 Posted May 16, 2014 Share 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. Link to comment
-.Paradox.- Posted May 16, 2014 Author Share 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.. Link to comment
Snow-Man Posted May 16, 2014 Share Posted May 16, 2014 use xmlLoadFile xmlCreateFile xmlCreateChild xmlSaveFile Link to comment
-.Paradox.- Posted May 16, 2014 Author Share Posted May 16, 2014 Thanks, And how i can use getElementData exactly to get some element data of the players? Link to comment
Karuzo Posted May 16, 2014 Share Posted May 16, 2014 getElementData(player,"YourData") Simple as that. Link to comment
-.Paradox.- Posted May 16, 2014 Author Share Posted May 16, 2014 I already know that-.- The problem is where i shall locate it. Link to comment
.:HyPeX:. Posted May 16, 2014 Share 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. Link to comment
-.Paradox.- Posted May 16, 2014 Author Share 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 :] Link to comment
.:HyPeX:. Posted May 17, 2014 Share Posted May 17, 2014 Simple, but it will be very laggy each access and search into that database to save/load the values. Link to comment
-.Paradox.- Posted May 17, 2014 Author Share 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. Link to comment
.:HyPeX:. Posted May 17, 2014 Share 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. Link to comment
Karuzo Posted May 18, 2014 Share 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. Link to comment
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