Thread: 718 Money Pouch + Shop

Page 1 of 14 123 11 ... LastLast
Results 1 to 10 of 132
  1. #1 718 Money Pouch + Shop 
    Registered Member
    maffia-rpg's Avatar
    Join Date
    Jul 2011
    Posts
    2,681
    Thanks given
    578
    Thanks received
    714
    Rep Power
    121
    Player.java

    Declare this:
    Code:
    	//money pouch
    	public int money = 0;
    And add this method:
    Code:
    	public void refreshMoneyPouch() {
    		//getPackets().sendConfig(1438, (money >> 16) | (money >> 8) & money);
    		getPackets().sendRunScript(5560, money);
    	}
    ButtonHandler.java

    Replace:
    Code:
    else if ((interfaceId == 746 && componentId == 207) || (interfaceId == 548 && componentId == 159)) {
    				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();
    				}
    			}
    With:
    Code:
    else if ((interfaceId == 746 && componentId == 207) || (interfaceId == 548 && componentId == 159)
    					|| (interfaceId == 548 && componentId == 194)) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
    					if (!player.getInterfaceManager().containsScreenInter()) {
    						player.getPackets().sendRunScript(5557, 1);
    						player.refreshMoneyPouch();
    					} else
    						player.getPackets().sendGameMessage("Please finish first with what your doing.");
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET){
    					player.getTemporaryAttributtes().put("remove_X_money", 995);
    					player.getTemporaryAttributtes().put("remove_money", Boolean.TRUE);
    					player.getPackets().sendRunScript(108, new Object[] { "                          Your money pouch contains " + player.money + " coins." + "                           How many would you like to withdraw?"});
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET){
    					player.getPackets().sendGameMessage("Your money pouch currently contains " + player.money + " coins.");
    				} 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();
    				}
    			}
    WorldPacketsDecoder.java

    In the ENTER_INTEGER_PACKET:

    Code:
    else if (player.getInterfaceManager().containsInterface(548) ||
    						player.getInterfaceManager().containsInterface(746)) {
    				if (value < 0)
    					return;
    				Integer remove_X_money = (Integer) player.getTemporaryAttributtes().remove("remove_X_money");
    				if (remove_X_money == null)
    					return;
    				int amount = player.getInventory().getItems().getNumberOf(remove_X_money);
    				if (player.getTemporaryAttributtes().remove("remove_money") != null) {
    					if (value <= player.money) {
    						if (amount + value > 0) {
    							player.getInventory().addItem(remove_X_money, value);
    							player.getPackets().sendRunScript(5561, 0, value);
    							player.money -= value;
    							player.refreshMoneyPouch();
    						} else {
    							player.getPackets().sendGameMessage("You can't have more then 2147483647 coins in your inventory.");
    						}
    					} else {
    						player.getPackets().sendGameMessage("You don't have enough coins to withdraw that many.");
    					}
    				}
    			}
    InventoryOptionsHandler.java

    In handleitemoption6:

    Code:
    else if (itemId == 995) {
    			int amount = player.getInventory().getItems().getNumberOf(995);
    			if (player.money + amount > 0) {
    				player.getInventory().deleteItem(995, amount);
    				player.getPackets().sendRunScript(5561, 1, amount);
    				player.money += amount;
    				player.refreshMoneyPouch();
    			} else {
    				player.getPackets().sendGameMessage("You can't have more then 2147483647 coins in your pouch.");
    			}
    		}

    Shop.java


    Replace your buy and sell method with these:

    Code:
    	public void buy(Player player, int clickSlot, int quantity) {
    		if (clickSlot >= getStoreSize())
    			return;
    		Item item = clickSlot >= mainStock.length ? generalStock[clickSlot
    				- mainStock.length] : mainStock[clickSlot];
    		if (item == null)
    			return;
    		if (item.getAmount() == 0) {
    			player.getPackets().sendGameMessage(
    					"There is no stock of that item at the moment.");
    			return;
    		}
    		int dq = clickSlot >= mainStock.length ? 0 : defaultQuantity[clickSlot];
    		int price = getBuyPrice(item, dq);
    		int amountCoins = player.getInventory().getItems().getNumberOf(money);
    		int amountInPouch = player.money;
    		int maxPouch = amountInPouch / price;
    		int maxQuantity = amountCoins / price;
    		int buyQ = item.getAmount() > quantity ? quantity : item.getAmount();
    
    		boolean enoughCoins = maxQuantity >= buyQ;
    		boolean enoughInPouch = maxPouch >= buyQ;
    		if (!enoughCoins && !enoughInPouch) {
    			player.getPackets().sendGameMessage("You don't have enough coins.");
    			buyQ = maxQuantity;
    		} else if (quantity > buyQ) {
    			player.getPackets().sendGameMessage("The shop has run out of stock.");
    			if (item.getDefinitions().isStackable()) {
    				if (player.getInventory().getFreeSlots() < 1) {
    					player.getPackets().sendGameMessage("Not enough space in your inventory.");
    					return;
    				}
    			}
    		} else {
    			int freeSlots = player.getInventory().getFreeSlots();
    			if (buyQ > freeSlots) {
    				buyQ = freeSlots;
    				player.getPackets().sendGameMessage("Not enough space in your inventory.");
    			}
    		}
    		if (buyQ != 0) {
    			int totalPrice = price * buyQ;
    			if (amountCoins + price > 0) {
    				if (enoughInPouch) {
    					player.getPackets().sendRunScript(5561, 0, totalPrice);
    					player.money -= totalPrice;
    					player.getInventory().addItem(item.getId(), buyQ);
    					player.refreshMoneyPouch();
    				} else {
    					player.getInventory().deleteItem(money, totalPrice);
    					player.getInventory().addItem(item.getId(), buyQ);
    				}
    				item.setAmount(item.getAmount() - buyQ);
    				if (item.getAmount() <= 0 && clickSlot >= mainStock.length)
    					generalStock[clickSlot - mainStock.length] = null;
    				refreshShop();
    				sendInventory(player);
    			} else {
    				player.getPackets().sendGameMessage("You can't have more then 2147M coins in your inventory.");
    				return;
    			}
    		}
    	}
    Code:
    	public void sell(Player player, int slotId, int quantity) {
    		if (player.getInventory().getItemsContainerSize() < slotId)
    			return;
    		Item item = player.getInventory().getItem(slotId);
    		if (item == null)
    			return;
    		int originalId = item.getId();
    		if (item.getDefinitions().isNoted())
    			item = new Item(item.getDefinitions().getCertId(), item.getAmount());
    		if (item.getDefinitions().isDestroyItem()
    				|| ItemConstants.getItemDefaultCharges(item.getId()) != -1
    				|| !ItemConstants.isTradeable(item) || item.getId() == money) {
    			player.getPackets().sendGameMessage("You can't sell this item.");
    			return;
    		}
    		int dq = getDefaultQuantity(item.getId());
    		if (dq == -1 && generalStock == null) {
    			player.getPackets().sendGameMessage(
    					"You can't sell this item to this shop.");
    			return;
    		}
    		int price = getSellPrice(item, dq);
    		int numberOff = player.getInventory().getItems().getNumberOf(originalId);
    		if (quantity > numberOff)
    			quantity = numberOff;
    		if (!addItem(item.getId(), quantity)) {
    			player.getPackets().sendGameMessage("Shop is currently full.");
    			return;
    		}
    		if (player.money + price > 0) {
    			player.getInventory().deleteItem(originalId, quantity);
    			//player.getInventory().addItem(money, price * quantity);
    			player.money += price * quantity;
    			player.getPackets().sendRunScript(5561, 1, price * quantity);
    		} else {
    			player.getPackets().sendGameMessage("You can't have more then 2147483647 coins in your pouch.");
    			return;
    		}
    	}
    Credits:
    noobscape (script ids)
    me
    Quote Originally Posted by Cjay0091 View Post
    Go back to coding your 718 rofl.
    Quote Originally Posted by Cjay0091 View Post
    Can you read english? I never blamed anyone?
    Reply With Quote  
     


  2. #2  
    Donator


    Join Date
    Sep 2006
    Age
    21
    Posts
    2,102
    Thanks given
    73
    Thanks received
    53
    Rep Power
    491
    sexy
    Reply With Quote  
     

  3. #3  
    Registered Member
    Vip3r's Avatar
    Join Date
    Oct 2011
    Age
    18
    Posts
    1,875
    Thanks given
    748
    Thanks received
    852
    Rep Power
    131
    Why? (fp) still gj.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    #FLAWLESSDUPES

    Monum3ntal's Avatar
    Join Date
    Oct 2011
    Posts
    693
    Thanks given
    33
    Thanks received
    79
    Rep Power
    87
    is this your old way or the actual rs way?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Vip3r's Avatar
    Join Date
    Oct 2011
    Age
    18
    Posts
    1,875
    Thanks given
    748
    Thanks received
    852
    Rep Power
    131
    Buggy, but not hard to fix, still gj bro.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    Registered Member
    Vip3r's Avatar
    Join Date
    Oct 2011
    Age
    18
    Posts
    1,875
    Thanks given
    748
    Thanks received
    852
    Rep Power
    131
    Quote Originally Posted by monum3ntal View Post
    is this your old way or the actual rs way?
    He's attempted RS way I think, from what I can see, but there are bugs


    so far:

    Cant take cash out of pouch.

    There's a max of 2147M on it, if you put the max amount in, then try to add more, it completely empties the pouch.

    Also. "player.getPackets().sendGameMessage("You can't have more then 2147483647 coins in your inventory.");" - more 'than' 2147483647*
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    May 2012
    Posts
    575
    Thanks given
    13
    Thanks received
    21
    Rep Power
    11
    u forgot the withdraw is not working properly unless i did something wrong
    My Dedicated Server Speedtest

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #8  
    MBScape 723 Owner


    Join Date
    Oct 2008
    Age
    19
    Posts
    1,432
    Thanks given
    11
    Thanks received
    32
    Rep Power
    302
    getBuyPrice in the buy void in Shops.java gives me an error.
    Reply With Quote  
     

  9. #9  
    #FLAWLESSDUPES

    Monum3ntal's Avatar
    Join Date
    Oct 2011
    Posts
    693
    Thanks given
    33
    Thanks received
    79
    Rep Power
    87
    Quote Originally Posted by Vip3r View Post
    He's attempted RS way I think, from what I can see, but there are bugs


    so far:

    Cant take cash out of pouch.

    There's a max of 2147M on it, if you put the max amount in, then try to add more, it completely empties the pouch.

    Also. "player.getPackets().sendGameMessage("You can't have more then 2147483647 coins in your inventory.");" - more 'than' 2147483647*
    well then i wont replace with myn than lol
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Sep 2009
    Posts
    1,605
    Thanks given
    300
    Thanks received
    956
    Rep Power
    656
    Bad way to do this, and not a tutorial as it doesn't explain anything.
    Reply With Quote  
     

  11. Thankful users:


Page 1 of 14 12311 ... LastLast

Thread Information
Users Browsing this Thread

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

Similar Threads

  1. [718] Money-Pouch Release
    By Cjay0091 in forum Snippets
    Replies: 76
    Last Post: 09-14-2013, 01:38 PM
  2. Money Pouch 667/718
    By RezoScape in forum Requests
    Replies: 2
    Last Post: 06-14-2012, 07:21 PM
  3. 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
  •