Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • FaTe_Of_GoDs: You guys have an offline client?
      Today at 03:25:13 AM
    • ASDss: where do u download source and clients now
      August 18, 2017, 10:39:31 PM
    • ASDss: yo
      August 18, 2017, 10:39:20 PM
    • dan v jad: click me 4 da fun ;)[link]
      August 18, 2017, 04:39:58 PM
    • stCky: Palidinho is your OpenGL (was it OpenGL?) stuff open source anywhere?
      August 16, 2017, 09:07:22 PM
    • Travas:BUILD THE WALL
      August 15, 2017, 09:28:49 PM
    • Travas: i have ass cancer
      August 15, 2017, 09:23:29 PM
    • stCky: what are the fudge are you tryna ask?
      August 15, 2017, 08:21:35 PM
    • bader: what are the rsps community alive ?
      August 15, 2017, 05:46:16 PM
    • bader: yo guys
      August 15, 2017, 05:46:08 PM
    • Spacehost:[link] Updated our thread :)
      August 15, 2017, 09:40:34 AM
    • Adaro: The client is in Download section at Homepage
      August 15, 2017, 01:09:20 AM
    • FaTe_Of_GoDs: where do i get the client?????????????
      August 14, 2017, 05:23:14 PM
    • stCky: can anyone help me? I cant login to the shoutbox
      August 13, 2017, 05:45:15 PM
    • drubrkletern: appeal denied
      August 13, 2017, 02:35:27 PM
    • King_Trout:[link]
      August 13, 2017, 11:17:12 AM
    • Cole1497: no sorry
      August 13, 2017, 10:27:14 AM
    • ayz: yo can anyone explain something to me
      August 13, 2017, 08:08:51 AM
    • coolking12: Hi
      August 13, 2017, 04:16:06 AM
    • stCky: n+1
      August 11, 2017, 06:09:24 PM

    Author Topic: Dropitem.java  (Read 942 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Dropitem.java
    « on: May 29, 2015, 03:37:17 PM »
    What is wrong here? i cant get any items to drop on ground manually like if i right click an item and click drop, it just disappears
    anyone have the right code for this?
    Code: [Select]
    package ardi.model.players.packets;

    import ardi.Config;
    import ardi.model.players.Client;
    import ardi.model.players.PacketType;

    /**
     * Drop Item by Ardi
     **/
    public class DropItem implements PacketType {

    @Override
    public void processPacket(Client c, int packetType, int packetSize) {

    int itemId = c.getInStream().readUnsignedWordA();
    c.getInStream().readUnsignedByte();
    c.getInStream().readUnsignedByte();
    int slot = c.getInStream().readUnsignedWordA();
    c.alchDelay = System.currentTimeMillis();
    if (c.arenas()) {
    c.sendMessage("You can't drop items inside the arena!");
    return;
    }
    if (c.underAttackBy > 0) {
    c.sendMessage("You can't drop items during a combat.");
    return;
    }
    if (c.inTrade) {
    c.sendMessage("You can't drop items while trading!");
    return;
    }
    if (c.playerRights == 2) {
    c.sendMessage("Administrator cannot drop items.");
    return;
    }

    boolean droppable = true;
    for (int i : Config.UNDROPPABLE_ITEMS) {
    if (i == itemId) {
    droppable = false;
    break;
    }
    }
    if (c.playerItemsN[slot] != 0 && itemId != -1
    && c.playerItems[slot] == itemId + 1) {
    if (droppable) {
    if (c.underAttackBy > 0) {
    if (c.getShops().getItemShopValue(itemId) > 1000) {
    c.sendMessage("You may not drop items worth more than 1000 while in combat.");
    return;
    }
    }
    //c.sendMessage("Your item dissapears when it touches the ground."); // drop
    // dissapearing
    c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    ardi.model.players.PlayerSave.saveGame(c);
    } else {
    c.sendMessage("You can't drop this item.");
    }
    }
    }
    }
    « Last Edit: May 29, 2015, 05:37:59 PM by tank nation »

    OfflineZymus

    • Member
    • ****
    • *
    • Posts: 7,267
    • Thanks: +0/-0
      • View Profile
    Re: itemdrop.java
    « Reply #1 on: May 29, 2015, 04:39:53 PM »
    What is wrong here? i cant get any items to drop on ground manually like if i right click an item and click drop, it just disappears
    anyone have the right code for this?
    Code: [Select]
    package ardi.model.players.packets;

    import ardi.Config;
    import ardi.model.players.Client;
    import ardi.model.players.PacketType;

    /**
     * Drop Item by Ardi
     **/
    public class DropItem implements PacketType {

    @Override
    public void processPacket(Client c, int packetType, int packetSize) {

    int itemId = c.getInStream().readUnsignedWordA();
    c.getInStream().readUnsignedByte();
    c.getInStream().readUnsignedByte();
    int slot = c.getInStream().readUnsignedWordA();
    c.alchDelay = System.currentTimeMillis();
    if (c.arenas()) {
    c.sendMessage("You can't drop items inside the arena!");
    return;
    }
    if (c.underAttackBy > 0) {
    c.sendMessage("You can't drop items during a combat.");
    return;
    }
    if (c.inTrade) {
    c.sendMessage("You can't drop items while trading!");
    return;
    }
    if (c.playerRights == 2) {
    c.sendMessage("Administrator cannot drop items.");
    return;
    }

    boolean droppable = true;
    for (int i : Config.UNDROPPABLE_ITEMS) {
    if (i == itemId) {
    droppable = false;
    break;
    }
    }
    if (c.playerItemsN[slot] != 0 && itemId != -1
    && c.playerItems[slot] == itemId + 1) {
    if (droppable) {
    if (c.underAttackBy > 0) {
    if (c.getShops().getItemShopValue(itemId) > 1000) {
    c.sendMessage("You may not drop items worth more than 1000 while in combat.");
    return;
    }
    }
    //c.sendMessage("Your item dissapears when it touches the ground."); // drop
    // dissapearing
    c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    ardi.model.players.PlayerSave.saveGame(c);
    } else {
    c.sendMessage("You can't drop this item.");
    }
    }
    }
    }


    It needs to be named "DropItem.java"

    OfflineFoHammer

    • Member
    • ***
    • Posts: 141
    • Thanks: +0/-0
      • View Profile
    Re: itemdrop.java
    « Reply #2 on: May 29, 2015, 06:28:43 PM »
    What is wrong here? i cant get any items to drop on ground manually like if i right click an item and click drop, it just disappears
    anyone have the right code for this?
    Code: [Select]
    package ardi.model.players.packets;

    import ardi.Config;
    import ardi.model.players.Client;
    import ardi.model.players.PacketType;

    /**
     * Drop Item by Ardi
     **/
    public class DropItem implements PacketType {

    @Override
    public void processPacket(Client c, int packetType, int packetSize) {

    int itemId = c.getInStream().readUnsignedWordA();
    c.getInStream().readUnsignedByte();
    c.getInStream().readUnsignedByte();
    int slot = c.getInStream().readUnsignedWordA();
    c.alchDelay = System.currentTimeMillis();
    if (c.arenas()) {
    c.sendMessage("You can't drop items inside the arena!");
    return;
    }
    if (c.underAttackBy > 0) {
    c.sendMessage("You can't drop items during a combat.");
    return;
    }
    if (c.inTrade) {
    c.sendMessage("You can't drop items while trading!");
    return;
    }
    if (c.playerRights == 2) {
    c.sendMessage("Administrator cannot drop items.");
    return;
    }

    boolean droppable = true;
    for (int i : Config.UNDROPPABLE_ITEMS) {
    if (i == itemId) {
    droppable = false;
    break;
    }
    }
    if (c.playerItemsN[slot] != 0 && itemId != -1
    && c.playerItems[slot] == itemId + 1) {
    if (droppable) {
    if (c.underAttackBy > 0) {
    if (c.getShops().getItemShopValue(itemId) > 1000) {
    c.sendMessage("You may not drop items worth more than 1000 while in combat.");
    return;
    }
    }
    //c.sendMessage("Your item dissapears when it touches the ground."); // drop
    // dissapearing
    c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    ardi.model.players.PlayerSave.saveGame(c);
    } else {
    c.sendMessage("You can't drop this item.");
    }
    }
    }
    }


    It needs to be named "DropItem.java"


    Offlinerunescape sucks

    • Member
    • ****
    • Posts: 2,798
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #3 on: May 29, 2015, 06:40:45 PM »
    Even if it's named correctly, not once do you declare a method that would indeed drop items.

    First you drop the item, then save the player if it is droppable.
    (click to show/hide)

    OfflineFoHammer

    • Member
    • ***
    • Posts: 141
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #4 on: May 29, 2015, 06:43:21 PM »
    Even if it's named correctly, not once do you declare a method that would indeed drop items.

    First you drop the item, then save the player if it is droppable.

    Oooh didn't even see haha

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #5 on: May 29, 2015, 11:00:57 PM »
    Even if it's named correctly, not once do you declare a method that would indeed drop items.

    First you drop the item, then save the player if it is droppable.

    What...? no one can drop items i mean, we can but they disappear.

    Offlinerunescape sucks

    • Member
    • ****
    • Posts: 2,798
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #6 on: May 29, 2015, 11:15:47 PM »
    I typed it wrong,
    the sequence is, according to your code,
    • c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    • ardi.model.players.PlayerSave.saveGame(c);
    if it's droppable.

    It doesn't show anything related to dropping the item if the item is droppable nor anywhere else in the code.
    (click to show/hide)

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #7 on: May 29, 2015, 11:41:29 PM »
    I typed it wrong,
    the sequence is, according to your code,
    • c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    • ardi.model.players.PlayerSave.saveGame(c);
    if it's droppable.

    It doesn't show anything related to dropping the item if the item is droppable nor anywhere else in the code.

    okay? so what i need to do so it drops on ground without disappearing. that's what i'm asking

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #8 on: May 30, 2015, 12:11:24 PM »
    You need to create a ground item based on what the player just dropped..

    Code: [Select]
    GroundItem(int id, int x, int y, int amount, int controller,
    int hideTicks, String name)
    ^Hint.

    Also: Saving after every item dropped is a shit way to fix the drop item dupe. Learn to save when the socket is closed.

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #9 on: May 30, 2015, 03:17:51 PM »
    You need to create a ground item based on what the player just dropped..

    Code: [Select]
    GroundItem(int id, int x, int y, int amount, int controller,
    int hideTicks, String name)
    ^Hint.

    Also: Saving after every item dropped is a shit way to fix the drop item dupe. Learn to save when the socket is closed.

    This is error im getting now..     
    Code: [Select]
    boolean droppable = true;
    for (int i : Config.UNDROPPABLE_ITEMS) {
    if (i == itemId) {
    droppable = false;
    break;
    }
    }
    if (c.playerItemsN[slot] != 0 && itemId != -1
    && c.playerItems[slot] == itemId + 1) {
    if (droppable) {
    if (c.underAttackBy > 0) {
    if (c.getShops().getItemShopValue(itemId) > 1000) {
    c.sendMessage("You may not drop items worth more than 1000 while in combat.");
    return;
    }
    }
    //c.sendMessage("Your item dissapears when it touches the ground."); // drop
    // dissapearing
    Server.itemHandler.createGroundItem(c, itemId, c.getX(), c.getY(), c.playerItemsN[slot], c.getId());
    c.getItems().deleteItem(itemId, slot, c.playerItemsN[slot]);
    ardi.model.players.PlayerSave.saveGame(c);
    } else {
    c.sendMessage("You can't drop this item.");
    }
    }
    }
    }

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #10 on: May 30, 2015, 03:19:21 PM »
    Import the server class.

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #11 on: May 30, 2015, 06:34:26 PM »
    Import the server class.

    How am i to do so? you have maybe a tutorial link or some sort?

    OfflineBowser jr

    • Member
    • ****
    • Posts: 6,001
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #12 on: May 30, 2015, 06:35:28 PM »
    Code: [Select]
    import ServerUse an IDE for development and learn Java.

    EDIT: Yes I know that he wasn't supposed to import it, I just answered his question about how to import stuff.
    « Last Edit: May 30, 2015, 09:48:57 PM by Bowser jr »

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #13 on: May 30, 2015, 06:50:44 PM »
    Code: [Select]
    import ServerUse an IDE for development and learn Java.

    I don't wanna use IDE, for java i just feel thats the easier way but idk never used it really, but where do i put "import Server"

    Offlinemalimt

    • Member
    • ****
    • Posts: 472
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #14 on: May 30, 2015, 09:07:05 PM »
    Code: [Select]
    import ServerUse an IDE for development and learn Java.

    I don't wanna use IDE, for java i just feel thats the easier way but idk never used it really, but where do i put "import Server"
    IDE Is the easiest way lol. Just get Eclipse! :)

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #15 on: May 30, 2015, 09:18:13 PM »
    Code: [Select]
    import ServerUse an IDE for development and learn Java.

    I don't wanna use IDE, for java i just feel thats the easier way but idk never used it really, but where do i put "import Server"
    I've literally only used my IDE for java.. But I don't use it for just RSPS. I write my own projects and etc, it's good for learning..

    You don't just put "import Server" somewhere..
    Here's a tutorial on Using Package Members, please read it as it talks about exactly what you're having an issue with

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #16 on: May 30, 2015, 10:02:43 PM »
    Code: [Select]
    import ServerUse an IDE for development and learn Java.

    I don't wanna use IDE, for java i just feel thats the easier way but idk never used it really, but where do i put "import Server"
    I've literally only used my IDE for java.. But I don't use it for just RSPS. I write my own projects and etc, it's good for learning..

    Ok i understand what there saying so where do i place my code at to import the grounditem server side: client.java? Or client side: client.java?
    You don't just put "import Server" somewhere..
    Here's a tutorial on Using Package Members, please read it as it talks about exactly what you're having an issue with

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #17 on: May 31, 2015, 01:12:45 AM »
    Do you understand what it's saying? Because it tells you in the tutorial exactly where to place them.

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #18 on: May 31, 2015, 01:47:28 PM »
    Do you understand what it's saying? Because it tells you in the tutorial exactly where to place them.

    i know.. nvm, ill just figure it out or do without it.

    Offlinerunescape sucks

    • Member
    • ****
    • Posts: 2,798
    • Thanks: +0/-0
      • View Profile
    Re: Dropitem.java
    « Reply #19 on: May 31, 2015, 03:12:28 PM »
    Do you understand what it's saying? Because it tells you in the tutorial exactly where to place them.

    i know.. nvm, ill just figure it out or do without it.
    If you don't plan on using an IDE, just google how to import something. If importing something is prohibiting you from adding basic content to your server, you really should learn or relearn the basics of Java.
    (click to show/hide)

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal