Thread: Quantity removing

Results 1 to 5 of 5
  1. #1 Quantity removing 
    Donator


    Join Date
    Feb 2014
    Age
    25
    Posts
    605
    Thanks given
    22
    Thanks received
    40
    Rep Power
    145
    Sounds dumb, haven't been around a private server in a while now. Cut slack, if not leave please. Thanks

    Question:
    You know how every one does removeItem(ID, 3000);
    or Whatever.

    How would I make it so, in inventoryoptionshandler for item on item. (Just to give you more details, I'm making zulrah scales on blowpipe.)

    I've tried multiple functions, all leading me to errors when I do it. Probably a slight mistake in front of my eyes. Or the biggest retard mode ever. Rather than me re-looking, coding, re-looking, I'd rather ask to save me time.

    For EX: if I'm using zulrah scale on blowpipe, how do I make it so if player has 4839 in inventory, it'll remove ALL of them in inventory.

    I don't want a ghetto rigged blowpipe. So any answers help. I'll show you my previous outlook.


    Code:
    				Item item;
    				Item[] data = null;
    				for (int i = 0; i < data.length; i++) {
    					if (data[i] != null) {
    						if (data[i].getId() == 29960) {
    							player.zulrahChargeBP += data.length;
    							player.getInventory().deleteItem(29960, data.length);
    							//player.zulrahChargeBP += aData.getAmount();
    							player.sm("You now have "+player.zulrahChargeBP+" blowpipe charges");
    							data[i] = null;
    						}
    					}
    				}
    Code:
    				int item;
    				int count = 0;
    				Item[] data = null;
    				for (Item aData : data) {
    					if (aData != null) {
    						if (aData.getId() == 29960) {
    							count += aData.getAmount();
    							player.getInventory().deleteItem(29960, aData.getAmount());
    							player.zulrahChargeBP += aData.getAmount();
    							player.sm("You now have "+player.zulrahChargeBP+" blowpipe charges");
    						}
    					}
    				}
    				return;
    				
    				//player.getInventory().deleteItem(quantity);
    				//player.zulrahChargeBP += quantity;
    				//player.sm("You now have "+quantity+" blowpipe charges");
    				
    				
    			}


    Please just tell me I'm being retarded and missed the smallest thing it'd make me smile.


    Just wanna say, my blowpipe is added, shooting with anims etc. Just adding charges now. Don't wanna buy stupid shit when I can simply add it.
    https://www.rune-server.ee/static/signaturepic/sigpic258406_2.gif
    Reply With Quote  
     

  2. #2  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,310
    Thanks received
    691
    Rep Power
    1098
    The basic logic would be;

    1). Check to see if the player has scales in their inventory;
    2). Increment the amount of scales in the blowpipe by the amount of scales in the inventory;
    3). Delete the scales from the players inventory.

    I.e.,
    Code:
    Item scales = player.inventory.lookup(29960);
    if (scales != null) {
        player.blowpipe.scales.increment(scales.amount);
        player.inventory.remove(scales);
    }
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator


    Join Date
    Feb 2014
    Age
    25
    Posts
    605
    Thanks given
    22
    Thanks received
    40
    Rep Power
    145
    Quote Originally Posted by hc747 View Post
    The basic logic would be;

    1). Check to see if the player has scales in their inventory;
    2). Increment the amount of scales in the blowpipe by the amount of scales in the inventory;
    3). Delete the scales from the players inventory.

    I.e.,
    Code:
    Item scales = player.inventory.lookup(29960);
    if (scales != null) {
        player.blowpipe.scales.increment(scales.amount);
        player.inventory.remove(scales);
    }
    Thanks a lot, easy enough, I was thinking too hard.

    Okay, heres my current source of code

    Code:
    				Item scales = player.inventory.getItem(29960);
    				if (scales != null) {
    				    //player.blowpipe.scales.increment(scales.amount);
    					player.zulrahChargeBP += scales.amount;
    				    player.inventory.deleteItem(scales);
    				}
    				
    				//player.getInventory().deleteItem(quantity);
    				//player.zulrahChargeBP += quantity;
    				player.sm("You now have "+player.zulrahChargeBP+" blowpipe charges");
    It sends me the message saying you have 0 charges which is expected. But, not when using 99k charges on blowpipe.

    I don't receive any messages, nor errors. It's not the problem item look up is my best guess. Can you provide me with your "item.lookup" or help me furtherwise? I was guessing it was inventory.contains, but its a integer in mine, and containsItem is a boolean
    https://www.rune-server.ee/static/signaturepic/sigpic258406_2.gif
    Reply With Quote  
     

  5. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,789
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Ravenboss View Post
    Thanks a lot, easy enough, I was thinking too hard.

    Okay, heres my current source of code

    Code:
    				Item scales = player.inventory.getItem(29960);
    				if (scales != null) {
    				    //player.blowpipe.scales.increment(scales.amount);
    					player.zulrahChargeBP += scales.amount;
    				    player.inventory.deleteItem(scales);
    				}
    				
    				//player.getInventory().deleteItem(quantity);
    				//player.zulrahChargeBP += quantity;
    				player.sm("You now have "+player.zulrahChargeBP+" blowpipe charges");
    It sends me the message saying you have 0 charges which is expected. But, not when using 99k charges on blowpipe.

    I don't receive any messages, nor errors. It's not the problem item look up is my best guess. Can you provide me with your "item.lookup" or help me furtherwise? I was guessing it was inventory.contains, but its a integer in mine, and containsItem is a boolean
    It's in ItemsContainer:

    Code:
        public Item lookup(int id) {
    	for (Item aData : data) {
    	    if (aData == null) {
    		continue;
    	    }
    	    if (aData.getId() == id) {
    		return aData;
    	    }
    	}
    	return null;
        }
    Project thread
    Reply With Quote  
     

  6. Thankful users:


  7. #5  
    Donator


    Join Date
    Feb 2014
    Age
    25
    Posts
    605
    Thanks given
    22
    Thanks received
    40
    Rep Power
    145
    Quote Originally Posted by clem585 View Post
    It's in ItemsContainer:

    Code:
        public Item lookup(int id) {
    	for (Item aData : data) {
    	    if (aData == null) {
    		continue;
    	    }
    	    if (aData.getId() == id) {
    		return aData;
    	    }
    	}
    	return null;
        }
    Thanks didn't realize, got it working.
    https://www.rune-server.ee/static/signaturepic/sigpic258406_2.gif
    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. Removing Flames in Client
    By Guthan in forum Tutorials
    Replies: 15
    Last Post: 07-24-2009, 10:42 PM
  2. [Tut] Adding/Moving/Removing Global Objects
    By XxMixTheMusicxX in forum Tutorials
    Replies: 17
    Last Post: 09-07-2007, 08:44 PM
  3. Removing mass click training (no kicks/bans)
    By The Unforgiven in forum Tutorials
    Replies: 13
    Last Post: 09-01-2007, 10:17 PM
  4. Replies: 7
    Last Post: 08-25-2007, 06:11 AM
  5. Removing Objects In An Area (UNTESTED)
    By Llama in forum Tutorials
    Replies: 10
    Last Post: 06-21-2007, 09:33 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
  •