amine2 Posted June 30, 2022 Share Posted June 30, 2022 I have an error while trying to open my file. I have an script that will save your text and when you type "/write" h the script will type what you save. This is the script: function save(command, text) local myFile = fileCreate(myPath) fileOpen(myPath) fileWrite ( myFile, text ) fileClose(myFile) end addCommandHandler("save", save) function writeSaved() local myFile2 = fileOpen(myPath) size = fileGetSize(myFile2) savedText = fileRead ( myFile2, size ) outputChatBox(savedText) fileClose(myFile2) end addCommandHandler("write", writeSaved) I forgot to tell you in the start i put: myPath = "test.txt" Link to comment
AngelAlpha Posted June 30, 2022 Share Posted June 30, 2022 2 hours ago, amine2 said: I have an error while trying to open my file. I have an script that will save your text and when you type "/write" h the script will type what you save. This is the script: function save(command, text) local myFile = fileCreate(myPath) fileOpen(myPath) fileWrite ( myFile, text ) fileClose(myFile) end addCommandHandler("save", save) function writeSaved() local myFile2 = fileOpen(myPath) size = fileGetSize(myFile2) savedText = fileRead ( myFile2, size ) outputChatBox(savedText) fileClose(myFile2) end addCommandHandler("write", writeSaved) I forgot to tell you in the start i put: myPath = "test.txt" function save(command, text) local myFile = fileExists(myPath) and fileOpen(myPath) or fileCreate(myPath) fileOpen(myPath) fileWrite ( myFile, text ) fileClose(myFile) end addCommandHandler("save", save) function writeSaved() local myFile2 = fileExists(myPath) and fileOpen(myPath) or fileCreate(myPath) size = fileGetSize(myFile2) savedText = fileRead ( myFile2, size ) outputChatBox(savedText) fileClose(myFile2) end addCommandHandler("write", writeSaved) 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