Thread: 55x2 NPC

Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11  
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by anaxonda View Post
    No this is in ItemOnNpc.java so that all npc's have the feature whenever a player uses an item on any.

    it's all in the right place, and it all works fine. I just cant get it to.. as an example:

    i use 40 noted shark and win; i still only get 1 extra back
    and lose; i still only lose 1 of the items.

    I want it so that it takes the entire 40 shark, or gives 40 shark extra. I just can't get it to do that. the *2 * 2 doesnt work, and i cant set up the int for "int amount = itemId.getAmount()" that part because it says the get.Amount part is wrong. So i can't use ints to make my own double int.
    Alright, so making your own ones is better?
    Owner of ThamenX
    Reply With Quote  
     

  2. #12  
    Registered Member anaxonda's Avatar
    Join Date
    Jan 2017
    Posts
    28
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by blaxe View Post
    Alright, so making your own ones is better?
    Any way i can get it to double or take the entire quantity of the item is better than it doing only 1.
    It seems like it shouldnt be so complicated.
    I love you. - Dizzy Rascal
    Reply With Quote  
     

  3. #13  
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by anaxonda View Post
    Any way i can get it to double or take the entire quantity of the item is better than it doing only 1.
    It seems like it shouldnt be so complicated.
    Thats right, post the right ones?
    Owner of ThamenX
    Reply With Quote  
     

  4. #14  
    Registered Member anaxonda's Avatar
    Join Date
    Jan 2017
    Posts
    28
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by blaxe View Post
    Thats right, post the right ones?
    post the right ones what? lol
    I love you. - Dizzy Rascal
    Reply With Quote  
     

  5. #15  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    What the flying fuck are you guys doing?
    Your method doesn't even carry on the Item object. Only the itemId and slot id are being carried. That being said, your only option is to go by the slot ID here.
    Item item = player.getInventory().getItem(slot);//Something in the lines of this. Syntax may differ. The method should return the Item object in the given slot.
    From there on, it's simple. item.getAmount() * 2 would multiply it with ease. I believe I told you that you could contact me on Skype if you needed any assistance with this stuff.
    Reply With Quote  
     

  6. #16  
    Registered Member anaxonda's Avatar
    Join Date
    Jan 2017
    Posts
    28
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Kris View Post
    What the flying fuck are you guys doing?
    Your method doesn't even carry on the Item object. Only the itemId and slot id are being carried. That being said, your only option is to go by the slot ID here.
    Item item = player.getInventory().getItem(slot);//Something in the lines of this. Syntax may differ. The method should return the Item object in the given slot.
    From there on, it's simple. item.getAmount() * 2 would multiply it with ease. I believe I told you that you could contact me on Skype if you needed any assistance with this stuff.
    Probably is best i do that lol. I ended up taking a break from it because it was stressing me.
    Clearly i have much more to learn.
    I love you. - Dizzy Rascal
    Reply With Quote  
     

  7. #17  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    28
    Posts
    2,887
    Thanks given
    417
    Thanks received
    885
    Rep Power
    856
    Quote Originally Posted by anaxonda View Post
    Probably is best i do that lol. I ended up taking a break from it because it was stressing me.
    Clearly i have much more to learn.
    Well I wrote something like this a little while ago now I'll post it here and you can reference it/maybe it'll help you.

    Code:
    package org.TAP.model.content;
    
    import org.TAP.event.CycleEvent;
    import org.TAP.event.CycleEventContainer;
    import org.TAP.event.CycleEventHandler;
    import org.TAP.model.items.ItemDefinition;
    import org.TAP.model.players.Player;
    import org.TAP.util.Misc;
    
    public class DiceNpc {
    
    	public static void diceNpc(final Player player, final int item) {
    		if (player == null || player.disconnected || player.teleporting || player.isDead) {
    			return;
    		}
    		int amount = player.getItems().getItemAmount(item);
    		if (player.getItems().freeSlots() < 2) {
    			player.sendMessage("You need atleast 2 free slots to gamble.");
    			return;
    		}
    		
    		if(!(Unspawnable.canSpawn(ItemDefinition.forId(item).getId()).length() > 1)){
    			player.getDH().sendStatement("The gambler doesn't seem to be interested in this item.");
    			return;
    		}
    		
    		player.getDH().sendStatement("Rolling...");
    		CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				if (container.getTotalTicks() == 2) {
    					container.stop();
    				}
    			}
    
    			@Override
    			public void stop() {
    				int roll = Misc.random(100);
    				if(Math.random() > 0.5) {
    					roll = Math.min(roll, Misc.random(100));
    				}
    				if (!player.getItems().playerHasItem(item)) {
    					player.getDH().sendStatement("Error! Item not found...");
    					return;
    				}
    				if (roll > 55) {
    					if (ItemDefinition.forId(item).isStackable()) {
    						player.getItems().addItem(item, amount);
    					} else if (!ItemDefinition.forId(item).isStackable()) {
    						player.getItems().addItem(item, 1);
    					}
    					player.getDH().sendStatement("Congratulations you have rolled: @blu@" + roll + "!");
    				} else if (roll < 55) {
    					if (ItemDefinition.forId(item).isStackable()) {
    						player.getItems().deleteItem(item, amount);
    					} else if (!ItemDefinition.forId(item).isStackable()) {
    						player.getItems().deleteItem(item, 1);
    					}
    					player.getDH().sendStatement("Better luck next time!");
    				}
    			}
    		}, 1);
    	}
    }


    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

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. [tut]Poison Npcs (With green splat)..
    By Santa Clause in forum Tutorials
    Replies: 9
    Last Post: 05-21-2007, 03:55 AM
  2. All Lists - item, object and NPC
    By purepkownage in forum Tools
    Replies: 2
    Last Post: 05-11-2007, 09:46 AM
  3. NPC Magic Distance Bug Fix
    By Zekkalkan in forum Tutorials
    Replies: 5
    Last Post: 05-06-2007, 07:21 PM
  4. Replies: 8
    Last Post: 05-04-2007, 09:52 PM
  5. Replies: 4
    Last Post: 05-03-2007, 03: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
  •