Thread: Fully destroy Item in a 508

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 [508]: Full destroy Item 
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    The result:

    http://tinypic.com/player.php?v=avsfbo&s=5


    Description: In this tutorial, you will be creating the Destroy item option.
    Difficulty: 2/10
    Assumed Knowledge: How to read.
    Tested Server: Palidino76's 508
    Files Modified: Player.java, PacketManager.java, DropItem.java.


    Procedure


    Step one.

    First, you need to add your untradable items that you want to be able to be destroyed, to the 'untradable' array, which is located in items.java. If you do not know where items.java is, then look for it yourself.

    The array will look something like this:

    Code:
    untradable[] = {####, ####};

    It is obvious that the '####' should be the item Id's that need to be placed in there, so add any item Id's in there, that you wish to be untradable.
    For example the Firecape Id, is 6570. I have that in my Untradable array.


    Step two.

    In player.java, you now need to declare the destroy Item arrays:

    Code:
        /**
         * Destroy item arrays
         */
        public int[] destroyItem = new int[28];
        public int[] destroyItemAmt = new int[28];

    And the variable:

    Code:
        /**
         * Destroy item variable
         */
        public int destroyItemInt;


    Step three

    You now need to open up DropItem.java.

    You will see this:

    Code:
    if (!Engine.items.isUntradable(itemId)) {

    The codes below that, until the closing bracket of that 'if' statement, are for items that are not in the 'untradable' array.
    So find the closing bracket for that specific 'if' statement (It will be in line with it if you are having trouble finding it).

    Once you have found it, replace it with this:

    Code:
            } else if (Engine.items.isUntradable(itemId)) {
                for (int i = 0; i < p.items.length; i++) {
    		p.destroyItem[i] = itemId;
    		p.destroyItemAmt[i] = 1;
    		p.destroyItemInt = itemId;
    		p.frames.showChatboxInterface(p, 94);
    		p.frames.setString(p, "Clicking yes will permanently delete this item.", 94, 11);
    		p.frames.setString(p, "", 94, 10);
    		p.frames.setString(p, "If you want to keep this item click no.", 94, 12);
    		p.frames.setString(p, ""+ Engine.items.getItemName(itemId) +"", 94, 13);
    		p.frames.setItems(p, 94, 0, 1, p.destroyItem, p.destroyItemAmt);
    	    }
    	}

    The 'else if' statement is the statement that allows us to place codes for items that Are in the 'untradable' array.

    Code:
    for (int i = 0; i < p.items.length; i++) {
    ^ This Is the loop through all the items in the inventory.

    Code:
    p.destroyItem[i] = itemId;
    ^ This is making the Loop variable (i) in the destroyItem array, equal the item Id that you are trying to destroy/drop.


    Code:
    p.destroyItemAmt[i] = 1;
    ^ This is making the Amount of the item being destroyed, 1, since nearly all destroyable items are Unstackable.


    Code:
    p.frames.showChatboxInterface(p, 94);
    ^ This is showing the Destroy Item interface in the chatbox area.

    Code:
    p.frames.setString(p, "Clicking yes will permanently delete this item.", 94, 11);
    p.frames.setString(p, "", 94, 10);
    p.frames.setString(p, "If you want to keep this item click no.", 94, 12);
    Those three lines are setting the strings of the text on the chatbox interface.


    Code:
    p.frames.setString(p, ""+ Engine.items.getItemName(itemId) +"", 94, 13);
    That line is setting the string of the item you are trying to destroy.


    And finally:

    Code:
    p.frames.setItems(p, 94, 0, 1, p.destroyItem, p.destroyItemAmt);
    That is setting the item that is going to be destroyed, onto the interface, along with the Amount of the item (1).



    Step five.

    We now have the full destroy item interface showing in the Chatbox, but the buttons do not do anything yet, so that is what we are going to add next.

    Now head over to PacketManager.java.
    Go down to packet 63.
    If you do not already have it, this is a simple example of the packet that you can add:

    Code:
    case 63:
        p.frames.removeChatboxInterface(p);
        break;


    First off, add these to the packet:

    Code:
    int clickId = p.stream.readUnsignedWord();
    int clickId2 = p.stream.readUnsignedWord();

    Those will be used to section off the options.
    Now you need to make a switch statement out of that integer:

    Code:
    switch (clickId2) {

    In this switch statement, there needs to be two 'cases'; Case 1024 and Case 1280.

    Case 1024 is the 'Yes' Option on the destroy Item interface.
    Case 1280 is the 'No' Option on the destroy Item interface, and will remove the chatbox interface.

    Here are the two Cases:

    Case 1024:
    Code:
    case 1024: // Yes option
        if (p.destroyItemInt > 0) {
    	Server.engine.playerItems.deleteItem(p, p.destroyItemInt, Server.engine.playerItems.getItemSlot(p, p.destroyItemInt), 1);
    	p.destroyItemInt = 0;
    	p.frames.removeChatboxInterface(p);	
        }					
        break;
    This will get the item slot of the item to be destroyed, and delete that item. (This is incase the player has two of the item). It will also reset the 'destroyItemInt' integer.


    Case 1280:
    Code:
    case 1280: // No option
        p.destroyItemInt = 0;
        p.frames.removeChatboxInterface(p);
        break;
    That will simply remove the chatbox interface, and reset the 'destroyItemInt' integer.

    Finally you need to add a closing bracket to end the switch statement.

    Now you can save all the files you have edited, compile, and run.

    Once more, the result:

    http://tinypic.com/player.php?v=avsfbo&s=5


    Enjoy.
    Last edited by Profesor Oak; 01-03-2009 at 06:31 PM. Reason: Spelt something wrong
    Reply With Quote  
     

  2. #2  
    Valar Morghulis

    Laxika's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    2,813
    Thanks given
    1,804
    Thanks received
    274
    Rep Power
    2128
    Nice! I need this... rep++
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,340
    Thanks given
    20
    Thanks received
    575
    Rep Power
    1202
    Now i can 0rgasm more freely.

    Thanks for releasing this Prima.
    Reply With Quote  
     

  4. #4  
    ̿ ̿̿ ̿̿ ̿̿̿'̿'\̵͇̿̿\=(•̪

    Dragonking's Avatar
    Join Date
    May 2008
    Posts
    2,011
    Thanks given
    16
    Thanks received
    31
    Rep Power
    567
    thank you i will do it later lol O.o good job =P why i do and it works rep++
    Reply With Quote  
     

  5. #5  
    Registered Member
    Kyye's Avatar
    Join Date
    May 2008
    Posts
    611
    Thanks given
    1
    Thanks received
    10
    Rep Power
    86
    Nicely done, looks good
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    Thanks for the good comments everyone .
    Reply With Quote  
     

  7. #7  
    ( ͡° ͜ʖ ͡°)
    Edgeville's Avatar
    Join Date
    Nov 2007
    Posts
    2,453
    Thanks given
    80
    Thanks received
    428
    Rep Power
    2589
    Nice Prima, Thanks alot

    Attached image
    Reply With Quote  
     

  8. #8  
    Officially Retired

    Huey's Avatar
    Join Date
    Jan 2008
    Age
    22
    Posts
    16,478
    Thanks given
    3,385
    Thanks received
    7,727
    Rep Power
    5000
    will try this thanks repped yah man
    Attached image
    Listen children don't become this guy.
    Quote Originally Posted by Owner Spikey View Post
    Why can I attack lower level npc's in a matter of a mouse hover but for a higher level npc the only choice to attack is by right clicking option attack?

    Reply With Quote  
     

  9. #9  
    SYthon
    Guest
    4500 I think thats the sound id for destroying an item lol.
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    Quote Originally Posted by SYthon View Post
    4500 I think thats the sound id for destroying an item lol.
    I'll take a look now.

    I don't think it is.
    Last edited by Profesor Oak; 01-03-2009 at 09:35 PM. Reason: Double posting is not allowed!
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •