Thread: Selling items to shops

Results 1 to 5 of 5
  1. #1 Selling items to shops 
    Legacy

    Join Date
    Jan 2010
    Posts
    15
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    So here's the issue..

    I've been working on a new project and it's partial spawn, so regular players can spawn items that aren't rare. The problem in short is that players can spawn items and sell them in the general store (or a shop that carries the item, for whatever reason it carries a spawnable item) for GP. Obviously I could just disable selling completely, but I still want players to be able to make money killing dragons and selling the bones for example. I've been trying to find a solution to this problem on my own for a couple weeks now, and had plenty of ideas that would work but I don't have the Java knowledge necessary to implement them yet. This is where I'll need one of you to help me, and I'm willing to pay through PayPal if the task seems too hard, otherwise you receive my kind thanks and +1 REP.

    Here's my sellToShopPrice method:

    [SPOIL]
    Code:
    	public boolean sellItem(int itemID, int fromSlot, int amount) {
    		for (int i : Config.ITEM_SELLABLE) {
    			if (i == removeId) {
    				c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+".");
    				return;
    			} 
    		}
    		boolean IsIn = false;
    		if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
    			for (int j = 0; j <= Server.shopHandler.ShopItemsStandard[c.myShopId]; j++) {
    				if (removeId == (Server.shopHandler.ShopItems[c.myShopId][j] - 1)) {
    					IsIn = true;
    					break;
    				}
    			}
    		} else {
    			IsIn = true;
    		}
    		if (IsIn == false) {
    			c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+" to this store.");
    		} else {
    			int ShopValue = (int)Math.floor(getItemShopValue(removeId, 1, removeSlot));
    			String ShopAdd = "";
    			if (ShopValue >= 1000 && ShopValue < 1000000) {
    				ShopAdd = " (" + (ShopValue / 1000) + "K)";
    			} else if (ShopValue >= 1000000) {
    				ShopAdd = " (" + (ShopValue / 1000000) + " million)";
    			}
    			c.sendMessage(c.getItems().getItemName(removeId)+": shop will buy for "+ShopValue+" coins"+ShopAdd);
    		}
    	}
    [/SPOIL]

    And here's my sellItem boolean:

    [SPOIL]
    Code:
        
        public boolean sellItem(int itemID, int fromSlot, int amount) {
    		if (c.myShopId == 3 || itemID != itemID || c.inTrade)
    			return false;
    		if (c.myShopId == 14)
    			return false;
    		for (int i : Config.ITEM_SELLABLE) {
    			if (i == itemID) {
    				c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+".");
    				return false;
    			} 
    		}
    		if(c.playerRights == 2 && !Config.ADMIN_CAN_SELL_ITEMS) {
    			c.sendMessage("Selling items as an admin has been disabled.");
    			return false;
    		}
    		
    		if (amount > 0 && itemID == (c.playerItems[fromSlot] - 1)) {
    			if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
    				boolean IsIn = false;
    				for (int i = 0; i <= Server.shopHandler.ShopItemsStandard[c.myShopId]; i++) {
    					if (itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
    						IsIn = true;
    						break;
    					}
    				}
    				if (IsIn == false) {
    					c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+" to this store.");
    					return false;
    				}
    			}
    
    			if (amount > c.playerItemsN[fromSlot] && (Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == true || Item.itemStackable[(c.playerItems[fromSlot] - 1)] == true)) {
    				amount = c.playerItemsN[fromSlot];
    			} else if (amount > c.getItems().getItemAmount(itemID) && Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == false && Item.itemStackable[(c.playerItems[fromSlot] - 1)] == false) {
    				amount = c.getItems().getItemAmount(itemID);
    			}
    			//double ShopValue;
    			//double TotPrice;
    			int TotPrice2 = 0;
    			//int Overstock;
    			for (int i = amount; i > 0; i--) {
    				TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 1, fromSlot));
    				if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995)) {
    					if (Item.itemIsNote[itemID] == false) {
    						c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
    					} else {
    						c.getItems().deleteItem(itemID, fromSlot, 1);
    					}
    					c.getItems().addItem(995, TotPrice2);
    					addShopItem(itemID, 1);
    				} else {
    					c.sendMessage("You don't have enough space in your inventory.");
    					break;
    				}
    			}
    			c.getItems().resetItems(3823);
    			resetShop(c.myShopId);
    			updatePlayerShop();
    			return true;
    		}
    		return true;
    	}
    [/SPOIL]

    Here's my idea:

    If it's possible I need someone to help me alter this so that Config.ITEM_SELLABLE works the opposite way around. This way any items I add to the list CAN be sold, and every other item in the game CANNOT. This would make it a lot easier to do what I'm trying to do with my project, because there are only going to be a handful of items players need to sell. I know I'm sort of trying to have the best of both worlds (spawn/eco) but it's just the approach I wanted to take, and I think I can make it work if I get this fixed.

    Of course if you think there's a better way to go about fixing my problem, I don't have any issues implementing that instead. I'm also open to any suggestions or criticism on what I'm trying to do, so feel free to say whatever is on your mind.

    Thanks,
    Bayrock
    Reply With Quote  
     

  2. #2  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    You could disable selling except for an array of items.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  3. #3  
    Legacy

    Join Date
    Jan 2010
    Posts
    15
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by Ninth Legion View Post
    You could disable selling except for an array of items.
    Could you or someone reading lead me in the right direction for doing this correctly?
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Nov 2010
    Posts
    1,528
    Thanks given
    1,017
    Thanks received
    348
    Rep Power
    240
    Change the value of spawnable items to 0, they sell them to shop for 0gp. Problem solved?
    None.
    Reply With Quote  
     

  5. #5  
    Proud User
    Join Date
    Feb 2011
    Posts
    530
    Thanks given
    69
    Thanks received
    28
    Rep Power
    29
    public static final int[] ITEM_SELLABLE =
    Search for that in your Config.jarba

    add the ID's there
    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. Selling items player owned and shops
    By climatikk in forum Help
    Replies: 3
    Last Post: 02-16-2012, 11:37 AM
  2. [PI] Shops DC When selling items
    By furls in forum Help
    Replies: 0
    Last Post: 12-24-2011, 11:22 PM
  3. [PI] Shops selling items problem
    By Bigger specz in forum Help
    Replies: 1
    Last Post: 09-01-2011, 06:59 PM
  4. [PI] Selling items to shops
    By Linus in forum Snippets
    Replies: 14
    Last Post: 11-17-2010, 02:10 AM
  5. Replies: 9
    Last Post: 07-16-2009, 11:52 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •