Jump to content

fileWrite doesn't work


JeViCo

Recommended Posts

Posted

Hi guys!

I've recently tried to change file client-side however i got none.

meta.xml:

<meta>
    <script src="client.Lua" type="client" />
    <file src="testfile.txt" />
</meta>

testfile.txt (server-side):

sometext
here

client.Lua:

local file = fileOpen('testfile.txt')
fileClear(file) -- clear file
local content = 'some new text'
fileWrite(file, content)
print(#content) -- got 13
print(#fileRead(file, fileGetSize(file))) -- always get 0
fileClose(file)

acl.xml has resource.* permission and debug doesn't give any hints

any ideas??

 

 

i used this function (same happens if a recreate file)

 

Posted

Try this:

local file = fileOpen('testfile.txt')
fileClear(file) -- clear file
local content = 'some new text'
fileWrite(file, content)
print(#content) -- got 13
local fileContent = fileRead(file, fileGetSize(file)) 
fileClose(file)
print(#fileContent)

 

 

 

  • Moderators
Posted

@JeViCo

There is nothing written on that file yet, not until the ? is finished. That poor creature needs a toilet and fast.

https://wiki.multitheftauto.com/wiki/FileFlush

  • Like 1
  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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