-.Paradox.- Posted September 2, 2014 Posted September 2, 2014 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? If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
ixjf Posted September 2, 2014 Posted September 2, 2014 (edited) 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. Edited September 2, 2014 by Guest I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
-.Paradox.- Posted September 2, 2014 Author Posted September 2, 2014 Everything. Don't ever do that. Use a database management system. MTA supports the SQLite library and MySQL. Okay i won't use that, Would you please tell me what's wrong? Because i'd like to know what's wrong with it... If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
ixjf Posted September 2, 2014 Posted September 2, 2014 I edited my previous message by the time you posted this, take a look. I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
-.Paradox.- Posted September 2, 2014 Author Posted September 2, 2014 I dont quietly understand, Should it be like this? local file = fileOpen(country..".txt") fileSetPos(file, 51) fileWrite(file, "Name:"..name.." Serial:"..serial) fileClose(file) If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
Et-win Posted September 2, 2014 Posted September 2, 2014 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 ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
-.Paradox.- Posted September 2, 2014 Author Posted September 2, 2014 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 If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
Et-win Posted September 2, 2014 Posted September 2, 2014 Like I said: \n "lollollol\ntest Outputs: lollollol test ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
-.Paradox.- Posted September 2, 2014 Author Posted September 2, 2014 Like I said: \n "lollollol\ntest Outputs: lollollol test oh lol, sorry i thought that is a kind of smileys If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
ixjf Posted September 2, 2014 Posted September 2, 2014 '\n' is one of the many escape characters. I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
vx89 Posted September 2, 2014 Posted September 2, 2014 Do you really want a database, or just to log players?
MTA Team 0xCiBeR Posted September 2, 2014 MTA Team Posted September 2, 2014 I also recomend using \r since if you read it with notepad it sometimes doesn't read the \n. So, you would have to add \n\r. DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
Anubhav Posted September 2, 2014 Posted September 2, 2014 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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
xTravax Posted September 2, 2014 Posted September 2, 2014 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
Anubhav Posted September 2, 2014 Posted September 2, 2014 Wasn't it there? I think its a misunderstanding. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
-.Paradox.- Posted September 2, 2014 Author Posted September 2, 2014 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 If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
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