Thread: [Elvarg] Deadman Mode Raiding

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34
  1. #1 [Elvarg] Deadman Mode Raiding 
    Banned

    Join Date
    Apr 2013
    Posts
    1,614
    Thanks given
    410
    Thanks received
    475
    Rep Power
    0
    Deadman Raiding
    The deletion tab is a transparent image, so when items are in the container, you can see them as your deleting.

    So just a few quick things before we get right into the snippet, post any questions if you have any trouble adding this its pretty strait forward considering its all new classes but I'm not gunna walk anyone through settings this up if you need someone to hold your hand, wrong snippet to follow.

    This is a flawless interfaces or at least it was, it works perfect this is just a redesigned build #2 that i really never finished. I am going to include what i wrote server sided for all this to work, its up to you if you want to finish or write your own system based off my components. Regardless of your choice leave any credits due to me please i worked hard on this about a year ago. The key was drawn transparent only because i was testing placeholder opacity, the interface itself doesn't show transparent items like in the image below.

    I also remember specifically not doing anything related to setting an actual bank key item it was all a container and checking if its a real 'key', just give it a look. I'm sure there's a few things that could be redone or that im missing from this. My focus was making the interface work and building the interface itself.

    Quote Originally Posted by Russian View Post
    Can someone re-upload the sprites please? Would greatly appreciate it.
    https://mega.nz/#!l6oxmBhS!GYHBxYiRQ...1J-gR5tqJ_ticQ

    Attached image

    Spoiler for media:

    Attached image
    Attached image
    Attached image


    Client Sided
    Add both the interfaces and add the methods somewhere in the widget class.

    (bottom of load method) in the widget class
    Code:
    deadmanDeleteTabInterface(textDrawingAreas);
    deadmanInterface(textDrawingAreas);
    Interfaces
    Code:
        /*
         * OSRS Bank Raid Interface : Delete Tab Overlay
         *
         * @author trees
         */
        public static void deadmanDeleteTabInterface(GameFont[] tda) {
            Widget rsi = addInterface(22500); // by trees
            addTransparentSprite(22501, 510, 175);
    
            addHoverButton_sprite_loader(22502, 511, 68, 44, "Delete", 250, 22503,
                    4);
            addHoveredButton_sprite_loader(22503, 512, 68, 44, 22504);
            addHoverButton_sprite_loader(22506, 513, 68, 44, "Cancel", 250, 22507,
                    4);
            addHoveredButton_sprite_loader(22507, 514, 68, 44, 22508);
    
            setChildren(6, rsi);
            setBounds(22200, 0, 0, 0, rsi); // Raid Interface Back
            setBounds(22501, 100, 5, 1, rsi); // Raid Interface Back
            setBounds(22502, 175, 205, 2, rsi);
            setBounds(22503, 175, 205, 3, rsi);
            setBounds(22506, 265, 205, 4, rsi);
            setBounds(22507, 265, 205, 5, rsi);
        }
    
        /*
         * OSRS Bank Raid Interface : Main Function
         *
         * @author trees
         */
        public static void deadmanInterface(GameFont[] tda) {
            Widget rsi = addInterface(22200); // by trees
            addSprite(22201, 499);
    
            addKeyTabItem(22271, true); // Key Slot 1
            addKeyTabItem(22272, true); // Key Slot 2
            addKeyTabItem(22273, true); // Key Slot 3
            addKeyTabItem(22274, true); // Key Slot 4
            addKeyTabItem(22275, true); // Key Slot 5
    
            addText(22236, "-1", tda, 0, 0xffffff, true, true); // tab 1 value
            addText(22237, "-1", tda, 0, 0xffffff, true, true); // tab 2 value
            addText(22238, "-1", tda, 0, 0xffffff, true, true); // tab 3 value
            addText(22239, "-1", tda, 0, 0xffffff, true, true); // tab 4 value
            addText(22240, "-1", tda, 0, 0xffffff, true, true); // tab 5 value
    
            addText(22241, "tab_viewing", tda, 0, 0xFE9624, true, true); // tab
            // viewing
            // #
            addText(22242, "total", tda, 0, 0xFE9624, true); // Bank size bottom
            addText(22243, "size", tda, 0, 0xFE9624, true); // Bank size top
            addText(22244, "username", tda, 0, 0xFE9624, true, true); // playerkilled
            addText(22246, "", tda, 0, 0xFE9624, true, true); // deleteitemstext
    
            addHoverButton_sprite_loader(22208, 500, 41, 40, "Tab 1", 250, 22209, 0);
            addHoveredButton_sprite_loader(22209, 501, 41, 40, 22210);
    
            addHoverButton_sprite_loader(22211, 500, 41, 40, "Tab 2", 250, 22212, 0);
            addHoveredButton_sprite_loader(22212, 501, 41, 40, 22213);
    
            addHoverButton_sprite_loader(22214, 500, 41, 40, "Tab 3", 250, 22215, 0);
            addHoveredButton_sprite_loader(22215, 501, 41, 40, 22216);
    
            addHoverButton_sprite_loader(22217, 500, 41, 40, "Tab 4", 250, 22218, 0);
            addHoveredButton_sprite_loader(22218, 501, 41, 40, 22219);
    
            addHoverButton_sprite_loader(22220, 500, 41, 40, "Tab 5", 250, 22221, 0);
            addHoveredButton_sprite_loader(22221, 501, 41, 40, 22222);
    
            addConfigButton(22229, 22200, 502, 503, 62, 22, "Receive As Note", 1,
                    1, 1430); // Recieve as note
            addConfigButton(22230, 22200, 502, 503, 62, 22, "Receive As Item", 0,
                    1, 1432); // recieve as item
    
            addHoverButton_sprite_loader(22223, 504, 41, 40, "All to Inventory",
                    250, 22224, 4);
            addHoveredButton_sprite_loader(22224, 505, 41, 40, 22225);
            addHoverButton_sprite_loader(22226, 508, 41, 40, "Delete Tab", 250,
                    22227, 4);
            addHoveredButton_sprite_loader(22227, 509, 41, 40, 22228);
            addHoverButton_sprite_loader(22260, 506, 41, 40, "All to Bank", 250,
                    22261, 4);
            addHoveredButton_sprite_loader(22261, 507, 41, 40, 22262);
    
            addHoverButton_sprite_loader(22266, 24, 21, 21, "Close", 250, 22267, 3);
            addHoveredButton_sprite_loader(22267, 25, 21, 21, 22268);
    
            addText(22264, "Note", tda, 0, 0xFE9624, true, true); // note
            addText(22265, "Item", tda, 0, 0xFE9624, true, true); // item
    
            addRaidItem(22270); // Items Container
    
            setChildren(39, rsi);
            setBounds(22201, 100, 5, 0, rsi); // Raid Interface Back
    
            setBounds(22208, 112, 50, 1, rsi); // Tab 1
            setBounds(22209, 112, 50, 2, rsi); // Tab 1 Hovered
    
            setBounds(22211, 152, 50, 3, rsi);// Tab 2
            setBounds(22212, 152, 50, 4, rsi);// Tab 2 Hovered
    
            setBounds(22214, 192, 50, 5, rsi);// Tab 3
            setBounds(22215, 192, 50, 6, rsi);// Tab 3 Hovered
    
            setBounds(22217, 232, 50, 7, rsi);// Tab 4
            setBounds(22218, 232, 50, 8, rsi);// Tab 4 Hovered
    
            setBounds(22220, 272, 50, 9, rsi);// Tab 5
            setBounds(22221, 272, 50, 10, rsi);// Tab 5 Hovered
    
            setBounds(22236, 128, 74, 11, rsi); // tab 1 value
            setBounds(22237, 169, 74, 12, rsi); // tab 2 value
            setBounds(22238, 208, 74, 13, rsi); // tab 3 value
            setBounds(22239, 247, 74, 14, rsi); // tab 4 value
            setBounds(22240, 286, 74, 15, rsi); // tab 5 value
    
            setBounds(22241, 357, 65, 16, rsi); // tab viewing #
            setBounds(22242, 296, 298, 17, rsi); // Bank size bottom
            setBounds(22243, 296, 282, 18, rsi); // Bank size top
            setBounds(22244, 357, 75, 19, rsi); // player killed username
            setBounds(22246, 354, 73, 20, rsi); // delete items button text
    
            setBounds(22229, 114, 295, 21, rsi); // Receive Noted
            setBounds(22230, 170, 295, 22, rsi); // Receive Itemized
    
            setBounds(22223, 230, 276, 23, rsi); // All to Inventory
            setBounds(22224, 230, 276, 24, rsi); // All to Inventory Hovered
    
            setBounds(22226, 358, 276, 25, rsi); // Delete Tab & Key
            setBounds(22227, 358, 276, 26, rsi); // Delete Tab & Key
    
            setBounds(22260, 311, 276, 27, rsi); // All to BANK
            setBounds(22261, 311, 276, 28, rsi); // All to BANK Hovered
    
            setBounds(22264, 140, 300, 29, rsi); // note text
            setBounds(22265, 196, 300, 30, rsi); // item text
            setBounds(22266, 382, 15, 31, rsi); // Exit X
            setBounds(22267, 382, 15, 32, rsi); // Exit X Hovered
    
            setBounds(22270, 115, 93, 33, rsi); // Raid Items
    
            setBounds(22271, 117, 54, 34, rsi); // Key Slot 1
            setBounds(22272, 158, 54, 35, rsi); // Key Slot 2
            setBounds(22273, 196, 54, 36, rsi); // Key Slot 3
            setBounds(22274, 236, 54, 37, rsi); // Key Slot 4
            setBounds(22275, 276, 54, 38, rsi); // Key Slot 5
        }
    Methods
    Code:
        public static void addRaidItem(int index) {
            Widget rsi = interfaceCache[index] = new Widget();
            rsi.actions = new String[5];
            rsi.actions[0] = "Take 1";
            rsi.actions[1] = "Take 5";
            rsi.actions[2] = "Take X";
            rsi.spritesX = new int[20];
            rsi.inventoryAmounts = new int[28];
            rsi.inventoryItemId = new int[28];
            rsi.spritesY = new int[20];
            rsi.children = new int[0];
            rsi.childX = new int[0];
            rsi.childY = new int[0];
            rsi.spritePaddingX = 10;
            rsi.spritePaddingY = 10;
            rsi.height = 4;
            rsi.width = 7;
            rsi.parent = 22270;
            rsi.id = index;
            rsi.type = 2;
        }
    
        public static void addKeyTabItem(int index, boolean hasOption) {
            Widget rsi = interfaceCache[index] = new Widget();
            rsi.actions = new String[5];
            rsi.actions[0] = "View Key";
            rsi.spritesX = new int[20];
            rsi.inventoryAmounts = new int[1];
            rsi.inventoryItemId = new int[1];
            rsi.spritesY = new int[20];
            rsi.children = new int[0];
            rsi.childX = new int[0];
            rsi.childY = new int[0];
            rsi.spritePaddingX = 10;
            rsi.spritePaddingY = 10;
            rsi.height = 4;
            rsi.width = 7;
            rsi.parent = 22200;
            rsi.id = index;
            rsi.type = 2;
        }
    Server Sided
    Check the images above if your unsure how to layout all the classes.

    RaidInterface
    Code:
    package com.elvarg.world.content.deadman.interfaces;
    
    import com.elvarg.world.content.deadman.DeadmanUtilities;
    import com.elvarg.world.content.deadman.interfaces.RaidInterfaceData.KeySlot;
    import com.elvarg.world.entity.impl.player.Player;
    
    /**
     * Bank raiding interface
     * 
     * @author trees
     *
     */
    public class RaidInterface {
    
    	/**
    	 * @param string
    	 */
    	static void print(String string) {
    		System.out.println("[RaidInterface] : Print / " + string);
    	}
    
    	/**
    	 * Opens the interface with appropriate data
    	 * 
    	 * @param player
    	 */
    	public static void open(Player player) {
    		clear(player);
    		sendKeys(player);
    		sendItemContainer(player);
    		player.getPacketSender().sendInterface(22200);
    	}
    
    	/**
    	 * Clear the current data on interface
    	 */
    	public static void clear(Player player) {
    		for (int i = 0; i < 5; i++) {
    			player.getPacketSender().sendItemOnInterface(22271 + i, -1, 1);
    			player.getPacketSender().sendString(22236 + i, "");
    		}
    		player.getPacketSender().sendItemOnInterface(RaidInterfaceData.getMainItemsContainerId(), -1, 1);
    	}
    
    	/**
    	 * sends keys tabs
    	 * 
    	 * @param player
    	 */
    	public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] != null) {
    				if (player.getBank_key()[i].getKey_id() > 0) {
    					if (player.getInventory().contains(player.getBank_key()[i].getKey_id())
    							&& DeadmanUtilities.isValidBankKey(player, player.getBank_key()[i].getKey_id())) {
    						int tab_slot = KeySlot.forId(player.getBank_key()[i].getKey_id()).getInterfaceId();
    						player.getPacketSender().sendItemOnInterface(tab_slot, player.getBank_key()[i].getKey_id(), 1);
    					}
    				}
    			}
    		}
    	}
    
    	/**
    	 * Draw items container
    	 */
    	public static void sendItemContainer(Player player) {
    		int viewing_key = player.viewing_raid_tab;
    		if (player.getBank_key()[viewing_key] != null) {
    			player.getPacketSender().sendInterfaceItems(RaidInterfaceData.getMainItemsContainerId(),
    					player.getBank_key()[viewing_key].getValidItems());
    		}
    	}
    }
    RaidInterfaceAction
    Code:
    package com.elvarg.world.content.deadman.interfaces;
    
    import com.elvarg.world.entity.impl.player.Player;
    
    /**
     * Action handler for raid interface
     * 
     * @author trees
     */
    public class RaidInterfaceAction {
    
        static final int MAIN_ITEMS = 22270;
    
        /**
         * Main handler for button actions
         *
         * @param player
         * @param button_id
         * @return
         */
        public static boolean clickButtonAction(Player player, int button_id) {
            if (button_id == 22226) {
                player.getPacketSender().sendInterface(22500);
                return true;
            }
            return false;
        }
    
    
        /**
         * Main item clicking handler
         * @param interface_id
         * @param slot
         * @param item_id
         */
        public static void clickItemAction(Player player, int interface_id, int slot, int item_id) {
            switch (interface_id) {
                case RaidInterfaceData.MAIN_ITEMS_CONTAINER_ID:
                    break;
                case RaidInterfaceData.TAB_1:
                    player.viewing_raid_tab = 0;
                    RaidInterface.open(player);
                    break;
                case RaidInterfaceData.TAB_2:
                    player.viewing_raid_tab = 1;
                    RaidInterface.open(player);
                    break;
                case RaidInterfaceData.TAB_3:
                    player.viewing_raid_tab = 2;
                    RaidInterface.open(player);
                    break;
                case RaidInterfaceData.TAB_4:
                    player.viewing_raid_tab = 3;
                    RaidInterface.open(player);
                    break;
                case RaidInterfaceData.TAB_5:
                    player.viewing_raid_tab = 4;
                    RaidInterface.open(player);
                    break;
            }
        }
    }
    RaidInterfaceData
    Code:
    package com.elvarg.world.content.deadman.interfaces;
    
    import com.elvarg.world.model.Item;
    
    /**
     * Main class for holding the interface data
     * 
     * @author trees
     */
    public class RaidInterfaceData {
    
    	/**
    	 * main container id for items
    	 */
    	public static final int MAIN_ITEMS_CONTAINER_ID = 22270;
    	/**
    	 * main tab ids by interface
    	 */
    	public static final int TAB_1 = 22271, TAB_2 = 22272, TAB_3 = 22273, TAB_4 = 22274, TAB_5 = 22275;
    
    	/**
    	 * gets the item container id
    	 * 
    	 * @return
    	 */
    	public static int getMainItemsContainerId() {
    		return MAIN_ITEMS_CONTAINER_ID;
    	}
    	/**
    	 * A blank default key for clearing interface
    	 */
    	static Item[] default_key = { new Item(-1) };
    
    	/**
    	 * Data set for key slot
    	 * 
    	 * @return key_id
    	 * @return interface_id
    	 */
    	public enum KeySlot {
    
    		SLOT_1(13302, 22271), SLOT_2(13303, 22272), SLOT_3(13304, 22273), SLOT_4(
    				13305, 22274), SLOT_5(13306, 22275);
    
    		int key_id;
    		int interface_id;
    
    		KeySlot(int key, int inter_id) {
    			this.key_id = key;
    			this.interface_id = inter_id;
    		}
    
    		public int getKeyId() {
    			return key_id;
    		}
    
    		public int getInterfaceId() {
    			return interface_id;
    		}
    
    		public static KeySlot forId(int itemId) {
    			for (KeySlot item : KeySlot.values()) {
    				if (itemId == item.getKeyId()) {
    					return item;
    				}
    			}
    			return null;
    		}
    	}
    }
    KeyBuilder
    This is what i created keys with (usually a command for testing) It's used for building the item list and comparing the items. Also to do all the pre checks and sets but i wasn't really sure where i was going with it. With that being said, this will grab the correct item value. Item stacks (10k) ; Coin stacks (500m) ;

    Code:
     if (parts[0].startsWith("raidmyself")) {
                KeyBuilder.attemptToBuildKey(player, player);
                RaidInterface.open(player);
            }
    Code:
    package com.elvarg.world.content.deadman;
    
    import java.util.PriorityQueue;
    import java.util.Queue;
    
    import com.elvarg.definitions.ItemDefinition;
    import com.elvarg.world.content.deadman.DeadmanUtilities.ItemComparator;
    import com.elvarg.world.entity.impl.player.Player;
    import com.elvarg.world.model.Item;
    
    /**
     * Bank Key Constructor
     *
     * @author trees
     */
    public class KeyBuilder {
    
        /**
         * Constant key values
         */
        static int[] keys = {13302, 13303, 13304, 13305, 13306};
    
        /**
         * @param string
         */
        public static void print(String string) {
            System.out.println("[KeyBuilder] : Print / " + string);
        }
    
        /**
         * Item Value Comparator
         */
        public static final ItemComparator VALUE_COMPARATOR = new ItemComparator();
    
        /**
         * Initiate building process; victim to owner
         */
        public static void attemptToBuildKey(Player owner, Player victim) {
            int open_slot = DeadmanUtilities.getEmptySlot(owner);
            if (open_slot > -1 && !DeadmanUtilities.areTabsFull(owner)) {
                createBankKey(open_slot, owner, victim);
            } else {
                // TODO Create another slot; 6th key incase a player wants to drop a key
                print("Key slots are full, did not create a key.");
            }
        }
    
        /**
         * Creates a key from victims bank for killer
         *
         * @param owner
         * @param victim
         */
        public static void createBankKey(int slot, Player owner, Player victim) {
            Item[] highest_valued_items = new Item[10];
            Queue<Item> itemsToAdd = new PriorityQueue<Item>(42, VALUE_COMPARATOR);
    
            if (victim != null || owner != null) {
                for (int i = 0; i < 9; i++) {
                    if (victim.getBanks()[i] != null) {
                        itemsToAdd.addAll(victim.getBanks()[i].getValidItems());
                    }
                }
                if (!itemsToAdd.isEmpty()) {
                    for (Item i : itemsToAdd) {
                        if (i != null || i.getDefinition() == null) {
                        } else {
                            itemsToAdd.remove(i);
                        }
                    }
                    for (int i = 0; i < itemsToAdd.size(); i++) {
                        Item next = itemsToAdd.poll();
                        if (next != null && isRaidableItem(next.getId())) {
                            int original_item = next.getId();
                            int original_amount = next.getAmount();
                            next = new Item(next.getDefinition().getNoteId() > 0 ? next.getDefinition().getNoteId() : next.getId(), DeadmanUtilities.doItemCorrection(next, original_amount));
                            highest_valued_items[i] = new Item(next.getId(), next.getAmount());
                        }
                    }
                    itemsToAdd.clear();
                    owner.getBank_key()[slot] = new BankKey(owner, keys[slot], victim.getUsername(), highest_valued_items);
                }
            }
        }
    
        /**
         * Determines whether an object is raidable
         *
         * @param id
         * @return
         */
        public static boolean isRaidableItem(int id) {
            if (ItemDefinition.forId(id) == null) {
                return false;
            } else if (ItemDefinition.forId(id).isTradeable() || ItemDefinition.forId(id).isSellable()) {
                print("isRaidableItem ? Item has definition ~ [" + ItemDefinition.forId(id).getName() + "] item clear ~ "
                        + id);
                return true;
            }
            return false;
        }
    }
    BankKey
    Similar to the first class i had no idea where i was going with this either but it worked for testing and building my interface. Basically the 'key' is a container only atm and it stores all the items raided like a bank tab but it does store the key_id which is one of the keys (13302-13306) that happens to not ever change. So all in all, it was stupid to store both values considering i could use the key to determine slot or visa-versa and not need to store both. For instance key 13302 is always slot 1.
    Code:
    package com.elvarg.world.content.deadman;
    
    import com.elvarg.world.entity.impl.player.Player;
    import com.elvarg.world.model.Item;
    import com.elvarg.world.model.container.ItemContainer;
    import com.elvarg.world.model.container.StackType;
    
    /**
     * Represents Single Bank Key
     * 
     * @author trees
     */
    public class BankKey extends ItemContainer {
    
    	/*
    	 * The Victims Key ID
    	 */
    	private int key_id;
    
    	/*
    	 * The Slot On Interface
    	 */
    	int tab_slot;
    
    	/*
    	 * Owner of this key
    	 */
    	Player player;
    
    	/*
    	 * The Victim raided
    	 */
    	String victim_name;
    
    	/*
    	 * Array list of items the key holds
    	 */
    	ItemContainer items_array;
    
    	public BankKey(Player owner, int key, String victim, Item[] items) {
    		super(owner);
    		this.player = owner;
    		this.setKey_id(key);
    		this.victim_name = victim;
    		this.items_array = setItems(items);
    
    		for (int i = 0; i < getItems().length; i++) {
    			if (getItems()[i] != null) {
    				print("[Adding Data]: " + getItems()[i].getId() + " / " + getItems()[i].getAmount());
    			}
    		}
    	}
    
    	/**
    	 * Gets the total value if this bank key
    	 * 
    	 * @param tab
    	 * @return
    	 */
    	public String getValue() {
    		refreshItems();
    		int total = 0;
    		for (int i = 0; i < getItems().length; i++) {
    			if (getItems()[i] != null) {
    				Item item = getItems()[i];
    				total += (item.getDefinition().getValue() * (item.getAmount()));
    				print("Getting Item Value ~ " + item.getId() + " " + item.getDefinition().getName() + " [Item Value "
    						+ item.getDefinition().getValue() + "]" + " [Total Value = "
    						+ (item.getDefinition().getValue() * (item.getAmount())) + "]");
    			}
    		}
    		return DeadmanUtilities.formatCoins(total);
    	}
    
    	/**
    	 * DEBUGGING COPY AND PASTE
    	 * 
    	 * @param string
    	 */
    	public static void print(String string) {
    		System.out.println("[BankKey] : Print / " + string);
    	}
    
    	@Override
    	public int capacity() {
    		return 10;
    	}
    
    	@Override
    	public StackType stackType() {
    		return StackType.STACKS;
    	}
    
    	@Override
    	public ItemContainer refreshItems() {
    		if (items_array != null) {
    			setItems(items_array.getItems());
    		}
    		return this;
    	}
    
    	@Override
    	public ItemContainer full() {
    		return this;
    	}
    
    	public int getKey_id() {
    		return key_id;
    	}
    
    	public void setKey_id(int key_id) {
    		this.key_id = key_id;
    	}
    }

    DeadmanUtilities

    Code:
    package com.elvarg.world.content.deadman;
    
    import java.util.Comparator;
    
    import com.elvarg.world.content.deadman.interfaces.RaidInterfaceData.KeySlot;
    import com.elvarg.world.entity.impl.player.Player;
    import com.elvarg.world.model.Item;
    
    /**
     * Common Usage
     * 
     * @author trees
     */
    public class DeadmanUtilities {
    
    	/**
    	 * Checks if key is correct key id then checks if the key is an active bank key
    	 * the player owns
    	 * 
    	 * @param player
    	 * @param item_id
    	 * @return
    	 */
    	public static boolean isValidBankKey(Player player, int item_id) {
    		if (isBankKey(item_id)) {
    			for (int i = 0; i < player.getBank_key().length; i++) {
    				if (player.getBank_key()[i] != null) {
    					if (player.getBank_key()[i].getKey_id() == item_id) {
    						print("Key is valid [" + player.getBank_key()[i].getKey_id() + "] : Contains "
    								+ player.getBank_key()[i].getItems() + " items.");
    						return true;
    					}
    				}
    			}
    		}
    		return false;
    	}
    
    	/**
    	 * is item id infact a bank key
    	 * 
    	 * @param item_id
    	 * @return
    	 */
    	public static boolean isBankKey(int item_id) {
    		if (item_id == KeySlot.forId(item_id).getKeyId()) {
    			return true;
    		}
    		return false;
    	}
    
    	/**
    	 * Counts the amount of keys in a players inventory
    	 * 
    	 * @param player
    	 * @return
    	 */
    	public static int keysInInventory(Player player) {
    		int count = 0;
    		for (int i = 0; i < player.getInventory().getItems().length; i++) {
    			if (player.getInventory().get(i).getId() >= 13302 && player.getInventory().get(i).getId() <= 13306) {
    				print("Player has key [key] : " + player.getInventory().get(i).getId());
    				if (isValidBankKey(player, player.getInventory().get(i).getId())) {
    					count += 1;
    				}
    			}
    		}
    		return count;
    	}
    
    	/**
    	 * Finds and returns a potential empty slot
    	 * 
    	 * @param player
    	 * @return
    	 */
    	public static boolean areTabsFull(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] == null) {
    				return false;
    			}
    		}
    		return true;
    	}
    
    	/**
    	 * Finds and returns a potential empty slot
    	 * 
    	 * @param player
    	 * @return
    	 */
    	public static int getEmptySlot(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] == null) {
    				return i;
    			}
    		}
    		return -1;
    	}
    
    	/**
    	 * Compare two items values ; Returns highest
    	 * 
    	 * @author trees
    	 *
    	 */
    	public static class ItemComparator implements Comparator<Item> {
    		@Override
    		public int compare(Item arg0, Item arg1) {
    			int val1 = (!arg0.getDefinition().isTradeable()) ? 0 : arg0.getDefinition().getValue();
    			int val2 = (!arg1.getDefinition().isTradeable()) ? 0 : arg1.getDefinition().getValue();
    			if (val1 > val2)
    				return -1;
    			if (val1 < val2) {
    				return 1;
    			}
    			return 0;
    		}
    	}
    
    	/**
    	 * Corrects the item values
    	 * 
    	 * @param item
    	 * @param amount
    	 * @return
    	 */
    	public static int doItemCorrection(Item item, int amount) {
    		int new_amount = amount;
    		if (amount >= 10000 && item.getId() != 995) {
    			new_amount = 10000;
    		} else if (item.getId() == 995 && amount > 500000000) {
    			new_amount = 500000000;
    		}
    		if (amount < 10000) {
    			new_amount = amount;
    		}
    		return new_amount;
    	}
    
    	/**
    	 * Formats and returns an integer as a coin value string
    	 * 
    	 * @param amount
    	 * @return
    	 */
    	public static String formatCoins(long amount) {
    		if (amount >= 1_000 && amount < 1_000_000) {
    			return "" + (amount / 1_000) + "K";
    		}
    
    		else if (amount >= 1_000_000 && amount < 1_000_000_000) {
    			return "" + (amount / 1_000_000) + "M";
    		}
    
    		else if (amount >= 1_000_000_000 && amount < 1_000_000_000_000L) {
    			return "" + (amount / 1_000_000_000) + "B";
    		} else if (amount >= 1_000_000_000) {
    			return "@red@MAX";
    		}
    		return "" + amount;
    	}
    
    	/**
    	 * @param string
    	 */
    	public static void print(String string) {
    		System.out.println("[DeadmanUtilities] : Print / " + string);
    	}
    }
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Jan 2018
    Posts
    136
    Thanks given
    143
    Thanks received
    10
    Rep Power
    58
    Thank you ! I am not sure how to add this in yet but i will be back when i do, great job
    Reply With Quote  
     

  4. #3  
    Banned

    Join Date
    Apr 2013
    Posts
    1,614
    Thanks given
    410
    Thanks received
    475
    Rep Power
    0
    Quote Originally Posted by RspsLife View Post
    Thank you ! I am not sure how to add this in yet but i will be back when i do, great job
    Cheers
    Reply With Quote  
     

  5. #4  
    Donator

    Join Date
    Dec 2016
    Posts
    143
    Thanks given
    119
    Thanks received
    124
    Rep Power
    71
    Nice contribution.
    Reply With Quote  
     

  6. #5  
    Extreme Donator

    Kiana's Avatar
    Join Date
    May 2015
    Posts
    1,050
    Thanks given
    147
    Thanks received
    187
    Rep Power
    223
    Nice my man!
    Reply With Quote  
     

  7. #6  
    Banned

    Join Date
    Apr 2013
    Posts
    1,614
    Thanks given
    410
    Thanks received
    475
    Rep Power
    0
    Quote Originally Posted by Ints View Post
    Nice contribution.
    Quote Originally Posted by jaydon View Post
    Nice my man!
    Thanks boise
    Reply With Quote  
     

  8. #7  
    Banned

    Join Date
    Oct 2013
    Posts
    570
    Thanks given
    3
    Thanks received
    60
    Rep Power
    0
    verry nice thanks alot for this
    Reply With Quote  
     

  9. #8  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] != null) {
    				if (player.getBank_key()[i].getKey_id() > 0) {
    					if (player.getInventory().contains(player.getBank_key()[i].getKey_id())
    							&& DeadmanUtilities.isValidBankKey(player, player.getBank_key()[i].getKey_id())) {
    						int tab_slot = KeySlot.forId(player.getBank_key()[i].getKey_id()).getInterfaceId();
    						player.getPacketSender().sendItemOnInterface(tab_slot, player.getBank_key()[i].getKey_id(), 1);
    					}
    				}
    			}
    		}
    	}
    Avoid this plz ^.

    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBankKey()[i] == null || player.getBankKey()[i].getKeyId() <= 0
    				|| !player.getInventory().contains(player.getBankKey()[i].getKeyId()) || !DeadmanUtilities.isValidBankKey(player, player.getBankKey()[i].getKeyId()))
    				continue;
    			final int tabSlot = KeySlot.forId(player.getBankKey()[i].getKeyId()).getInterfaceId();
    			player.getPacketSender().sendItemOnInterface(tabSlot, player.getBankKey()[i].getKeyId(), 1);
    		}
    	}
    Ty.
    Excuse poor formatting, modified it in this editor box.
    Attached image
    Reply With Quote  
     

  10. #9  
    Banned

    Join Date
    Dec 2017
    Posts
    89
    Thanks given
    12
    Thanks received
    27
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] != null) {
    				if (player.getBank_key()[i].getKey_id() > 0) {
    					if (player.getInventory().contains(player.getBank_key()[i].getKey_id())
    							&& DeadmanUtilities.isValidBankKey(player, player.getBank_key()[i].getKey_id())) {
    						int tab_slot = KeySlot.forId(player.getBank_key()[i].getKey_id()).getInterfaceId();
    						player.getPacketSender().sendItemOnInterface(tab_slot, player.getBank_key()[i].getKey_id(), 1);
    					}
    				}
    			}
    		}
    	}
    Avoid this plz ^.

    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBankKey()[i] == null || player.getBankKey()[i].getKeyId() <= 0
    				|| !player.getInventory().contains(player.getBankKey()[i].getKeyId()) || !DeadmanUtilities.isValidBankKey(player, player.getBankKey()[i].getKeyId()))
    				continue;
    			final int tabSlot = KeySlot.forId(player.getBankKey()[i].getKeyId()).getInterfaceId();
    			player.getPacketSender().sendItemOnInterface(tabSlot, player.getBankKey()[i].getKeyId(), 1);
    		}
    	}
    Ty.
    Excuse poor formatting, modified it in this editor box.
    Just for personal curiosity, is the only difference of having if statements opposed to || to make it cleaner, it does it effect the performance?
    Reply With Quote  
     

  11. #10  
    Banned

    Join Date
    Apr 2013
    Posts
    1,614
    Thanks given
    410
    Thanks received
    475
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBank_key()[i] != null) {
    				if (player.getBank_key()[i].getKey_id() > 0) {
    					if (player.getInventory().contains(player.getBank_key()[i].getKey_id())
    							&& DeadmanUtilities.isValidBankKey(player, player.getBank_key()[i].getKey_id())) {
    						int tab_slot = KeySlot.forId(player.getBank_key()[i].getKey_id()).getInterfaceId();
    						player.getPacketSender().sendItemOnInterface(tab_slot, player.getBank_key()[i].getKey_id(), 1);
    					}
    				}
    			}
    		}
    	}
    Avoid this plz ^.

    Code:
    public static void sendKeys(Player player) {
    		for (int i = 0; i < 5; i++) {
    			if (player.getBankKey()[i] == null || player.getBankKey()[i].getKeyId() <= 0
    				|| !player.getInventory().contains(player.getBankKey()[i].getKeyId()) || !DeadmanUtilities.isValidBankKey(player, player.getBankKey()[i].getKeyId()))
    				continue;
    			final int tabSlot = KeySlot.forId(player.getBankKey()[i].getKeyId()).getInterfaceId();
    			player.getPacketSender().sendItemOnInterface(tabSlot, player.getBankKey()[i].getKeyId(), 1);
    		}
    	}
    Ty.
    Excuse poor formatting, modified it in this editor box.
    Problem is with the way you have demonstrated, your gunna run into errors checking a key_id that may or may not be null that’s why we check only if it’s null first, I have it broken down in order to prevent exactly that. If you hit an a null it won’t continue and try and check the other options.

    So no I wouldn’t suggest that kris.
    Reply With Quote  
     

Page 1 of 4 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. Replies: 4
    Last Post: 06-29-2017, 03:05 PM
  2. Replies: 100
    Last Post: 07-10-2016, 12:51 PM
  3. Replies: 61
    Last Post: 05-29-2016, 09:17 PM
  4. [PI] Deadman mode Bank Key/Bank Raid System
    By 2nubs1cup in forum Buying
    Replies: 5
    Last Post: 02-07-2016, 01:54 AM
  5. Deadman mode bank raid interface
    By Pandemia in forum Graphics
    Replies: 7
    Last Post: 02-02-2016, 12: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
  •