Help with question

So, I am trying to make a log system, writing to a .txt and everything is working, and when I do !log in singleplayer it returns this.

http://puu.sh/9yzBP/5c98d6a32d.jpg

This is what I want it to do.
But when I use !log on my server it returns nothing in the console. Why will it not read the logs on a server( Note it is writing correctly on the server and everything)

Here is my code for the !log command


	elseif (string.sub(text, 1, 4) == "!log") then
		print( file.Read( "logs.txt", "data" ) )

I have tried ply:print but that did not work.


(User was banned for this post ("Undescriptive Thread Title" - Blazyd))

-snip read it wrong-

I’m going to assume the code you posted is serverside. It works in singleplayer because it counts as it’s own server. You have to do ply:ChatPrint() or something equivalent to get it to print out on the client.

Thanks for this, this does make it print in the players chat, but what about printing it just in the players console?. Also this will not print the full log It will only print the first couple of lines.

Edit: Okay I made it print clientside now using ply:sendlua, but now it is only printing the clientside logs.txt, how can I make it print the servers logs.txt? new code



function printLogs()

	print( file.Read( "logs.txt", "data" ) )

end

	elseif (string.sub(text, 1, 4) == "!log") then

		ply:SendLua( "printLogs()" )

	end


Use the PlayerSay hook, this will avoid any custom chat-tags or of the sort.

You check and see if the text is, indeed, !log and then run your function (make sure it’s serverside);

Yes, Im already using this in my code, thats not my problem my other !commands work and print to chat, and !log does work but it is reading the client side logs.txt and not the serverside one.


hook.Add( 'PlayerSay', 'callStuff', callStuff );

It just seems like your making it read logs.txt. There are two separate?

Yes because there is a logs.txt in located at data/logs.txt in my client, and there is one in my server(dedicated) also at data/logs.txt. if I use this in my server.


file.Write("logs.txt", "Start of logs 
")

It will write to my servers /data/ folder, So writing to the server works just not reading…

Again, as I said. You’re going to have to (somewhere serverside), make it so that it calls


 ply:ChatPrint(file.Read( "logs.txt", "data" ))

Although, I’m not sure what you’re trying to achieve by having it written on both the clientside and serverside.

Also, your ply:SendLua() is redundant. You can just do


print( file.Read( "logs.txt", "data" ) )

First off Lolcats is on the right track. In single player the server logs will print out blue (like your first image)

It would really help if you posted your script for us to see.
Are the logs being stored server side or client side?
What hooks are you using to append data?
So many more questions, would be easiest to just post the script.

But from what I see I would suggest looking into the net library.

Pretty much this, if you’re looking to print to their console. I don’t know how he saves stuff in his logs.txt, but looking here would be a good start.

@OP
You can add me on Steam if you want help with code.