Author Topic: How can I open a gui with a command?  (Read 1328 times)

/title

How can I open a gui with a command? Like doing /help brings up a help gui I made.

If you have a Server-Client setup, you can make a clientCmd in the client mod to create the GUI elements and in the have a server mod that has a serverCmdHelp that does commandToClient(clientcmdfunction);

Command to open a GUI: canvas.pushDialog(YourGUI);

so.. (client only, no server stuff)
function openBlah()
{
   canvas.pushDialog(YourGUI);
}


for servers to clients:

client.cs

function clientCmdOpenBlah()
{
   canvas.pushDialog(Blah);
}

server.cs

function serverCmdGUI(%client)
{
   commandToClient(%client,'OpenBlah');
}
« Last Edit: April 25, 2015, 04:53:53 PM by Advanced Bot »

what about changing to a text version if the player doesn't have the client addon?

You can package GameConnection::autoAdminCheck and create a schedule to another client check for the client.
The client can send a handshake to the server, and the server will have the handshake.

What I usually do is create passwords and version to each of the sides.

can you give me an example?

can you give me an example?
Here's part of my RPG gui communication system server sided.

Please look at how it works, and not to try to copy/paste it like other people would.

Code: (GUICommunication.cs (a server.cs)) [Select]
$RPG::Version = 0.3;

package RPG_GuiCOM
{
function GameConnection::AutoAdminCheck(%this)
{
%this.chatMessage("\c7Checking client status..");
commandToClient(%this,'RPG_GuiComn_hsc',"GKAD3-AKBR-AMV4-PI4X");
** Sends a command to the client to see if they have the client with a sent password
%this.schedule(1000,RPG_GuiComn_hsc);
** Checks the client in a second to see if they sent a version (This will be changed since people may lag once they join) - You can make the check longer as well
return Parent::AutoAdminCheck(%this);
}

...
};
activatepackage(RPG_GuiCOM);

function sendRPGCommmand(%client,%command,%var1,%var2,%var3,%var4,%var5,%var6,%var7,%var8,%var9,%var10,%var11,%var12,%var13,%var14,%var15,%var16)
{
...
** Same as commandToClient(%client,'VRPG_%command', ..args..)
}

function GameConnection::sendRPGCommmand(%client,%command,%var1,%var2,%var3,%var4,%var5,%var6,%var7,%var8,%var9,%var10,%var11,%var12,%var13,%var14,%var15,%var16)
{
...
** Same as commandToClient(%client,'VRPG_%command', ..args..)
}

function serverCmdRPG_GuiComn_shs(%this,%password,%version)
{
** Make sure the password is correct
if(%password !$= "GKAD1-ALGE-UVN3-RAU3")
{
** Some of my old versions had different passwords
%this.chatMessage("Looks like your RPG is either outdated or broken, please contact the host about the issue.");
return -1; //Login Failure
}
if(%version < 0)
{
** Thier GUI either broke, or had the really old version of the RPG client
%this.chatMessage("Looks like your RPG has a version issue, please contact the host about this.");
return 0; //Version Error
}
** They successfully have the client, so set variable information on the client.
* Such as version, rpg client
%this.RPGCLV = %version; //Send the version, if it is higher than the server's version, obviously we have to disable it.
%this.RPGCL = true; //They have it now
** Send a donation link
%this.sendRPGCommmand("SetDonationLink",$RPG::DonationLink);
** Notify they have the client installed correctly
%this.chatMessage("Client status successful. Your client is currently updated.");
** This needs to be re-arranged, should be before they get activated
if(%version < $RPG::Version)
{
%this.chatMessage("Your client is outdated, contact the host for a newer version. (Client is still activated)");
%this.chatMessage(" \c6-> \crServer client version: \c3" @ $RPG::Version);
}
}

function GameConnection::RPG_GuiComn_hsc(%this)
{
** If they do not have it (See AutoAdminCheck for the command check), they cannot use it..
if(!%this.RPGCL)
{
%this.chatMessage("You do not have the RPG client. Click <a:www.dropbox.com/s/20y1q171ow267iw/Client_VRPG.zip?dl=1>here</a>");
%this.chatMessage(" --> DEMO has been turned on for you.");
%this.chatMessage("    -> Level access: Limited, highest level to get to is \c5" @ $RPG::DemoLevel);
%this.chatMessage("    -> Item access: Limited");
%this.chatMessage("    -> Player access: Limited");
%this.chatMessage("    -> Party/Group access: Restricted");
}
}
« Last Edit: April 25, 2015, 05:49:00 PM by Advanced Bot »

sorry, I don't really get it

sorry, I don't really get it
here's a bare minimum stripped down version



Code: [Select]
---SERVER.CS--
package thing
{
function  gameconnection::autoadmincheck(%this)
{
commandtoclient(%this,'doyouhavegui');
return parent::autoadmincheck(%this);
}
};
activatepackage(thing);

function serverCmdyesihavegui(%client)
{
%client.hasgui =  true;
}


--CLIENT.CS--

function clientcmddoyouhavegui()
{
commandtoserver('yesihavegui');
}


Here's part of my RPG gui communication system server sided.

Please look at how it works, and not to try to copy/paste it like other people would.

here's a bare minimum stripped down version

Would I need this clientCmd structure to check if a client downloaded textures when it connected?
« Last Edit: April 28, 2015, 06:09:41 PM by Hime »

Would I need this clientCmd structure to check if a client downloaded textures when it connected?
Theoretically yes, you could make a clientcmd to report to the server if the option is enabled
But doing so requires them downloading a clientside add-on with the client cmd, and at that point you might as well just give them the textures in the add-on

Theoretically yes, you could make a clientcmd to report to the server if the option is enabled
But doing so requires them downloading a clientside add-on with the client cmd, and at that point you might as well just give them the textures in the add-on

Texture alternatives to text-based displays seem best left to a client script then. Thank you.
« Last Edit: April 28, 2015, 06:09:42 PM by Hime »

Just a note, there are default clientcmd callable GUIs, forgot the exact parameters, but here are the functions
clientCmdMessageBoxOK
clientCmdMessageBoxOKCancel
clientCmdMessageBoxYesNo

clientCmdMessageBoxOK(string Title, string Message);
clientCmdMessageBoxOKCancel(string Title, string Message, string Eval_OnOKButtonPressed); (Cancel uses serverCmdCancel I believe)
clientCmdMessageBoxYesNo(string Title, string Message, string Eval_OnYESButtonPressed); (No uses serverCmdNo I believe)