Geting players Name's

So i am making some thing for my server and i need the server to get the players names
and i need it to write all the players names down in a text doc and later on i will make it in to a multi use doc.

The problem is that the server is not writing or making a doc for the names to go in.

init.lua
[lua]
function GetNames()
net.Start(“GetName”)
net.Broadcast()
end

                  net.Receive("SendName",function()
			if file.Exists("PlayerData.txt") then
				file.Append("PlayerData.txt",net.ReadString(ply))
				MsgC(Color( 255, 0, 0 )"Server is writen PlayerData")
			else
				file.Write("PlayerData.txt",net.ReadString(ply))
				MsgC(Color( 255, 0, 0 )"Server writen PlayerData")
			end
		end)

[/lua]

cl.init.lua
[lua]
function SendName()
print(“SendName active”)
net.Receive(“GetName”,function(ply)
net.Start(“SendName”)
net.WriteString(ply)
net.SendToServer()
end)
end
[/lua]

he first argument in net.Receive is message length, which is a number and not the player entity, which goes second (i.e function(len,ply))

You also don’t have any arguments at all in the serverside net.Recieve so ply is most likely nil. Also ply in that context would be an entity, but you’re trying to send it as a string, so do ply:Nick() instead - nor are you reading the contents you’ve written when it’s received serverside - so do something like local name = net.ReadString()

Basically re-read the Wiki page for the Net Library (or how arguments/variables work) because you’ve got the right idea but have made quite a few small mistakes

Alternatively, just get everyone’s name via k, v pairs loop and v:Nick(), then insert it into a table and write that via util.TableToJSON as this doesn’t revolve going clientside

na make more work for my self is fun :smiley:

[editline]30th August 2016[/editline]

Still don’t understand i have read net Library for the past hour :smiley:

you don’t need the net library