Thread: [PI] Ardi's TradeandDuel Class [Much Better] [More Dupe Fixes]

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1 [PI] Ardi's TradeandDuel Class [Much Better] [More Dupe Fixes] 
    Banned
    Join Date
    Apr 2015
    Posts
    90
    Thanks given
    23
    Thanks received
    13
    Rep Power
    0

    All you're gonna wanna do if you're using Ardi's Base, or project Raw, etc. Replace these files, and add things I say to do. It Will fix most bugs and dupes. Yes, I do know ardi is a bad base because of all the glitches and stuff or whatever, But I have been working on this base for a week now, and I can say I will be releasing it very soon. Released this too help people out.



    TradeandDuel replacement: Click here. IF you're gonna add any of these things below, make sure to replace you're current TradeAndDuel With this.

    Spoiler for Player.java:
    Add this in player.java:

    Code:
    public int lastSlot = -1;
    	public int tradeTime;
    
    
    	public void activateTradeTimer() {
    		EventManager.getSingleton().addEvent(new Event() {
    			public void execute(EventContainer e) {
    				if (tradeTime > 0)
    					tradeTime--;
    				if (tradeTime <= 0)
    					e.stop();
    			}
    		}, 0);
    	}


    Add these Method in ItemAssistant.java


    Spoiler for Add in ItemAssistant under a method:

    Code:
    public boolean forceAddItem(int item, int amount) {
    		if (amount < 1) {
    			amount = 1;
    		}
    		if (item <= 0) {
    			return false;
    		}
    		int freeSlotId = freeSlotId();
    		boolean freeSlot = freeSlotId != -1;
    		int itemSlot = getItemSlot(item);
    		if (((freeSlot || itemSlot != -1) && Item.itemStackable[item])
    				|| ((freeSlot) && !Item.itemStackable[item])) {
    			if (itemSlot != -1 && Item.itemStackable[item]
    					&& (c.playerItems[itemSlot] == (item + 1))) {
    				c.playerItems[itemSlot] = (item + 1);
    				if (((c.playerItemsN[itemSlot] + amount) < Config.MAXITEM_AMOUNT)
    						&& ((c.playerItemsN[itemSlot] + amount) > -1)) {
    					c.playerItemsN[itemSlot] += amount;
    				} else {
    					c.sendMessage("The item has dropped because you had the maximum of that item.");
    					ItemHandler.createGroundItem(c, item, c.absX, c.absY,
    							amount, c.playerId);
    					return false;
    				}
    				updateInventory = true;
    				return true;
    			}
    			if (c.lastSlot > -1) {
    				if (c.playerItems[c.lastSlot] <= 0) {
    					c.playerItems[c.lastSlot] = item + 1;
    					if ((amount < Config.MAXITEM_AMOUNT) && (amount > -1)) {
    						c.playerItemsN[c.lastSlot] = 1;
    						if (amount > 1) {
    							c.getItems().addItem(item, amount - 1);
    							c.lastSlot = -1;
    							return true;
    						}
    					} else {
    						c.playerItemsN[c.lastSlot] = Config.MAXITEM_AMOUNT;
    					}
    					updateInventory = true;
    					c.lastSlot = -1;
    					return true;
    				}
    			}
    			if (c.playerItems[freeSlotId] > 0)
    				return false;
    			c.playerItems[freeSlotId] = item + 1;
    			if (amount < Config.MAXITEM_AMOUNT) {
    				if (Item.itemStackable[item]) {
    					c.playerItemsN[freeSlotId] = amount;
    				} else {
    					c.playerItemsN[freeSlotId] = 1;
    					if (amount > 1) {
    						c.getItems().addItem(item, amount - 1);
    						return true;
    					}
    				}
    			} else
    				c.playerItemsN[freeSlotId] = Config.MAXITEM_AMOUNT;
    			updateInventory = true;
    			return true;
    		} else {
    			c.sendMessage("The item has dropped because you had no inventory space.");
    			ItemHandler.createGroundItem(c, item, c.absX, c.absY, amount,
    					c.playerId);
    			return false;
    		}
    	}


    Spoiler for Add these methods in itemassistant.java As well::

    Code:
    public int getItemCount(int itemID) {
    		int count = 0;	
    		for (int j = 0; j < c.playerItems.length; j++) {
    			if (c.playerItems[j] == itemID + 1) {
    				count += c.playerItemsN[j];
    			}		
    		}
    		return count;
    	}
    	
    	public boolean updateInventory = false;
    	
    	public void updateInventory() {
    		updateInventory = false;
    		resetItems(3214);
    	}
    
          	public int freeSlotId() {
    		for (int i = 0; i < c.playerItems.length; i++) {
    			if (c.playerItems[i] <= 0) {
    				return i;
    			}
    		}
    		return -1;
    	}


    Replace this method in ClickingButtons.java

    Spoiler for In clickingbuttons.java, Replace case 13218 with:


    Replace case 13218 With:


    Code:
    case 13218:
    				if (c.tradeTime > 0)
    					  return;
    				if (System.currentTimeMillis() - c.lastButton < 400) {
    					c.lastButton = System.currentTimeMillis();
    					break;
    				} else {
    					c.lastButton = System.currentTimeMillis();
    
    				}
    				c.tradeAccepted = true;
    				Client ot1 = (Client) PlayerHandler.players[c.tradeWith];
    				if (ot1 == null) {
    					c.getTradeAndDuel().declineTrade();
    					c.sendMessage("Trade declined as the other player has disconnected.");
    					break;
    				}
    
    				if (c.inTrade && c.tradeConfirmed && ot1.tradeConfirmed
    						&& !c.tradeConfirmed2) {
    					c.tradeConfirmed2 = true;
    					if (ot1.tradeConfirmed2) {
    						c.getPA().resetInterfaceStatus();
    						ot1.getPA().resetInterfaceStatus();
    						c.acceptedTrade = true;
    						ot1.acceptedTrade = true;
    						c.getTradeAndDuel().giveItems();
    						ot1.getTradeAndDuel().giveItems();
    						c.getTradeAndDuel().resetTrade();
    						ot1.getTradeAndDuel().resetTrade();
    						c.sendMessage("Trade accepted.");
    						ot1.sendMessage("Trade accepted.");
    						break;
    					}
    					ot1.getPA().sendFrame126("Other player has accepted.", 3535);
    					c.getPA().sendFrame126("Waiting for other player...", 3535);
    				}
    
    				break;


    Spoiler for Walking.java Add:

    Code:
    if (c.inTrade) {
    			c.tradeTime = 20;
    			c.activateTradeTimer();
    			c.getTradeAndDuel().declineTrade();
    		}


    In playerassistant.java, add:

    Spoiler for Add In Playerassistant.java:


    Code:
    public void resetInterfaceStatus() {
    		if (c.getOutStream() != null && c != null) {
    			c.getPA().resetVariables();
    			c.getOutStream().createFrame(219);
    		}
    	}



    That's it, im pretty sure. If you get any errors, post them below and I will help you.
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Feb 2014
    Posts
    209
    Thanks given
    20
    Thanks received
    6
    Rep Power
    11
    Nice, Thanks for the contribution!
    Reply With Quote  
     

  4. #3  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,409
    Thanks given
    576
    Thanks received
    580
    Rep Power
    5000
    Yeah replacing your whole file is always a good idea
    Reply With Quote  
     

  5. #4  
    Registered Member

    Join Date
    Feb 2013
    Posts
    1,682
    Thanks given
    401
    Thanks received
    402
    Rep Power
    446
    Nice to see you're actually working on it and not only say it's shit, also resetInterfaceStatus ? I've checked some of your code and you didn't put this method
    Reply With Quote  
     

  6. #5  
    Banned
    Join Date
    Apr 2015
    Posts
    90
    Thanks given
    23
    Thanks received
    13
    Rep Power
    0
    Quote Originally Posted by Delinquent View Post
    Nice to see you're actually working on it and not only say it's shit, also resetInterfaceStatus ? I've checked some of your code and you didn't put this method
    Added it. If it's missing anything else, let me know, and i'll add it in.
    Reply With Quote  
     

  7. #6  
    oof


    Join Date
    Aug 2012
    Posts
    3,150
    Thanks given
    2,847
    Thanks received
    857
    Rep Power
    2260
    jw what made you center the code
    Reply With Quote  
     

  8. #7  
    Banned
    Join Date
    Apr 2015
    Posts
    90
    Thanks given
    23
    Thanks received
    13
    Rep Power
    0
    Quote Originally Posted by Vesia View Post
    jw what made you center the code
    fIXED.
    Reply With Quote  
     

  9. #8  
    oof


    Join Date
    Aug 2012
    Posts
    3,150
    Thanks given
    2,847
    Thanks received
    857
    Rep Power
    2260
    Quote Originally Posted by Arras View Post
    fIXED.
    cool but you should use code tags too
    Reply With Quote  
     

  10. #9  
    Registered Member
    Join Date
    May 2012
    Posts
    445
    Thanks given
    31
    Thanks received
    19
    Rep Power
    48
    Quote Originally Posted by Arras View Post

    All you're gonna wanna do if you're using Ardi's Base, or project Raw, etc. Replace these files, and add things I say to do. It Will fix most bugs and dupes. Yes, I do know ardi is a bad base because of all the glitches and stuff or whatever, But I have been working on this base for a week now, and I can say I will be releasing it very soon. Released this too help people out.


    TradeandDuel replacement: Click here. IF you're gonna add any of these things below, make sure to replace you're current TradeAndDuel With this.

    Spoiler for Player.java:
    Add this in player.java:

    public int lastSlot = -1;
    public int tradeTime;


    public void activateTradeTimer() {
    EventManager.getSingleton().addEvent(new Event() {
    public void execute(EventContainer e) {
    if (tradeTime > 0)
    tradeTime--;
    if (tradeTime <= 0)
    e.stop();
    }
    }, 0);
    }


    Add these Method in ItemAssistant.java


    Spoiler for Add in ItemAssistant under a method:

    public boolean forceAddItem(int item, int amount) {
    if (amount < 1) {
    amount = 1;
    }
    if (item <= 0) {
    return false;
    }
    int freeSlotId = freeSlotId();
    boolean freeSlot = freeSlotId != -1;
    int itemSlot = getItemSlot(item);
    if (((freeSlot || itemSlot != -1) && Item.itemStackable[item])
    || ((freeSlot) && !Item.itemStackable[item])) {
    if (itemSlot != -1 && Item.itemStackable[item]
    && (c.playerItems[itemSlot] == (item + 1))) {
    c.playerItems[itemSlot] = (item + 1);
    if (((c.playerItemsN[itemSlot] + amount) < Config.MAXITEM_AMOUNT)
    && ((c.playerItemsN[itemSlot] + amount) > -1)) {
    c.playerItemsN[itemSlot] += amount;
    } else {
    c.sendMessage("The item has dropped because you had the maximum of that item.");
    ItemHandler.createGroundItem(c, item, c.absX, c.absY,
    amount, c.playerId);
    return false;
    }
    updateInventory = true;
    return true;
    }
    if (c.lastSlot > -1) {
    if (c.playerItems[c.lastSlot] <= 0) {
    c.playerItems[c.lastSlot] = item + 1;
    if ((amount < Config.MAXITEM_AMOUNT) && (amount > -1)) {
    c.playerItemsN[c.lastSlot] = 1;
    if (amount > 1) {
    c.getItems().addItem(item, amount - 1);
    c.lastSlot = -1;
    return true;
    }
    } else {
    c.playerItemsN[c.lastSlot] = Config.MAXITEM_AMOUNT;
    }
    updateInventory = true;
    c.lastSlot = -1;
    return true;
    }
    }
    if (c.playerItems[freeSlotId] > 0)
    return false;
    c.playerItems[freeSlotId] = item + 1;
    if (amount < Config.MAXITEM_AMOUNT) {
    if (Item.itemStackable[item]) {
    c.playerItemsN[freeSlotId] = amount;
    } else {
    c.playerItemsN[freeSlotId] = 1;
    if (amount > 1) {
    c.getItems().addItem(item, amount - 1);
    return true;
    }
    }
    } else
    c.playerItemsN[freeSlotId] = Config.MAXITEM_AMOUNT;
    updateInventory = true;
    return true;
    } else {
    c.sendMessage("The item has dropped because you had no inventory space.");
    ItemHandler.createGroundItem(c, item, c.absX, c.absY, amount,
    c.playerId);
    return false;
    }
    }


    Spoiler for Add these methods in itemassistant.java As well::

    public int getItemCount(int itemID) {
    int count = 0;
    for (int j = 0; j < c.playerItems.length; j++) {
    if (c.playerItems[j] == itemID + 1) {
    count += c.playerItemsN[j];
    }
    }
    return count;
    }

    public boolean updateInventory = false;

    public void updateInventory() {
    updateInventory = false;
    resetItems(3214);
    }

    public int freeSlotId() {
    for (int i = 0; i < c.playerItems.length; i++) {
    if (c.playerItems[i] <= 0) {
    return i;
    }
    }
    return -1;
    }


    Replace this method in ClickingButtons.java

    Spoiler for In clickingbuttons.java, Replace case 13218 with:


    Replace case 13218 With:


    case 13218:
    if (c.tradeTime > 0)
    return;
    if (System.currentTimeMillis() - c.lastButton < 400) {
    c.lastButton = System.currentTimeMillis();
    break;
    } else {
    c.lastButton = System.currentTimeMillis();

    }
    c.tradeAccepted = true;
    Client ot1 = (Client) PlayerHandler.players[c.tradeWith];
    if (ot1 == null) {
    c.getTradeAndDuel().declineTrade();
    c.sendMessage("Trade declined as the other player has disconnected.");
    break;
    }

    if (c.inTrade && c.tradeConfirmed && ot1.tradeConfirmed
    && !c.tradeConfirmed2) {
    c.tradeConfirmed2 = true;
    if (ot1.tradeConfirmed2) {
    c.getPA().resetInterfaceStatus();
    ot1.getPA().resetInterfaceStatus();
    c.acceptedTrade = true;
    ot1.acceptedTrade = true;
    c.getTradeAndDuel().giveItems();
    ot1.getTradeAndDuel().giveItems();
    c.getTradeAndDuel().resetTrade();
    ot1.getTradeAndDuel().resetTrade();
    c.sendMessage("Trade accepted.");
    ot1.sendMessage("Trade accepted.");
    break;
    }
    ot1.getPA().sendFrame126("Other player has accepted.", 3535);
    c.getPA().sendFrame126("Waiting for other player...", 3535);
    }

    break;



    Spoiler for Walking.java Add:

    if (c.inTrade) {
    c.tradeTime = 20;
    c.activateTradeTimer();
    c.getTradeAndDuel().declineTrade();
    }


    In playerassistant.java, add:

    Spoiler for Add In Playerassistant.java:


    public void resetInterfaceStatus() {
    if (c.getOutStream() != null && c != null) {
    c.getPA().resetVariables();
    c.getOutStream().createFrame(219);
    }
    }




    That's it, im pretty sure. If you get any errors, post them below and I will help you.
    Thanks, going to use.
    Reply With Quote  
     

  11. #10  
    Member
    Join Date
    Apr 2015
    Posts
    212
    Thanks given
    6
    Thanks received
    58
    Rep Power
    0
    Not the best way of doing it. I could explain why but I am on my phone. Nice job though.
    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

Similar Threads

  1. Replies: 8
    Last Post: 03-11-2016, 07:42 PM
  2. Replies: 1
    Last Post: 07-21-2013, 11:01 AM
  3. [PI]More Dupe Fixes!
    By Division in forum Snippets
    Replies: 31
    Last Post: 09-18-2011, 07:11 AM
  4. PI Range much better way to calc hits?
    By Spooky in forum Help
    Replies: 1
    Last Post: 08-01-2010, 05:24 PM
  5. Replies: 13
    Last Post: 07-30-2010, 05:20 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
  •