Sending Client Messages To Server

Ok so what I Want to do is send a client message to server, I have already used umsg for server to send to client and to open up my DermaPanel / Button but I need it to go back to the server because I want to make a server teleporter.
If you could help me make a server teleporter and fix the code that would be great thanks!
Client Side:



include('shared.lua')
local ply = LocalPlayer()

hook.Add("PostDrawOpaqueRenderables", "Server Teleport", function()
	for _, ent in pairs (ents.FindByClass("server_tp")) do
		if ent:GetPos():Distance(LocalPlayer():GetPos()) < 1000 then
			local Ang = ent:GetAngles()

			Ang:RotateAroundAxis( Ang:Forward(), 90)
			Ang:RotateAroundAxis( Ang:Right(), -90)
		
			cam.Start3D2D(ent:GetPos()+ent:GetUp()*80, Ang, 0.35)
				draw.SimpleTextOutlined( 'Server Teleporter', "HUDNumber5", 0, 0, Color( 0, 150, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color(0, 0, 0, 255))			
			cam.End3D2D()
		end
	end
end)

function MenuOpen( ply )
ply = LocalPlayer()
local DermaPanel = vgui.Create( "DFrame" )
	DermaPanel:SetPos( 80,70 )
	DermaPanel:SetSize( 300, 200 )
	DermaPanel:SetTitle( "Server Teleport - PabloSky11400" )
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true )
	DermaPanel:ShowCloseButton( true )
	DermaPanel:MakePopup()
	DermaPanel:Center()
	local DermaButton = vgui.Create( "DButton" )
		DermaButton:SetParent( DermaPanel )
		DermaButton:SetText( "Farmer Brown's Farm" )
		DermaButton:SetPos( 20, 50 )
		DermaButton:SetSize( 150, 50 )
		DermaButton:SetFont( "DarkRPHUD1" )
		DermaButton.DoClick = function ( player )
			   player:SetPos(Vector(6126.940918, -4330.143555, 2116.523682))
		end

end
usermessage.Hook( "Menu", MenuOpen )



Server Side:



AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:Initialize()
	self:SetModel( "models/Humans/Group02/male_09.mdl" )
	self:SetHullType( HULL_HUMAN )
	self:SetHullSizeNormal( )
	self:SetNPCState( NPC_STATE_SCRIPT )
	self:SetSolid( SOLID_BBOX )
	self:CapabilitiesAdd( CAP_ANIMATEDFACE )
	self:SetUseType( SIMPLE_USE )
	self:DropToFloor()
 
	self:SetMaxYawSpeed( 180 )
end
function ENT:OnTakeDamage( dmg ) 
	return false
end
function ENT:AcceptInput( Name, Activator, Caller )
	if Name == "Use" and Caller:IsPlayer() then
	umsg.Start( "Menu", Activator )
	umsg.End()
	end
end



I have tried using net messages but I don’t know how they work and if I use umsg to get back to server side it will give me an error when press the button.
If you help thanks!

[editline]2nd March 2014[/editline]

P.S- The server teleporter is not to change server its to move you’re guy around our map!

This, http://wiki.garrysmod.com/page/Net_Library_Usage

Its faster allows 2 way communication and uses less resources.

Mind giving me an example on where to put it and how I could use it please?

client:



FarmerBrown.DoClick = function()
    net.Start("myuniquenetmsg");
    net.WriteByte(1);
    net.SendToServer();
end


sever:



util.AddNetworkedString("myuniquenetmsg");
local pos = {
    [1] = Vector(6126.940918, -4330.143555, 2116.523682);
};
net.Receive("myuniquenetmsg", function(len, ply)
    local index = net.ReadByte();
    if(ply:GetPos():Distance(whateverentity:GetPos()) < 20) then
        ply:SetPos(pos[index] or ply:GetPos());
    end
end);





[ERROR] addons/server teleport/lua/entities/server_tp/cl_init.lua:38: attempt to call field 'WriteByte' (a nil value)
  1. DoClick - addons/server teleport/lua/entities/server_tp/cl_init.lua:38
   2. unknown - lua/vgui/dlabel.lua:206



This is code is mine ///
Serverside!



AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )


function ENT:Initialize()
	self:SetModel( "models/Humans/Group02/male_09.mdl" )
	self:SetHullType( HULL_HUMAN )
	self:SetHullSizeNormal( )
	self:SetNPCState( NPC_STATE_SCRIPT )
	self:SetSolid( SOLID_BBOX )
	self:CapabilitiesAdd( CAP_ANIMATEDFACE )
	self:SetUseType( SIMPLE_USE )
	self:DropToFloor()
 
	self:SetMaxYawSpeed( 180 )
end
function ENT:OnTakeDamage( dmg ) 
	return false
end
function ENT:AcceptInput( Name, Activator, Caller )
	if Name == "Use" and Caller:IsPlayer() then
	umsg.Start( "Menu", Activator )
	umsg.End()
	end
end


util.AddNetworkedString("TowerTP");
local pos = {
    [1] = Vector(6126.940918, -4330.143555, 2116.523682);
};
net.Receive("TowerTP", function(len, ply)
    local index = net.ReadByte();
    if(ply:GetPos():Distance(server_tp:GetPos()) < 20) then
        ply:SetPos(pos[index] or ply:GetPos());
    end
end);


Client Side



include('shared.lua')
local ply = LocalPlayer()

hook.Add("PostDrawOpaqueRenderables", "Server Teleport", function()
	for _, ent in pairs (ents.FindByClass("server_tp")) do
		if ent:GetPos():Distance(LocalPlayer():GetPos()) < 1000 then
			local Ang = ent:GetAngles()

			Ang:RotateAroundAxis( Ang:Forward(), 90)
			Ang:RotateAroundAxis( Ang:Right(), -90)
		
			cam.Start3D2D(ent:GetPos()+ent:GetUp()*80, Ang, 0.35)
				draw.SimpleTextOutlined( 'Server Teleporter', "HUDNumber5", 0, 0, Color( 0, 150, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color(0, 0, 0, 255))			
			cam.End3D2D()
		end
	end
end)

function MenuOpen( ply )
ply = LocalPlayer()
local DermaPanel = vgui.Create( "DFrame" )
	DermaPanel:SetPos( 80,70 )
	DermaPanel:SetSize( 300, 200 )
	DermaPanel:SetTitle( "Server Teleport - PabloSky11400" )
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true )
	DermaPanel:ShowCloseButton( true )
	DermaPanel:MakePopup()
	DermaPanel:Center()
	local DermaButton = vgui.Create( "DButton" )
		DermaButton:SetParent( DermaPanel )
		DermaButton:SetText( "Farmer Brown's Farm" )
		DermaButton:SetPos( 20, 50 )
		DermaButton:SetSize( 150, 50 )
		DermaButton:SetFont( "DarkRPHUD1" )
		DermaButton.DoClick = function ( player, ply )
		net.Start("TowerTP");
		net.WriteByte(1);
		net.SendToServer();
	end
end
usermessage.Hook( "Menu", MenuOpen )




WriteInt and ReadInt for numbers without decimal points.

Use like this

[lua]WriteInt(1,8)[/lua]
[lua]ReadInt(8)[/lua]

I don’t get what you mean?

Use that instead of ReadByte and WriteByte