Author Topic: GUI commandToServer  (Read 663 times)

Dose not work:
Client:
Code: [Select]
function deposit(%gui)
{
%amount = Deposit.getValue();

commandToServer('bankdeposit', %amount);
}
GUI:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new GuiWindowCtrl(bankGUI) {
   profile = "GuiWindowProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "200 200";
   minExtent = "8 2";
   visible = "1";
   maxLength = "255";
   resizeWidth = "1";
   resizeHeight = "1";
   canMove = "1";
   canClose = "1";
   canMinimize = "1";
   canMaximize = "1";
   minSize = "50 50";

   new GuiTextEditCtrl(deposit) {
      profile = "GuiTextEditProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "40 60";
      extent = "82 18";
      minExtent = "8 2";
      visible = "1";
      maxLength = "255";
      historySize = "0";
      password = "0";
      tabComplete = "0";
      sinkAllKeyEvents = "0";
   };
   new GuiButtonCtrl() {
      profile = "GuiButtonProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "38 88";
      extent = "100 22";
      minExtent = "8 2";
      visible = "1";
      command = "deposit();";
      text = "Button";
      groupNum = "-1";
      buttonType = "PushButton";
   };
};
//--- OBJECT WRITE END ---
Server:
Code: [Select]
function ServerCmdbankdeposit(%client, %amount)
{
%amount = atoi(%amount);
if (%amount <= 0)
{
commandToClient(%client, 'messageBoxOK', "Error", "Not a valid number.");
return;
}

if(%amount > PitroRPData.getData(%client.bl_id).valueMoney)
{
commandToClient(%client, 'messageBoxOK', "Error", "You don't have the much money dipstuff.");
return;
}

PitroRPData.getData(%client.bl_id).valueBank += %amount;
PitroRPData.getData(%client.bl_id).valueMoney -= %amount;
}
The deposit command dose not work.
Note: The GUI opens, The server.cs is running.


After reading over a few times, I've at least found two cosmetic problems:

  • There's a %gui in the deposit function which has absolutely no reason to be there.
  • You call the user a "dipstuff" for no reason, demeaning them and probably pissing off noobs. There's no reason to call them a dipstuff when it could be a mistake or simpler.

Edit: Any syntax errors? The command for determining amount (atoi) is shown here, maybe that's the problem? Could we see it? What happens when you try, besides the GUI opening?
« Last Edit: June 27, 2010, 11:56:27 PM by MegaScientifical »


Also, you're not checking if the person is depositing exactly all their money. If they try, it also gives the not enough error.

put some echo() commands in your script so you can see the values of things.  Use those to check to make sure the script is doing what you want it to.

I tried putting:
Code: [Select]
echo("Sending bank data);into the clientCmd but it caused a syntax.

I tried putting:
Code: [Select]
echo("Sending bank data);into the clientCmd but it caused a syntax.
You need to use an end quote

echo("Sending bank data");

Also; calling someone a dipstuff for trying to put more money into their bank is stupid. I wouldn't care because even if they did max their bank account they'd have negative cash and wouldn't be able to purchase anything until they took all that money back out of their bank, and they'd probably never do that again.

Try changing
Code: [Select]
function deposit(%gui)
{
%amount = Deposit.getValue();

commandToServer('bankdeposit', %amount);
}
to
Code: [Select]
function deposit(%gui)
{
%amount = Deposit.getValue();

echo("Function called; Value is " @ %ammount); //If you didn't know, @ allows you to add onto a message.

commandToServer('bankdeposit', %amount);
}
« Last Edit: June 29, 2010, 12:15:17 PM by Triple Nickels »