file.Read no longer works Clientside?

Has else experenced file.Read no longer working client-side?

The first prints are what I added into the file.Read function, they print as if they are successful in reading the file, but the function only returns nil.

When I do the same test server side with a file that is named and contains the exact thing that the client file does.

why not use the regular functions? never seen those methods being used before

What regular functions are you talking about?

file.Write

file.Read

I’m confused… The problem I described is with file.Read not working clientside, as I mentioned in the tittle and several times throughout my post. :v:

That’s really weird. Post the output of the following script: [lua]PrintTable( debug.getinfo( file.Open ) ); PrintTable( debug.getinfo( file.Read ) )[/lua]

Looks like lua/includes/extensions/file.lua has been modified in your server. Maybe an addon is overriding it?

I modified it myself to add in prints, so I could try and figure out why it wasn’t working.

I also searched through my entire garrysmod folder looking to see if an addon was overwriting it and I didn’t find anything.

I can’t reproduce the issue. Why is your server’s output yellow?

I use https://github.com/Metastruct/EPOE

I’m going to try reinstalling gmod and see if the problem persists.

I’m experiencing this same issue. file.Read works fine on the serverside, but if the same exact code is used on clientside it just returns nil. I’ve looked around for solutions for awhile and I’m lost at this point. Any idea what could be causing this?

Edit: Not really sure why im getting marked as late considering no resolution was ever determined for this. It would be pointless to create a new thread for the exact same issue.

I did some extra testing and it seems that the file.Read function is working correctly, but something is happening during the return process. I can modify the file.Read function to print the file content right before return line and it displays the content, however nil is the only value that will get returned by the function for some reason.

For now I am just using the same code that is used in the file.Open function and it works just fine:


local f = file.Open( filename, "rb", path )
if ( !f ) then return end
local str = f:Read( f:Size() )
f:Close()

Try



PrintTable( debug.getinfo( FindMetaTable("File").Read ) )


Running clientside:


currentline	=	-1
func	=	function: 0x02147090
isvararg	=	true
lastlinedefined	=	-1
linedefined	=	-1
namewhat	=	
nparams	=	0
nups	=	0
short_src	=	[C]
source	=	=[C]
what	=	C


Running serverside:


currentline     =       -1
func    =       function: 0xec493b18
isvararg        =       true
lastlinedefined =       -1
linedefined     =       -1
namewhat        =
nparams =       0
nups    =       0
short_src       =       [C]
source  =       =[C]
what    =       C


how about you try this



local txt = file.Read("cockacola.txt", "DATA")

print("cockacola: " .. (txt or "0"))

file.Write("cockacola.txt", "lol cockacola")

txt =  file.Read("cockacola.txt", "DATA")
print("cockacola2: " .. (txt or "0"))


try it on the client & on the server
both should print “lol cockacola”.
If they don’t, it’s broken, if they do - it was your fault. Make sure to send the console logs though.
file.Open+_R[“File”].Read + size etc. do they same thing as file.Read, so there’s no point in retyping the lines.