Client players name to server.


So I’ve been trying for ages to get a menu to open on a v:Name() player and not LocalPlayer().
I’ve done:


net.Receive( "testest", function()

       local targeth = net.WriteEntity( v:Name() )

       --dermacode here



local function TestTest()

       net.Start( "testtest" )
               local targeth = net.ReadEntity()
       net.Send( targeth )


I’ve tried loads of other ways as well, and just can’t get my head around client to server, but the other way round I can easily do, any help would be appreciated.

Not certain I follow what you’re trying to do.

So you have your function TestTest and you’re trying to send net.ReadEntity, but where are you receiving that entity?

Also why are you trying to write a string as an entity on the clientside?

I’m using

for k, v in pairs(player.GetAll())

I’m wanting to send the v player to the server so a menu opens up on there screen only and not mine.

An entity is an object in the game. You’re trying to write a string in the client which is not an entity.

Just looking at your code, I think you need to re-read the net tutorial

You want to write the entity that you want to send to the client and then have the client read the entity it was sent by the server

1.) You do realize

Player:Name returns a string and NOT an entity right?

2.) If you are doing client to server, you do net.Start on the client and write whatever data you need, then at the end, instead of net.Send, you do net.SendToServer(). Note that you still need to do util.AddNetworkString on the SERVER.

3.) This is all pretty well explained

v:Name() is not an entity, so you’d need to write a string.

But I’m curious why you’re doing this - if all you need is the name sent to the client why not just write the string instead of the entity?

I need the name from client sent to server.

Just write the entity. Names are already networked internally.

If you need to open a derma panel on a player, you will not need their name at all. However, if you need just their name, then network the name over with net.WriteString, instead of net.WriteEntity.

Been trying again, sorry.
Just don’t understand.



First time trying to do something like this.

Okay so let me try to understand.

Is this essentially what you’re trying to do?

[lua]if (SERVER) then

local plyMeta = FindMetaTable('Player')

function plyMeta:openTestMenu()
	local ply = self

net.Receive(‘open_test_menu’, function(len)
local plyName = LocalPlayer():Name()

	-- Open menu here --


Yeah, that is, but instead of LocalPlayer() having the menu pop up, the targeted player, which in this case is v:Name().

I don’t follow.

So when you call ply:openTestMenu() on the serverside on the player you want, it will open the menu for that user.

You don’t need to call it via name.

I think today is a dumb day for me…
Then wouldn’t this work?
If so it doesn’t seem too.

In plyMeta please keep ply local like I had it, don’t make it global.

Also you’re doing a net.Receive inside a function, so naturally it can’t do anything. It won’t open the menu.