| Blockland Forums > Modification Help |
| GUI commandToServer |
| (1/2) > >> |
| pitfall:
Dose not work: Client: --- Code: ---function deposit(%gui) { %amount = Deposit.getValue(); commandToServer('bankdeposit', %amount); } --- End code --- GUI: --- Code: ---//--- 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 --- --- End code --- Server: --- Code: ---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; } --- End code --- The deposit command dose not work. Note: The GUI opens, The server.cs is running. |
| pitfall:
Bump. |
| MegaScientifical:
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? |
| pitfall:
No syntax. |
| 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. |
| Navigation |
| Message Index |
| Next page |