Thread: [718] Money-Pouch Release

Page 1 of 8 123 ... LastLast
Results 1 to 10 of 77
  1. #1 [718] Money-Pouch Release 
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,919
    Thanks given
    480
    Thanks received
    1,687
    Rep Power
    1262
    The help section can be found if you click http://www.rune-server.org/runescape...t-server/help/. Please don't ask for help here.

    Bare in mind this is a snippet and not fully operational unless you do a few minor edits to your server.

    Code:
    package com.rs.game.player.content;
    
    import java.io.Serializable;
    import java.text.DecimalFormat;
    
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    
    public class MoneyPouch implements Serializable {
    
    	private static final long serialVersionUID = -3847090682601697992L;
    
    	private transient Player player;
    	private boolean usingPouch;
    	private int coinAmount;
    
    	public MoneyPouch(Player player) {
    		this.player = player;
    	}
    
    	public void switchPouch() {
    		usingPouch = !usingPouch;
    		refresh(true);
    	}
    
    	private void refresh(boolean swap) {
    		if (swap)
    			player.getPackets().sendRunScript(5557, 1);
    		player.getPackets().sendRunScript(5560, coinAmount);
    	}
    
    	public void sendDynamicInteraction(int amount, boolean remove) {
    		int newAmount = remove ?  amount - coinAmount : amount + coinAmount;
    		Item item = new Item(995, amount - (remove ? 0 : Integer.MAX_VALUE));
    		if (remove) {
    			if (newAmount <= 0) {
    				if (player.getInventory().containsItem(item.getId(), item.getAmount())) 
    					player.getInventory().getItems().remove(item);
    				else
    					player.getPackets().sendGameMessage("You don't have enough coins.");
    				return;
    			} else
    				player.getPackets().sendGameMessage(getFormattedNumber(amount) +" coins have been removed from your money pouch.");
    		} else {
    			if (newAmount > Integer.MAX_VALUE) {
    				if (player.getInventory().getItems().add(item))
    					player.getPackets().sendGameMessage("Your money-pouch is currently full. Your coins will now go to your inventory.");
    				else
    					player.getPackets().sendGameMessage("Your inventory is currently full.");
    				return;
    			} else
    				player.getPackets().sendGameMessage(getFormattedNumber(amount) +" coins have been added to your money pouch.");
    		}
    		setAmount(newAmount, amount, remove);
    	}
    
    	private String getFormattedNumber(int amount) {
    		return new DecimalFormat("#,###,##0").format(amount).toString();
    	}
    
    	public void sendExamine() {
    		player.getPackets().sendGameMessage("Your money pouch current contains " + getFormattedNumber(coinAmount) + " coins.");
    	}
    
    	private void setAmount(int coinAmount, int addedAmount, boolean remove) {
    		this.coinAmount = coinAmount;
    		player.getPackets().sendRunScript(5561 , remove ? 0 : 1, addedAmount);
    		refresh(false);
    	}
    
    	public boolean isUsingPouch() {
    		return usingPouch;
    	}
    
    	public int getCoinsAmount() {
    		return coinAmount;
    	}
    }
    Buttonhandler stuff.

    Code:
    } else if ((interfaceId == 746 && componentId == 207) || (interfaceId == 548 && componentId == 159)) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
    					player.getMoneyPouch().switchPouch();
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
    					
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					player.getMoneyPouch().sendExamine();
    				else 
    					if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
    						if (player.getInterfaceManager().containsScreenInter()) {
    							player.getPackets()
    							.sendGameMessage(
    									"Please finish what you're doing before opening the price checker.");
    							return;
    						}
    						player.stopAll();
    						player.getPriceCheckManager().openPriceCheck();
    					}
    			}
    Code:
     public void depositMoneyPouch(boolean banking) {
    		int coinsCount = player.getMoneyPouch().getCoinsAmount();
    		int space = addItems(new Item[] {new Item(955, coinsCount) }, banking);
    		if(space != 0) {
    			if (space < 1) {
    				player.getPackets().sendGameMessage("Not enough space in your bank.");
    				return;
    			}
    			player.getMoneyPouch().sendDynamicInteraction(coinsCount, true);
    		}
    	}
    Things that aren't included in the release.

    • Withdrawl (I dont want to post a new system).


    I was going to release this before Vincent released the cs, however he beat me to it as I had to sleep (faggot). Enjoy, think of this as my welcome back prezzie to all.

    Implementation for player :


    Quote Originally Posted by Cjay0091 View Post
    Declare this in player.java

    Code:
     private MoneyPouch pouch;
    Find the method init in Player.java and put this :

    Code:
     pouch = new MoneyPouch(this);
    under

    Code:
     petManager.setPlayer(this);
    Finally add the getter.

    Code:
     public MoneyPouch getMoneyPouch() {
    		return pouch;
    	}
    Attached image
    Reply With Quote  
     


  2. #2  
    Contributor

    .ssh's Avatar
    Join Date
    Jul 2012
    Posts
    934
    Thanks given
    421
    Thanks received
    570
    Rep Power
    248
    Good job mate.
    Reply With Quote  
     

  3. #3  
    Extreme Donator [718] Money-Pouch Release Market Banned



    Join Date
    Dec 2010
    Age
    25
    Posts
    6,060
    Thanks given
    1,692
    Thanks received
    1,238
    Rep Power
    1765
    Thanks, pretty sure Peril will find this useful.
    Reply With Quote  
     

  4. #4  
    (づ。◕‿‿◕。)づ
    macalroy's Avatar
    Join Date
    Jun 2011
    Posts
    1,123
    Thanks given
    717
    Thanks received
    297
    Rep Power
    12
    Thank you, Cjay.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2011
    Posts
    183
    Thanks given
    7
    Thanks received
    13
    Rep Power
    44
    Nice, i like the your use on the sendDynamicInteraction
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    May 2012
    Posts
    989
    Thanks given
    19
    Thanks received
    28
    Rep Power
    0
    good release
    Attached image
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Aug 2011
    Posts
    56
    Thanks given
    0
    Thanks received
    4
    Rep Power
    5
    Release the rest pl0x
    Reply With Quote  
     

  8. #8  
    #FLAWLESSDUPES

    Monum3ntal's Avatar
    Join Date
    Oct 2011
    Posts
    704
    Thanks given
    35
    Thanks received
    83
    Rep Power
    92
    i get nullpointers

    EDIT: nvm fixed it
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,919
    Thanks given
    480
    Thanks received
    1,687
    Rep Power
    1262
    Quote Originally Posted by monum3ntal View Post
    i get nullpointers
    You didn't implement it properly then.
    Attached image
    Reply With Quote  
     

  10. Thankful users:


  11. #10  
    (づ。◕‿‿◕。)づ
    macalroy's Avatar
    Join Date
    Jun 2011
    Posts
    1,123
    Thanks given
    717
    Thanks received
    297
    Rep Power
    12
    Quote Originally Posted by icyphat View Post
    Release the rest pl0x
    Make it yourself.... Jesus, idiots these days.
    Reply With Quote  
     

  12. Thankful users:


Page 1 of 8 123 ... LastLast

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. 667 & 718 Summoning Pouch Creation.
    By kingcobra805 in forum Snippets
    Replies: 34
    Last Post: 01-01-2013, 12:01 AM
  2. 718 Pouch/Scroll Creation
    By kingcobra805 in forum Buying
    Replies: 0
    Last Post: 07-24-2012, 02:53 PM
  3. Money Pouch 667/718
    By RezoScape in forum Requests
    Replies: 2
    Last Post: 06-14-2012, 07:21 PM
  4. Replies: 15
    Last Post: 06-10-2012, 01:32 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
  •