Client to server and reverse...

Hi all, I have little problems with client and server side.

  1. So, for example, I have Derma menu with checkboxes wich must to change con_vars… but Derma menus can be run on client side but con_vars can be changed only on the server side… and how I can make Derma menu with checkboxes wich can changed con_vars like this: sv_alltak, mp_falldamage, sbox_noclip etc…

  2. How I can use this command? chat.AddText on client as server sending for each player? For example: I have game hook in server side like this:

function PlyConnect(ply, ip)
---- and here I need to send this command : chat.AddText(…) to any player on the server…
end
hook.Add(“PlayerConnect”, “PlyCon”, PlyConnect)

I try to use Player.SendLua("…") but it doesn’t work…

Thanks.

Server -> Client

Client -> Server

You can also use datastream to stream in both directions, but I use umsg when possible as it is simpler. You may want someone to hold your hand through this, but these two links are more than enough to let you figure it out yourself( I had to xD ). If you have to figure it out yourself, you will remember it better and can say that you truly wrote the code on your own. Try to get it working, if you cant, just ask about what you are stuck on.

@Rayjingstorm

concommands.

Ok, thanks, I will try it…

just to make it clearer, ignore what he said about the datastream. You want to be using concommands for client->server

Why is Datastream assumed to be the only way?

Because it’s the easiest.

But, the worst.

How is datastream.StreamToServer({“CRAP”, “CRAP”, "CRAP}) easier then:

RunConsoleCommand(“crap”, “crap”, “crap”)

If anything it’s more complicated.

datastream.StreamToServer(“some_handler” , {“derp” 1 , 3})

RunConsoleCommand(“some_handler” , “derp” , 1 , 3)

[editline]10:32PM[/editline]

20 minute ninja

:ninja:

I know, umsg. functions good for Server -> Client
But, I asked, how to make Checkboxes with server con_vars?
MyCheckBox:SetConVar(“sv_alltak”) -> client can’t to do this, but can I do SetConVar as (“rcon sv_alltak”) ? or something function…

You could make a console command for it:

[lua]concommand.Add( “changeconvar”, function( ply, com, args )
if ( ply:IsAdmin() and #args > 2 and tonumber( args[2] ) ) then
RunConsoleCommand( args[1], args[2] )
end
end )[/lua]

D:< I asked about CHECKBOX which change server convar, I KNOW WHAT I CAN DO MY CONCOMMAND, I NEED CHECKBOX in MY PANEL: when I checked so convar set to 1, else convar set to 0! =/

argghh… -_-

D:< You should BE ABLE TO figure out HOW TO DO IT by looking at THE DERMA EXAMPLES ON THE WIKI: as you can see, you can run the console command when the state of the checkbox changes! =/

[lua]checkbox.OnChange = function( self )
RunConsoleCommand( “setconvar”, “sv_alltalk”, self:GetChecked() and 1 or 0 )
end )[/lua]

-_-

I’m going to assume capitals is you raising your voice, do not expect any help around here if you are going to be like that you ungrateful bastard.

I don’t know who is bastard, and I not…
Just want to see normal answer on current question.

Thx Overv, this is what I wanted to know…

[editline]06:53PM[/editline]

And THIS = not cry, remember, in normal chats etc it equal to Accent on words… ^_-

Don’t be ungrateful just because you can’t read what we wrote.

I can… =/ but don’t know where it must be placed…

So with change convars I will work after…

Now I try to use umsg and I take this error… (Warning: unhandled usermessage ‘…’) or something… when I do this:

SERVER:

function TestUmsg(ply, cmd, args)
umsg.Start(“TestUm”)
umsg.End()
end
concommand.Add(“testum”, TestUmsg)

CLIENT:

function PrintUmsg()
chat.AddText(Color(255,0,0), “Umsg is work :)”)
chat.PlaySound()
end
usermessage.Hook(“TestUm”, PrintUmsg)

What’s wrong?
This two files work on own sides… but Umsg doesn’t work…

On the server, the usermessage is called TestUm, but on the client it’s called testum. It’s case sensitive.

Hm? So, please, write short code like this but which will be work curectly :wink:

[editline]07:16PM[/editline]

Stop, Sorry, it’s wrong, I know, TestUm on client and server equal to TestUm… And don’t work…