Xabache Posted February 17, 2015 Share Posted February 17, 2015 Remember those old favorites? Golden Oldies weren't they? MTA resources seem to store all their info in SQlite, yes? In my world we used far more simple systems to write ordinary data to ordinary files... write writeini fwrite readini read & fread Did I miss this part of lua/mta? Can I simply write info to a normal .txt .ini file and store it openly where it is easy to access and control? If so, how? If not, why not--and what otherwise comes closer to IRC's ideal than MTA's encoding it into a corruptible alien language impossible to work with.... I mean SQlite Link to comment
..:D&G:.. Posted February 17, 2015 Share Posted February 17, 2015 You can save data in Xml files: https://wiki.multitheftauto.com/wiki/Xml Also, I think you can make any file you want and save data in it. https://wiki.multitheftauto.com/wiki/FileRead Link to comment
Callum Posted February 17, 2015 Share Posted February 17, 2015 An INI parser would be very simple to make using the file functions. Link to comment
Xabache Posted February 24, 2015 Author Share Posted February 24, 2015 My joinquit with the wiki for fileCreate attached. Produces no file in the resource directory. Ideas? addEventHandler('onClientPlayerJoin', root, function() outputChatBox('JOIN: ' .. getPlayerName(source) .. '', 0, 128, 255) local newFile = fileCreate("test.txt") -- attempt to create a new file if (newFile) then -- check if the creation succeeded fileWrite(newFile, "This is a test file!") -- write a text line fileClose(newFile) -- close the file once you're done with it end end ) Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 onClientPlayerJoin only works when other players join the server and not the client itself, so that's a possible problem. Also, a stupid question, but, you're checking the client resource directory and not the server one right? Link to comment
Xabache Posted February 24, 2015 Author Share Posted February 24, 2015 (edited) . Edited February 24, 2015 by Guest Link to comment
Xabache Posted February 24, 2015 Author Share Posted February 24, 2015 I was not checking the client directory. Stupid questions are the best questions. And I did find my files!!! Thanks Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 A classic mistake. You're welcome. Link to comment
Xabache Posted February 24, 2015 Author Share Posted February 24, 2015 So if these are being written to the client directory. I presume then they are being written to all client directories of all users. I would prefer it would create a single file on the server for each user that joins. How on join can i create a file on the server, in the server resource directory would be fine. Edit: And perhaps I missed this, but fileDelete appears to only clear the contents of the file. And not traditionally "Delete" the file. I would like to delete/remove/destroy the file on user part but do not see this function other than perhaps fileRename to the recycle bin? Seems like a better answer might exist. Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 A client side file can be used to save client specific data, ones that don't need to be that secure. You can't create a file on the client and save it to the server resource directory. You'll have to create the file server side. fileDelete should delete the file not just wipe it. Are you sure you are closing after deleting? Link to comment
Xabache Posted February 24, 2015 Author Share Posted February 24, 2015 Yes server-side is where i would like to create a text file for each join, and remove it on each part. I tried loading this same script that mostly works to server side but it did nothing. What events should i use server side for player join and quit. I used this client-side addEventHandler('onClientPlayerJoin', root, function() outputChatBox('JOIN: ' .. getPlayerName(source) .. '', 0, 128, 255) end ) addEventHandler('onClientPlayerQuit', root, function(reason) outputChatBox('PART: ' .. getPlayerName(source) .. ' [' .. reason .. ']', 153, 153, 255) end ) Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Just remove "Client" from the event names. onPlayerJoin and onPlayerQuit. Always look on the wiki for events and functions. Link to comment
Xabache Posted February 28, 2015 Author Share Posted February 28, 2015 and with xml... did i miss xmlNodeSetChildAttribute? Is this not possible with xml, lua or mta? Link to comment
Addlibs Posted February 28, 2015 Share Posted February 28, 2015 xmlNodeGetChildren and then xmlNodeSetAttribute 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