Saving User inputted Text to a table

What im looking for is some code that when a user types in the Title of there Loadout it saves it to a table…



Name = "Input1"
Weapons = {}


Idk something like this



local Name = vgui.Create("DTextEntry", Frame)
	Name:SetText("Input1")
	Name:SetSize( 100,20 )
	Name:SetPos(5,28)
	Name.OnEnter = function(self) Msg("Text Entered: " .. self:GetValue() .. "
") end -- But instead i want it to save to a table


Any help would be great, even just where i could start
The table would be read and displayed under your name on the scoreboard for example

AGFlav
Input1
Team RED

To do: net message -> sent to server with that value and (save into your table or if you need save into clientside table) -> and broadcast that message from server to everyone with entity player :slight_smile:

Example?, I know what you mean with net messages but iim not very experienced with tables

http://lua-users.org/wiki/TablesTutorial



if SERVER then
	local plyaltnames = {} -- Define our table 
	util.AddNetworkString( "MyPlayerNameTable" ) -- pool our net message
	net.Recieve("MyPlayerNameTable", function(len,ply) -- receiving our net message from client
		if ( IsValid( ply ) and ply:IsPlayer() ) then
			local altname = net.ReadString()
			plyaltnames[ply:SteamID64()] = {}
			plyaltnames[ply:SteamID64()] = altname
			net.Start("MyPlayerNameTable") -- starting our net message
				net.WriteEnt(ply)
				net.WriteString(altname)
			net.Broadcast() -- sending our net message to server    
		end
	end)
else
	local Name = vgui.Create("DTextEntry", Frame)
	Name:SetText("Class One")
	Name:SetSize( 100,20 )
	Name:SetPos(5,28)
	Name.OnEnter = function(self)
	net.Start("MyPlayerNameTable") -- starting our net message
		net.WriteString(self:GetValue())
	net.SendToServer() -- sending our net message to server    
	end
	net.Recieve("MyPlayerNameTable", function(len)
		local ply = net.ReadEntity()
		local plyaltname = net.ReadString()
		ply.altname = plyaltname
		print(ply.altname)
	end)		
end


I think it should works

How would i link the DTextEntry and this table together? like this?



	local Name = vgui.Create("DTextEntry", Frame)
	Name:SetText("Class One")
	Name:SetSize( 100,20 )
	Name:SetPos(5,28)
	Name.OnEnter = function(self)
	net.Start("MyPlayerNameTable")
	net.WriteString(self:GetValue())
        net.SendToServer()         
	end




if SERVER then
	local plyaltnames = {}
	util.AddNetworkString( "MyPlayerNameTable" ) 
	net.Recieve("MyPlayerNameTable", function(len,ply)
		if ( IsValid( ply ) and ply:IsPlayer() ) then
			local altname = net.ReadString()
			plyaltnames[SteamID64()] = {}
			plyaltnames[SteamID64()] = altname
		end
	end)
else
	net.Start("MyPlayerNameTable")
		net.WriteString(self.GetValue())
	net.SendToServer()
end

And then how would i read this? for displaying on a derma panel or scoreboard/hud?

You asked example, not code for you.
P.S. updated code :\