Liberty Unleashed

Scripting => Script Help => Topic started by: Rocky on April 17, 2013, 11:44:05 am

Title: Why doesn't this work?
Post by: Rocky on April 17, 2013, 11:44:05 am
I added a GUI Bank system where player can withdraw or Deposit by entering amount. so once player clicks Deposit button

Code: [Select]
Deposit_Button.SetCallbackFunc( "DepositMoney" );
This script shows up.

Code: [Select]
function DepositMoney( )
{
    local amount = Amount_Box.Text;
    if( !amount || !IsNum( amount ) ) otherwL.Text = "Amount should be numeric*";
    else if( localPlayer.Cash < amount ) otherwL.Text = "You do not have the entered amount*";
    else
    {
        CallServerFunc( "RPG/File.nut", "DepositScript", localPlayer, amount );
        Disable_Bank_Window( );
        }
}

This line doesn't work
Code: [Select]
else if( localPlayer.Cash < amount ) otherwL.Text = "You do not have the entered amount*";
Also when i try to message/print  amount (Amount_Box.Text) my game crashes. but this line works fine.
Code: [Select]
if( !amount || !IsNum( amount ) ) otherwL.Text = "Amount should be numeric*";
Bug or my coding skills sucks?
Title: Re: Why doesn't this work?
Post by: Thijn on April 17, 2013, 03:28:48 pm
You should atleast do
Code: [Select]
else if( localPlayer.Cash < amount.tointeger() ) otherwL.Text = "You do not have the entered amount*";

Other then that I can't really see any error.
Try putting a try and catch around it, and print the errors to the client's console (`).
Title: Re: Why doesn't this work?
Post by: Rocky on April 17, 2013, 03:36:30 pm
You should atleast do
Code: [Select]
else if( localPlayer.Cash < amount.tointeger() ) otherwL.Text = "You do not have the entered amount*";

Other then that I can't really see any error.
Try putting a try and catch around it, and print the errors to the client's console (`).

thanks i always forget to put such things :P