Hello,
I would like to sent a variable from client to server.
Example:
[lua]local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 250,250 )
DermaPanel:SetSize( 500, 50 )
DermaPanel:SetTitle( "Derma Testing Stuff" )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetVisible( true )
DermaPanel:MakePopup()
local DermaText = vgui.Create( "DTextEntry", DermaPanel )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )
DermaText.OnEnter = function()
Msg("You entered -"..DermaText:GetValue().."-!" ) -- What happens when you press enter
DermaPanel:SetVisible( false )
end[/lua]
In this clientside lua i want to send the variable "DermaText:GetValue()" to a serverside lua
Itry to read [URL]http://wiki.garrysmod.com/?title=Client_to_Server[/URL] but i don't understand what I need to do.
Thanks in advance for your help.
It's probably better to just use a single console command than datatream, just seems like overkill.
Server:
[lua]concommnand.Add("sendvalue", function(ply, cmd, args)
local value = args[1]; -- Do what you need to do with the value
end)[/lua]
Client:
[lua]local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 250,250 )
DermaPanel:SetSize( 500, 50 )
DermaPanel:SetTitle( "Derma Testing Stuff" )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetVisible( true )
DermaPanel:MakePopup()
local DermaText = vgui.Create( "DTextEntry", DermaPanel )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )
DermaText.OnEnter = function()
Msg("You entered -"..DermaText:GetValue().."-!" ) -- What happens when you press enter
DermaPanel:SetVisible( false )
RunConsoleCommand("sendvalue", DermaText:GetValue())
end[/lua]
thanks a lot!
Sorry, you need to Log In to post a reply to this thread.