net.ReadEntity Null

Hello,

From my client I send one entity to my server like that:



net.Start( "call_taxi" )
    net.WriteString( "trolol" )
    net.WriteEntity( LocalPlayer() )
net.SendToServer()


On my serverside I receive that entity like that:



util.AddNetworkString( "call_taxi" )

net.Receive( "call_taxi", function()
	local ply = net.ReadEntity()
	local text = net.ReadString()
	print( ply:IsValid(), ply )
	print( text )
end)


Result :



false   [NULL Entity]
olol


Why my “trolol” become “olol” and why my entity is null ?

I’m trying to understand, but no thread solve my problem.

Thanks.

You have to read data in the same order you write it. Also, you shouldn’t need to network the local player to the server as it’ll be passed as the net.Receive callback’s second argument.



net.Receive("call_taxi", function(len, ply)
    local text = net.ReadString()

    print( ply:IsValid(), ply )
    print( text )
end)


and so on

Oh my god ! Thank you so much ! it works !