Jump to content

fileOpen: unable to load file.


Tekken

Recommended Posts

Hi there,

I am trying to make a script that loads text from a *.txt file but I keep getting this error, why?

addEventHandler("log", getRootElement(), function(message)
	local f = fileOpen("logs.txt");
	fileSetPos(f, fileGetSize(f));
	fileWrite(f, time().." "..message:gsub("#%x%x%x%x%x%x", "").."\r");
	fileFlush(f);
	fileClose(f);
end);

This one works.

But when I try like this

addCommandHandler("readlog", function(player)
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
        local f1 = fileOpen("logs.txt");
        if f1 then
            text1 = fileRead(f1, fileGetSize(f1));
            fileClose(f1);
        end
        triggerClientEvent(player, "show:LOGS", player, text1);
    end
end);

It doesn't and I get this warnings

fileOpen: unable to load file

Bad argument @ 'fileGetSize' [Expected scriptfile at argument 1, got boolean]

Bad argument @ 'fileRead' [Expected scriptfile at argument 1, got boolean]

Bad argument @ 'fileClose' [Expected scriptfile at argument 1, got boolean]

Hmm, if I set the readOnly propriety to fileOpen I only get the unable to load file warning.

Link to comment

Like this

[28-7-2017|9:6] (GLOBAL) Tekken: dsdsdsd
[28-7-2017|9:7] (StaffChat) Tekken : dsds
[28-7-2017|9:7] (GLOBAL) Tekken: dsd
[28-7-2017|9:7] (StaffChat) Tekken : xcx
[28-7-2017|9:8] (GLOBAL) Tekken: dsd
[28-7-2017|9:59] (GLOBAL) [Tz]Marius5: salut
[28-7-2017|10:6] (GLOBAL) [Tz]Marius5: Salut

 

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