1 Attachment(s)
[TUT - 508] 100% Full trading
I did not make this, but thought I would share it.
100% Full bank (accepting, declining, taking item(s), flashing icon, etc.)
Credits to:
Gravediggah
Peterbjornx
Martin
Maxi
Make sure you add the new package to the file used
to compile your files, or the new classes won't be compiled!
This file is most probably called ALL.CMD.
Or just use an IDE, like you should be already..
Step 1. Open up ActionButtons.java
Remove the cases for 334,335 and 336 and add this:
Code:
case 335:
case 334:
case 336:
p.pTrade.buttons.handleButton(interfaceId, packetId, buttonId, buttonId2);
break;
Step 2. Open up PlayerOption2.java
Find this:
Code:
Player p2 = Engine.players[p.clickId];
Remove everything untill this line:
Code:
p.playerOption2 = false;
Replace it with this:
Code:
Player p2 = Engine.players[p.clickId];
if (p2.pTrade.getPartner() == p) {
} else {
p.frames.sendMessage(p, "Sending trade request...");
p.frames.sendMessage(p2, p.username.substring(0, 1).toUpperCase() + p.username.substring(1) + ":tradereq:");
}
p.requestFaceTo(p.clickId);
p.pTrade.tradePlayer(p2);
p.playerOption2 = false;
Step 3. Open up PacketManager.java
If case 253 exists, replace it with this, if not, add this case.
Code:
case 253:
int playerId = p.stream.readUnsignedWord();
playerId -= 33024;
playerId = playerId / 256;
playerId++;
if (playerId < 0 || playerId >= Engine.players.length || Engine.players[playerId] == null) {
return;
}
if (Engine.players[playerId].pTrade.getPartner() == p) {
p.pTrade.tradePlayer(Engine.players[playerId]);
}
break;
Add this to Case 119:
Code:
if(
p.interfaceId==762 ||
p.interfaceId==335 ||
p.interfaceId==334 ||
p.interfaceId==620) {
return;
}
Step 4. Open up Player.java
Add this to your imports:
Code:
import palidino76.rs2.players.ptrade.PTrade;
Find this:
Code:
public boolean showingInterface = false;
Or this:
Code:
public class Player {
Add this to the next line:
Code:
public PTrade pTrade;
Find this:
Code:
for (int i = 0; i < bankItems.length; i++) {
bankItems[i] = -1;
}
Add this to the next line:
Code:
pTrade = new PTrade(this);
Find this:
Code:
if (disconnected[0]) {
disconnected[1] = true;
}
Replace it with this:
Code:
if (disconnected[0]) {
if (pTrade.getPartner() != null) {
pTrade.declineTrade();
}
disconnected[1] = true;
}
Step 5. Create a new package (folder) in "palidino76.rs2.players" called "ptrade"
Step 6. Download the attachment at the bottom. RaGEZONE *** out some character's in the file so it would give errors. Save it as "PTrade.java" to the package we've just made.
Step 7. Create a new file called "TButtons.java" in the package we've just created.
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package palidino76.rs2.players.ptrade;
import palidino76.rs2.Engine;
import palidino76.rs2.players.Player;
import palidino76.rs2.players.items.PlayerItems;
/**
*
* @author Gravediggah
*/
public class TButtons {
private Player p;
private PlayerItems pi = new PlayerItems();
public TButtons(Player p) {
this.p = p;
}
public void handleButton(int interfaceId, int packetId, int buttonId, int buttonId2) {
switch (interfaceId) {
case 334:
secondScreen(packetId,buttonId,buttonId2);
break;
case 335:
firstScreen(packetId, buttonId, buttonId2);
break;
case 336:
inventoryItems(packetId, buttonId2);
break;
}
}
public void firstScreen(int packetId, int buttonId, int buttonId2) {
switch (buttonId) {
case 16:
p.pTrade.confirmTrade();
break;
case 12:
case 18:
p.pTrade.declineTrade();
break;
case 30:
if (packetId == 233 && buttonId==30) {
p.pTrade.removeItemB(buttonId2, 1);
}
break;
}
}
public void secondScreen(int packetId, int buttonId, int buttonId2) {
switch (buttonId) {
case 20:
p.pTrade.confirmTrade();
break;
case 8:
case 21:
p.pTrade.declineTrade();
break;
}
}
public void inventoryItems(int packetId, int buttonId2) {
switch (packetId) {
case 233:
p.pTrade.tradeItemB(buttonId2, 1);
break;
case 21:
p.pTrade.tradeItemB(buttonId2, 5);
break;
case 169:
p.pTrade.tradeItemB(buttonId2, 10);
break;
case 214:
p.pTrade.tradeItemB(buttonId2, Engine.playerItems.invItemCount(p,p.items[buttonId2]));
break;
case 173:
p.pTrade.tradeItemB(buttonId2, 1); //Option X
break;
}
}
}
Step 8. Create a new file called "TItem.java" in the package we've just created.
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package palidino76.rs2.players.ptrade;
/**
*
* @author Gravediggah
*/
public class TItem {
private int itemId;
private int itemAmount;
public TItem(int itemId, int itemAmount) {
this.itemId=itemId;
this.itemAmount=itemAmount;
}
public int getItemAmount() {
return itemAmount;
}
public void setItemAmount(int itemAmount) {
this.itemAmount = itemAmount;
}
public int getItemId() {
return itemId;
}
public void setItemId(int itemId) {
this.itemId = itemId;
}
public void incAmount(int value) {
this.itemAmount+=value;
}
public void decAmount(int value) {
this.itemAmount-=value;
}
}
Step 9. Open up Frames.java
If you haven't got these methods yet, add this:
Code:
/**
* Sets item options allowed
* @param p The Player which the frame should be created for.
* @param set The access mask
* @param window The window or child interface id
* @param inter The main interface id
* @param off The item offset to start with
* @param len The item count to set
*/
public void setAccessMask(Player p, int set, int window, int inter, int off, int len) {
if (p == null || p.stream == null || p.disconnected[0]) {
return;
}
p.stream.createFrame(223);
p.stream.writeWord(len);
p.stream.writeWordBigEndianA(off);
p.stream.writeWordBigEndian(window);
p.stream.writeWordBigEndian(inter);
p.stream.writeWordBigEndian(set);
p.stream.writeWordBigEndian(0);
}
/**
* Runs an ClientScript2 script
* @param p The Player which the frame should be created for.
* @param id The script id
* @param o The script arguments
* @param valstring The argument types
*/
public void runScript(Player p, int id, Object[] o, String valstring) {
if (valstring.length() != o.length) {
throw new IllegalArgumentException("Argument array size mismatch");
}
p.stream.createFrameVarSizeWord(152);
p.stream.writeString(valstring);
int j = 0;
for (int i = (valstring.length() - 1); i >= 0; i--) {
if (valstring.charAt(i) == 115) {
p.stream.writeString((String) o[j]);
} else {
p.stream.writeDWord((Integer) o[j]);
}
j++;
}
p.stream.writeDWord(id);
p.stream.endFrameVarSize();
}
Step 10. Open up Items.java
Add this to your imports:
Code:
import palidino76.rs2.players.items.BankUtils;
Find this method:
Code:
public boolean noted(int itemId) {
Replace the whole method with this:
Code:
public boolean noted(int itemId) {
return new BankUtils().isNote(itemId);
}
Step 11. Create a file called "BankUtils.java" in package palidino76.rs2.players.items
Code:
package palidino76.rs2.players.items;
import java.util.LinkedList;
import palidino76.rs2.Engine;
import palidino76.rs2.world.items.ItemList;
import palidino76.rs2.world.items.Items;
/**
*
* @author Gravediggah
*/
public class BankUtils {
public BankUtils() {
}
public boolean isNote(int itemId) {
String description = Engine.items.getItemDescription(itemId);
return description.toLowerCase().startsWith("swap");
}
public boolean canBeNoted(int itemId) {
return (findNote(itemId)>-1);
}
public int findNote(int itemId) {
for(ItemList i : Engine.items.itemLists) {
if (i !=null) {
if (i.itemDescription.toLowerCase().startsWith("swap") &&
i.itemName.equals(Engine.items.getItemName(itemId))) {
return i.itemId;
}
}
}
return -1;
}
public int findUnNote(int itemId) {
for(ItemList i : Engine.items.itemLists) {
if (i !=null) {
if (!i.itemDescription.toLowerCase().startsWith("swap") &&
i.itemName.equals(Engine.items.getItemName(itemId))) {
return i.itemId;
}
}
}
return -1;
}
}
Step 12. Compile, run, and you're done.
Make sure you add the new package to the file used
to compile your files, or the new classes won't be compiled!
This file is most probably called ALL.CMD.
Or just use an IDE, like you should be already..
Re: [TUT - 508] 100% Full trading
i get tons of errors when i do all that lol, but my problem is not the trading screen. If i trade someone it open's up the tradescreen but in my inventory i see the other player his items and that's wy i cant trade because i can not put my opponents his items in trade....
(P.S: i already checked my playertrade.java and maybe there is something with the item sides but at first sight there isn't i compared it with a playertrade.java file of another source and it is the same :s help me out pls.)
rep++ for someone who helps me. I don't know if this is the right section but it is related to this topic as it still doesn't work with this tut.
Re: [TUT - 508] 100% Full trading
Quote:
Originally Posted by
smurfss
i get tons of errors when i do all that lol, but my problem is not the trading screen. If i trade someone it open's up the tradescreen but in my inventory i see the other player his items and that's wy i cant trade because i can not put my opponents his items in trade....
(P.S: i already checked my playertrade.java and maybe there is something with the item sides but at first sight there isn't i compared it with a playertrade.java file of another source and it is the same :s help me out pls.)
rep++ for someone who helps me. I don't know if this is the right section but it is related to this topic as it still doesn't work with this tut.
Post your errors? Then I'll try to help.
Nice already had this, from scratch :)
Re: [TUT - 508] 100% Full trading
This is used on palidinos source right? Is the guy with the errors using a different source? Cuz they might use different variables or methods and such
Ragezone changed the text, and some of the things and numbers are replaced with stars... -.-
Re: [TUT - 508] 100% Full trading
Quote:
Originally Posted by
stability666
This is used on palidinos source right? Is the guy with the errors using a different source? Cuz they might use different variables or methods and such
Ragezone changed the text, and some of the things and numbers are replaced with stars... -.-
yea...
thanx for telling me :P
the .java's for trading with file downloads
Re: [TUT - 508] 100% Full trading
Looks good, but it's messy. You can make things a lot simpler than that, but it gets the job done. Also, it needs to have the available inventory added(it has been done).
Other than that, decent; the naming says a lot about the kid's programming habits :/
Re: [TUT - 508] 100% Full trading
Quote:
Originally Posted by
rickymenier
yea...
thanx for telling me :P
the .java's for trading with file downloads
Np..:8::ott1:
EDIT:
Code:
public void tradeOptions() {
p.frames.setAccessMask(p, 1150, 30, 335, 0, 27);
p.frames.setAccessMask(p, 1026, *** 335, 0, 27);
p.frames.setAccessMask(p, 1278, 0, 336, 0, 27);
Object[] tparams1 = new Object[]{"", "", "", "Value", "Remove-X", "Remove-All", "Remove-10", "Remove-5", "Remove", -1, 0, 7, 4, 90, 21954590};
Object[] tparams2 = new Object[]{"", "", "Lend", "Value", "Offer-X", "Offer-All", "Offer-10", "Offer-5", "Offer", -1, 0, 7, 4, 93, 220200****;
Object[] tparams3 = new Object[]{"", "", "", "", "", "", "", "", "Value", -1, 0, 7, 4, 90, 21954592};
p.frames.runScript(p, 150, tparams1, "IviiiIsssssssss");
p.frames.runScript(p, 150, tparams2, "IviiiIsssssssss");
p.frames.runScript(p, 695, tparams3, "IviiiIsssssssss");
}
public void flashIcon(int itemSlot) {
Object[] tparams4 = new Object[]{itemSlot, 7, 4, 21954593};
p.frames.runScript(p, 143, tparams4, "Iiii");
}
THATS FROM PTrade.java
Is wrong too... it doesnt compile.
Re: [TUT - 508] 100% Full trading
well i don't have anny errors annymore (i fixed them) but i got still the same problem :s when i trade someone trade screen is opening i can click accept or decline but i can't put in items.(as i see my opponents his inventory.)
Re: [TUT - 508] 100% Full trading
Those that downloaded V2 of my release will already have this XD
Re: [TUT - 508] 100% Full trading
Nvm guys i took some java code lessons. And it is fixed now ;)
Re: [TUT - 508] 100% Full trading
Nice to see somebody doesn't just copy tutorials and actually tries to learn how to code it.
Good Job.
Re: [TUT - 508] 100% Full trading
I finally got this right, as in fixing all errors. And after trading the tabs and such are fucked up.
EDIT: Fixed this by adding variable RidInterface, to make the interfaces the same as when you login after trading is over ;D
Re: [TUT - 508] 100% Full trading
Sadly, this is NOT 100% just yet... It doesn't have the price calculations like Real RuneScape does. So I would count this as 90% done. Anywho, thank god I got Joe's V2 when it was available. <3. I'm using it as my base. My server won't be that good, but in 6 months - a year (my estimated time when I am finished customizing/adding features to it), my server will probably be the best :P. I might even just start off with Clean Mopar, since I plan on making a RuneScape like server. I hate those too easy servers. They just suck.
Anyway, thanks for the release. If anyone is keeping something away from the public is because they are being fags. They should help the RS DEV get better and closer to RuneScape-like.
Re: [TUT - 508] 100% Full trading
Uhm i liked the title so i took a quick look and noticed this small thing,
Code:
Player p2 = Engine.players[p.clickId];
if (p2.pTrade.getPartner() == p) {
} else {
p.frames.sendMessage(p, "Sending trade request...");
p.frames.sendMessage(p2, p.username.substring(0, 1).toUpperCase() + p.username.substring(1) + ":tradereq:");
}
p.requestFaceTo(p.clickId);
p.pTrade.tradePlayer(p2);
p.playerOption2 = false;
Its really small but shouldnt it be more like this ?
Code:
Player p2 = Engine.players[p.clickId];
if (p2.pTrade.getPartner() != p) {
p.frames.sendMessage(p, "Sending trade request...");
p.frames.sendMessage(p2, p.username.substring(0, 1).toUpperCase() + p.username.substring(1) + ":tradereq:");
}
p.requestFaceTo(p.clickId);
p.pTrade.tradePlayer(p2);
p.playerOption2 = false;
Not 100% sure as i havent coded in java for ages :p.