Author Topic: Making a clientsided GUI show serversided variables.  (Read 613 times)

Could I do this by having some sort of commandToClient thing

And have the text be a variable on the client or something?

Any help would be nice.

You'd need to send them through a commandToClient, exactly how you code it would depend on what you're doing with it.

If you have a large amount of variables that change values often, and having a delay between opening the GUI and getting a proper value is not an issue, have the bind to open the GUI also call a commandToServer, and have the serverCmd call a commandtoclient, and the clientCmd sets the values in the GUI.

If you have a small amount of variables, or a larger amount that doesn't change values often, and a delay is an issue, you could call a commandToClient every time the value of the variable changes, and the clientCmd would immediately change the value, even while the GUI is open.

That's what I was thinking. Just sending the command over every time.

And I see how the function would work, too.

Thanks.

You could also try a message callback, though I'm not entirely sure how to set that up on the client. Once I get home I'll look through some old code to see if I can find an example, if someone else doesn't. Found some stuff on my laptop that I can look through
« Last Edit: September 22, 2010, 05:36:54 PM by Headcrab Zombie »

I just want a GUI on the playgui that shows variables. :I

Using a message callback would basically do the same thing as using clientCmds, except you call it with messageClient instead of commandToClient, and if you want to update a variable on all clients you can do messageAll instead of looping through ClientGroup and sending a clientCmd to each object, which can make things easier and faster.

Anyways, here's an example I found:
Code: [Select]
addMessageCallback('MsgEquipInv', handleEquipInv);

function handleEquipInv(%msgType, %msgString, %slot)
{
%slot++;
switch (%slot)
{
case (1):
Slot1BG.setBitmap("fps/client/ui/GUIBrickSideEquip.png");
case (2):
Slot2BG.setBitmap("fps/client/ui/GUIBrickSideEquip.png");
case (3):
Slot3BG.setBitmap("fps/client/ui/GUIBrickSideEquip.png");
case (4):
Slot4BG.setBitmap("fps/client/ui/GUIBrickSideEquip.png");
case (5):
Slot5BG.setBitmap("fps/client/ui/GUIBrickSideEquip.png");
}
}

To call it on the client you would use messageClient(%client,'MsgEquipInv','',%slot);
« Last Edit: September 22, 2010, 05:51:27 PM by Headcrab Zombie »

Cool.

That makes things a lot easier! Thanks.  :cookieMonster:

That would be a serversided script, right?
« Last Edit: September 22, 2010, 09:20:07 PM by otto-san »

The message callback would be client side

Using a message callback would basically do the same thing as using clientCmds, except you call it with messageClient instead of commandToClient, and if you want to update a variable on all clients you can do messageAll instead of looping through ClientGroup and sending a clientCmd to each object, which can make things easier and faster.

There's a commandToAll function; you don't have to do any looping.

Yeah I kind figured that, but by the time I thought of it I was in class and couldn't access BL to check and didn't want to go on forums.