Using netlibrary from one client to another; on a keypress

I can’t seem to get it sent to another local client. I make sure both clients have the same, updated lua files each time I update it. Right now nothing seems to happen, no errors persay but nothing happens on the 2nd client. The goal is to make it that this image panel appears on every OTHER client, but not the client that is pressing the button. (I haven’t started the keypress function yet, I’m just making sure the net library stuff works first and then moving on to that._

serverside code






util.AddNetworkString("openimagepanel")
util.AddNetworkString("sendimagepanel")

net.Receive("openimagepanel",function (len, ply)
	local ImageVar= net.ReadString(MyImage)

	for k, v in pairs(player.GetAll()) do
 			  if v == ply then continue end 
			   net.Start("sendimagepanel")
				net.WriteString(ImageVar)
				 net.Send(ply)
				
	end

end)









clientside stuff




function sendimage() 

net.Start("openimagepanel")
net.WriteString( MyImage)		
net.SendToServer()
end 

		

function DisplayImagePanel()
		net.Receive ("sendimagepanel", function (ply)
		ImageDisplayed = net.ReadString(ImageVar)
		print ("Display Test")
		print (ImageDisplayed)
					end)

end 
		

concommand.Add("sendimage", sendimageboard
concommand.Add("displaypanel",DisplayImagePanel) 



You cannot send data from a player to player directly, it MUST go through the server.

I thought I had done that. One command sends the string to the server and then once the server receives it, it sends it to every other player that isn’t the player who sent it…

Your clientside code contains syntax error, you must not put net.Receive in any functions ( Unless you absolutely know what you are doing, but even then, it’s a dumb idea )

Is my syntax for “every other player” correct though?

Yes, but its a lot cleaner to use

net.SendOmit

The reason your code isn’t working is due to calling net.Send on the server with the ‘ply’ variable when it should be ‘v’ instead. However, you would be better off using the net.SendOmit function as mentioned above.



function DisplayImagePanel()
        net.Receive ("sendimagepanel", function (ply)
        ImageDisplayed = net.ReadString(ImageVar)
        print ("Display Test")
        print (ImageDisplayed)
                    end)

end 


net.Receive cannot be called like that, so instead, inside the receive function, add the data to a table, and then disaply that table inside your concommand function

wrong thread. I’m sorry.