Author Topic: GUI Question  (Read 1526 times)

Would it be possible to display a VCE Variable value in a GUI? I might be just thinking about it the wrong way but it doesn't seem like it would possible or indeed a good idea, considering you can open a keybound GUI on any server. I suppose that leads me to another question, is it possible to make it so people can download your GUI and yet only be able to use it on your own server. (NOT saying that they couldn't go change the code but just asking in general.)

VCE is a server sided data set, while GUIs are on the client side.

In order to have a gui display a variable from VCE, the client must request it from the server, and the server needs to send it back.

Could I make it so all they have to do is request it once and it will automatically request it from then on?

Could I make it so all they have to do is request it once and it will automatically request it from then on?

There is no difference between "request" and "automatic request" in this context.  All the requests would be identical, whether you call them "automatic" or not.

How would somone go about requesting it anyway?

How would somone go about requesting it anyway?

First the client sends the request like this:
commandtoserver('gimmeData');

Then the server receives it, and sends the data back by doing:
function servercmdgimmeData(%client)
{
      %data = getdata();
      commandtoclient(%client, 'givinData', %data);
}

Finally, the client receives the data like so:
function clientcmdgivinData(%data)
{
      dataObtained(%data);
}

Could you make it so they automatically request it when they connect to the server?

Like have the server forces them to request it or something weird.
« Last Edit: January 27, 2012, 03:31:31 PM by Mapster »

Could you make it so they automatically request it when they connect to the server?

Like have the server forces them to request it or something weird.

How would you define automatic?

You can have the server just send the data sure, which would basically skip to the commandtoclient(%client, 'givinData', %data);

However, if the client does not have the function clientcmdgivinData, then nothing will happen.

Automatic as in, when the connect to the server it happens on its own.

Automatic as in, when the connect to the server it happens on its own.
Wouldn't that be ServerConnection::onClientJoin?
or what?

Automatic as in, when the connect to the server it happens on its own.

the most commonly used one is
gameConnection::autoAdminCheck(%client)

This is called just after a player connects to the server, so in your case would be used like this:
Server-sided
Code: [Select]
function gameConnection::autoAdminCheck(%client)
{
    parent::autoAdminCheck(%client); //We parent + package this so we don't overwrite the function

    commandToClient(%client, 'GivingData', "Whatever needs to be sent");
}

And client-sided, as Nexus said
Code: [Select]
function clientCmdGivingData(%data)
{
   // do stuff with data
}

You need to return the parent when using autoAdminCheck:
Code: [Select]
function GameConnection::autoAdminCheck(%client)
{
commandToClient(%client, 'GivingData', "Whatever needs to be sent");

return parent::autoAdminCheck(%client); //We parent + package this so we don't overwrite the function
}

Alright that makes sense, I still need to know how a VCE Variable value is displayed in a GUI. As in what would I add to my GUI itself so that the variable value can be shown in some text.

Alright that makes sense, I still need to know how a VCE Variable value is displayed in a GUI. As in what would I add to my GUI itself so that the variable value can be shown in some text.
I think that would be
Code: [Select]
CONTROL_NAME.setText(%client.brickGroup.varGroup.getVariable("CLIENT, SELF, OR PLAYER","VAR_NAME",%client));