Author Topic: Get client from GUI?  (Read 1000 times)

There must be a way to do this, but I can't figure it out. How do you get the client that clicked a button in your GUI?

I did find one thing: GUI.getClient(); but when you run that on a LAN server you get an error message saying that it only works on internet servers. Is there any other way to get the client that works no matter server type?

Well, the way a gui is set up is that when you click a button, you want it to send a commandToServer() to the server.  The server recieves it as a slash command, and it starts by default with the %client.  The server can then send a commandToClient() back.

What is it that you're trying to do?
If you're always trying to get the local client, it's always simply named localclientconnection.

Well, the way a gui is set up is that when you click a button, you want it to send a commandToServer() to the server.  The server recieves it as a slash command, and it starts by default with the %client.  The server can then send a commandToClient() back.
That won't work because I need to run a bunch of stuff client side first and then send all the data to the server.

What is it that you're trying to do?
If you're always trying to get the local client, it's always simply named localclientconnection.
Ah, thanks.

EDIT: Wait, localclientconnection will give me the client that's running the GUI? That's what I need.
« Last Edit: February 02, 2011, 02:11:41 PM by Greek2me »

That won't work because I need to run a bunch of stuff client side first and then send all the data to the server.
Ah, thanks.

EDIT: Wait, localclientconnection will give me the client that's running the GUI? That's what I need.
In client sided code, localclientconnection is always the controlled client. If you're talking about server-sided code then you'll have to rely on server commands.

serverConnection*. Only localClientConnection if you are hosting.

why do you need to know the client thats running the gui?

if you need to store values someplace -- put them in the gui object:

%stuff = ClientSideGui.stuff;
<scripting stuff>
ClientSideGui.stuff = %result;


then later on:
commandToServer('stuff', ClientSideGui.stuff );

Wow, I'm dumb.

When you do commandToServer, the client is sent automatically. duh

locking