Jump to content

file functions


-.Paradox.-

Recommended Posts

Hey guys, I currently want to save player database using file functions, and for testing i used country as test, and actually it should write a line everytime a player login but actually it just replace it, This is my code.

Server:

if fileExists(country..".txt") then 
            local file = fileOpen(country..".txt") 
            fileWrite(file, "Name:"..name.." Serial:"..serial) 
            fileClose(file) 
        else 
            local file = fileCreate(country..".txt") 
            fileWrite(file, "Name:"..name.." Serial:"..serial) 
            fileClose(file) 
        end 

What i'm doing wrong?

Link to comment
local gSize = getFileSize(file) 
fileSetPos(file, gSize) 

This will be the last character of the file. You may want to use this to start drawing on a new line: \n

fileGetSize(file) * 

It works, thanks, And there is one thing, How i can make it write a line everyplayer join in? Because currently it output like this

Name: Test Serial: 0123456789Name: Test Serial: 0123456789  

Link to comment
Did you ever save it?
  
if fileExists(country..".txt") then 
            local file = fileOpen(country..".txt") 
            fileWrite(file, "Name:"..name.." Serial:"..serial) 
            fileSave(file) 
            fileClose(file) 
        end 
  

fileSave doesnt exist

Link to comment
Did you ever save it?
  
if fileExists(country..".txt") then 
            local file = fileOpen(country..".txt") 
            fileWrite(file, "Name:"..name.." Serial:"..serial) 
            fileSave(file) 
            fileClose(file) 
        end 
  

Everything. Don't ever do that. Use a database management system. MTA supports the SQLite library and MySQL.

But just for the record, you should call fileSetPos to set the position where reads and writes will take place.

I'm not planning to save it anymore...

And your function doesn't exist

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