Jump to content

write writeini fwrite readini read fread


Xabache

Recommended Posts

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

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

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

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

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

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