Search the Community
Showing results for tags 'fileopen'.
-
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.
-
Hey, with MTA 1.5.3, the fileOpen function got a new "readOnly" argument. The default value is "false", as it always was. But for some reason, something is different now. I have a script that worked fine for month, but now it throws an error when opening a file that has been in use before. I noticed this on an mp3 file that is played by playSound, and later destroyed again. If I set the "readOnly" argument to "true", it works as it used to, except that I cannot modify the files anymore. (Which in this case I don't need) Nothing in my script changed except clients were updated to 1.5.3. Is this possibly a bug? Bonsai