ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. fileOpen

Function

fileOpen

Server and clientFilesIdentical to MTA:SA

Opens an existing file for reading and writing (or read-only). On the server the path is relative to the resource folder and cannot leave it. On the client it first looks for the script's own files (written with fileCreate), then for <file> files sent by the server - those are read-only; ":other/file" points to another resource's file. Close the file with fileClose when done.

Syntax

file fileOpen(string filePath [, bool readOnly = false])

Arguments

filePathstring
File path.
readOnlybool, optional = false
true = read only.

Returns

A file handle, or false when the file does not exist.

Example

local file = fileOpen("log.txt")
if file then
    fileSetPos(file, fileGetSize(file))
    fileWrite(file, os.date("[%H:%M] ") .. "Start zasobu\n")
    fileClose(file)
end

See also