Author Topic: Gui help  (Read 1119 times)

Ok so I recently started on my Medieval mods GUI since everyone was complaining about all the chat commands.

Anyway I just need to know a couple things about a GUI.

1.How do I display a clients variable while in a GUI such as a box that says
Code: [Select]
"Copper Ore: %client.quantity["CopperOre"]".
2.Changing a font in a gui.

3.
« Last Edit: December 23, 2008, 04:57:47 PM by Kunit »

Quote
How do I display a clients variable while in a GUI such as a box that says
Client commands. They work in a similar way as serverCmds, but from the server to the clients instead.
Server-side code (e.g. servercmd that is triggered by opening the GUI)
Code: [Select]
commandtoclient(%client,'updateMedievalModResource',"Copper Ore",%client.quantity["CopperOre"]);
Client-side code (goes in client.cs or related files)
Code: [Select]
function clientcmdUpdateMedievalModResource(%type,%amount)
{
 //Perhaps use %type to determine which text box it's supposed to be
 whateverTextBox.setText(%type @ ":" SPC %amount);
}
People will need to have your version of the client files to see the GUI functioning.

Quote
Changing a font in a gui.
Use an MLTextCtrl. You can then use the ML tags, such as <color:HEX>, \cX, <font:Type:Size>, <br>, etc.

Oh, Thanks for the refrence Space Guy, I found out the font yesterday though.

Spaceguy, what would the code be to make "CoppeOre" (   messageClient(%client, '', '\c2Iron Ore: \c1%1!',%client.quantity["IronOre"]);) Work for the red 0.




The code I posted here is the chat command version of it.

Just make a client command that updates their menu when they gain ore quantity.
Like this:
Code: [Select]
function clientCmdUpdateOre(%type,%amm)
{
   switch$(%type)
   {
      case "Copper":
         CopperOreTextControl.setText(%amm);
   }
}

function pickaxeProjectile::oncol....
{
   if(col.hits... copperore)
   {
      commandtoclient(%obj.client,'updateOre',"Copper",%obj.client.copperore);
   }
}

Code: [Select]
function clientcmdUpdateMedievalModResource(%type,%amount)
{
 //This is just an example, change the text box names to whatever you need and add the rest of your ores
 switch$(%type)
 {
  case "Copper Ore":
   %txt = txtAmtCopperOre;
  case "Iron Ore":
   %txt = txtAmtIronOre;
 }

 if(%amount <= 0)
  %col = "\c0";
 else
  %col = "\c1";

 %message = "\c6" @ %type @ ":" SPC %col @ %amount;

 %txt.setText(%message);
}

The text controls should be GuiMLTextCtrls if they aren't already. If you have zero ore, it'll display in red, otherwise the number displays in \c1. (I think it's blue)

This uses the same commandtoclient line I posted.

Also, you should probably use something to determine that the client has the GUI first like a command sent to everyone joining the server - perhaps sending all messages through chat (as well as an occasional "by the way, you can use the GUI for this" one) if they don't.