Thread: [PI] Money Pouch Withdraw

Results 1 to 5 of 5
  1. #1 [PI] Money Pouch Withdraw 
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    139
    Thanks received
    80
    Rep Power
    99
    how do i make it so that when you withdraw say 2b coins from your money pouch and you have 500m coins it wont delete the extra 353m (about) coins and instead add them into your money pouch?

    Current Code

    Code:
    if(playerCommand.startsWith("withdraw")) {
                    String[] cAmount = playerCommand.split(" ");
                    int amount = Integer.parseInt(cAmount[1]);
                    if (c.inWild()) {
                            c.sendMessage("You cannot do this in the wilderness");
                            c.getPA().sendFrame126(""+c.MoneyCash+"", 8135); 
                            return;
                    }
                    if (amount < 1) {
    		return; 
    		}
                    if(amount == 0) {
                            c.sendMessage("Why would I withdraw no coins?");
                            return;
                    }
                    if(c.MoneyCash == 0) {
                            c.sendMessage("You don't have any cash in the bag.");
                            c.getPA().sendFrame126(""+c.MoneyCash+"", 8135); 
                            return;
                    }
                    if(c.MoneyCash < amount) {
                            if(amount == 1) {
                                    c.sendMessage("You withdraw 1 coin.");
                            } else  {
                                    c.sendMessage("You withdraw "+c.MoneyCash+" coins.");
                            }
                            c.getItems().addItem(995, c.MoneyCash);
                            c.MoneyCash = 0;
                            c.getPA().sendFrame126(""+c.MoneyCash+"", 8134); 
                            c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
                            return;
                    }
                    if(c.MoneyCash != 0) {
                            if(amount == 1) {
                                    c.sendMessage("You withdraw 1 coin.");
                            } else  {
                                    c.sendMessage("You withdraw "+amount+" coins.");
                            }
                                    c.MoneyCash -= amount;
                                    c.getItems().addItem(995, amount);
                                    c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
                    if(c.MoneyCash > 99999 && c.MoneyCash <= 999999) {
                    c.getPA().sendFrame126(""+c.MoneyCash/1000+"K", 8134); 
                    } else if(c.MoneyCash > 999999 && c.MoneyCash <= 2147483647) {
                            c.getPA().sendFrame126(""+c.MoneyCash/1000000+"M", 8134);
                    } else {
                                    c.getPA().sendFrame126(""+c.MoneyCash+"", 8134);
                            }
                    c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
                    }
            }
    Reply With Quote  
     

  2. #2  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    The math way:
    Code:
    maxToWithdraw = maxPosibleAmount - currentAmount
    if(maxToWithdraw > toWithdraw)
         maxToWithdraw = toWithdraw
    With in the end, maxToWithdraw the maximum amount you can withdraw without losing anything or without withdrawing more than you have.
    Reply With Quote  
     

  3. #3  
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    139
    Thanks received
    80
    Rep Power
    99
    thanks, i know what to do for the math im just not sure of the methods to use. :\ like what do i put for it to see how many coins the player has in their inv. when i get that i should be able to get it right.
    Reply With Quote  
     

  4. #4  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    Oh...
    Don't have PI myself so can't tell .
    But it's probably some method in: c.getItems()
    Reply With Quote  
     

  5. #5  
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    139
    Thanks received
    80
    Rep Power
    99
    alright, thanks. ill take a look.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Money Pouch Disconnection
    By Dhruv in forum Help
    Replies: 1
    Last Post: 08-13-2012, 09:33 PM
  2. [PI] Money Pouch withdrawing problem
    By Thock321 in forum Help
    Replies: 4
    Last Post: 04-15-2012, 05:00 PM
  3. [PI] money pouch error?
    By 64Bit in forum Help
    Replies: 9
    Last Post: 02-13-2012, 12:56 PM
  4. [pi] money pouch help please
    By Preject Retribution in forum Help
    Replies: 4
    Last Post: 02-11-2012, 03:54 AM
  5. [PI] Money Pouch Problem
    By Gr1nderscape in forum Help
    Replies: 6
    Last Post: 01-06-2012, 08:57 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •