I have a DTextEntry which triggers net.Start
[lua]
sc_input.OnEnter = function( self )
net.Start( "sc_verify" )
net.WriteString( self:GetValue() )
net.WriteEntity(LocalPlayer())
net.SendToServer()
end
[/lua]
Receiving side
[lua]
net.Receive( "sc_verify", function(len)
local a = net.ReadString()
local b = net.ReadEntity()
print(a) -- works
print(b:Nick()) -- doesn't work
b:Kill() -- same here
end
[/lua]
I'm doing this to find out what player used the DTextEntry ofcourse, so I could the player later on serverside (for instance kill him)
It always sends a null entity now matter what I do, if it's not possible to do then what would be the best approach here?
The only way I can think of right now is to send some kind of identifier like SteamID(64) then loop through all players and find the matching one, but that seems kinda inefficient.
Any help is appreciated!
I suppose you could use player.GetByID( id ) serverside, and write the id of LocalPlayer() clientside?
On the server, the second argument to the net.Recieve callback is the player that sent the message.
Oh well that solves all my problems, thanks!
[lua]
net.Receive( "sc_verify", function(len, ply)
local a = net.ReadString()
print(a)
print(ply:Nick())
ply:Kill()
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.