Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Released by BamBam to piss off PasiipaZ from Rune-Server.org
- <---Add this anywhere in ShopAssistance.java--->
- public void openPlayerShop(Client o){
- if(o == null || o.properLogout)
- return;
- c.getItems().resetItems(3823);
- resetShop(o);
- c.myShopClient = o;
- c.myShopId = 7390;
- c.isShopping = true;
- c.getPA().sendFrame248(3824, 3822);
- c.getPA().sendFrame126("Welcome to "+o.playerName+"'s shop.", 3901);
- }
- public int[] fixArray(int[] array){
- int arrayPos = 0;
- int[] newArray = new int[array.length];
- for(int x = 0; x < array.length; x++){
- if(array[x] != 0){
- newArray[arrayPos] = array[x];
- arrayPos++;
- }
- }
- return newArray;
- }
- public void fixShop(Client o){
- o.playerShop = fixArray(o.playerShop);
- o.playerShopN = fixArray(o.playerShopN);
- o.playerShopP = fixArray(o.playerShopP);
- }
- public void resetShop(Client o) {
- synchronized(c) {
- fixShop(o);
- for (int x = 0; x < 10; x++) {
- if (o.playerShopN[x] <= 0) {
- o.playerShop[x] = 0;
- }
- }
- int TotalItems = 0;
- for (int i = 0; i < 10; i++) {
- if (o.playerShop[i] > 0) {
- TotalItems++;
- }
- }
- if (TotalItems > 10) {
- TotalItems = 10;
- }
- c.getOutStream().createFrameVarSizeWord(53);
- c.getOutStream().writeWord(3900);
- c.getOutStream().writeWord(TotalItems);
- int TotalCount = 0;
- for (int i = 0; i < o.playerShop.length; i++) {
- if (o.playerShop[i] > 0) {
- if (o.playerShopN[i] > 254) {
- c.getOutStream().writeByte(255);
- c.getOutStream().writeDWord_v2(o.playerShopN[i]);
- } else {
- c.getOutStream().writeByte(o.playerShopN[i]);
- }
- c.getOutStream().writeWordBigEndianA((o.playerShop[i]+1));
- TotalCount++;
- }
- if (TotalCount > TotalItems) {
- break;
- }
- }
- c.getOutStream().endFrameVarSizeWord();
- c.flushOutStream();
- }
- }
- /*end of player owned shops*/
- <---Add this in ShopAssistance.java under--->
- String ShopAdd = ""; in public void buyFromShopPrice(int removeId, int removeSlot){ method.
- if (c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.playerName.equals(c.playerName)) {
- c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + c.myShopClient.playerShopP[removeSlot] + " coins.");
- return;
- } else if (c.myShopId == 7390 && c.myShopClient != null && c.myShopClient.playerName.equals(c.playerName)) {
- c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + c.playerShopP[removeSlot] + " coins.");
- return;
- }
- <---add this in the public double getItemShopValue(int ItemID, int Type, int fromSlot) under double TotPrice = 0;--->
- if(c.myShopId == 7390){
- return c.myShopClient.playerShopP[fromSlot];
- }
- <---Add this in the public boolean buyItem(int itemID, int fromSlot, int amount) method--->
- if(c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && !c.playerName.equals(c.myShopClient.playerName)){
- int bought = 0;
- int price = c.myShopClient.playerShopP[fromSlot];
- if(amount > c.myShopClient.playerShopN[fromSlot])
- amount = c.myShopClient.playerShopN[fromSlot];
- for(int x = 0; x < amount; x++){
- if(c.getItems().playerHasItem(995, c.myShopClient.playerShopP[fromSlot]) && c.getItems().freeSlots() > 0){
- c.getItems().deleteItem2(995, c.myShopClient.playerShopP[fromSlot]);
- c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
- c.myShopClient.playerShopN[fromSlot]--;
- c.myShopClient.playerCollect += c.myShopClient.playerShopP[fromSlot];
- if(c.myShopClient.playerShopN[fromSlot] == 0){
- c.myShopClient.playerShop[fromSlot] = 0;
- c.myShopClient.playerShopP[fromSlot] = 0;
- }
- bought++;
- }else{
- c.sendMessage("Not enought space or money.");
- break;
- }
- }
- if(bought > 0){
- resetShop(c.myShopClient);
- c.getItems().resetItems(3823);;
- c.sendMessage("You just bought "+bought+" "+c.getItems().getItemName(itemID)+" for "+ (bought*price) +" gold.");
- c.myShopClient.sendMessage(c.playerName+" has bought "+bought+" "+c.getItems().getItemName(itemID)+" from you!");
- //c.myShopClient.sendMessage("You now have "+c.myShopClient.playerCollect+" coins to collect (::collect)");
- }
- return false;
- }else if(c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && c.playerName.equals(c.myShopClient.playerName)){
- if(amount > c.myShopClient.playerShopN[fromSlot])
- amount = c.myShopClient.playerShopN[fromSlot];
- for(int x = 0; x < amount; x++){
- if(c.getItems().freeSlots() > 0){
- c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
- c.myShopClient.playerShopN[fromSlot]--;
- if(c.myShopClient.playerShopN[fromSlot] == 0){
- c.myShopClient.playerShop[fromSlot] = 0;
- c.myShopClient.playerShopP[fromSlot] = 0;
- fixShop(c);
- }
- }else{
- c.sendMessage("Not enought space.");
- break;
- }
- }
- resetShop(c.myShopClient);
- c.getItems().resetItems(3823);
- return false;
- }else if(c.myShopId == 7390){
- return false;
- }
- <---Add this in the public boolean sellItem(int itemID, int fromSlot, int amount) method--->
- if(c.myShopId == 7390){
- for (int i : Config.ITEM_TRADEABLE) {
- if(i == itemID) {
- c.sendMessage("You can't sell this item.");
- return false;
- }
- }
- if(c.playerName.equals(c.myShopClient.playerName)){
- c.sellingId = itemID;
- c.sellingN = amount;
- c.sellingS = fromSlot;
- c.xInterfaceId = 7390;
- c.outStream.createFrame(27);
- }else{
- c.sendMessage("You can only sell items to your own shop.");
- }
- return true;
- }
- <---Add this to public void sellToShopPrice(int removeId, int removeSlot) method--->
- if(c.myShopId == 7390){
- c.sendMessage("You choose your price when using Player Owned Shops.");
- return;
- }
- <---Open up Player.java and add these.--->
- public Client myShopClient;
- public int sellingId;
- public int sellingN;
- public int sellingS;
- public int playerCollect;
- public int playerShop[] = new int[10];
- public int playerShopN[] = new int[10];
- public int playerShopP[] = new int[10];
- <---Open up BankX2.java and add this.--->
- if(c.sellingId > 0 && c.sellingN > 0 && c.xInterfaceId == 7390){
- for (int i : Config.ITEM_TRADEABLE) {
- if(i == c.sellingId) {
- c.sendMessage("You can't sell this item.");
- c.sellingId = 0;
- c.sellingN = 0;
- c.sellingS = 0;
- return;
- }
- }
- if(c.sellingN > c.getItems().getItemAmount(c.sellingId))
- c.sellingN = c.getItems().getItemAmount(c.sellingId);
- int slot = -1;
- for(int x = 0; x < 10; x++){
- if(c.playerShop[x] == 0){
- slot = x;
- break;
- }
- }
- if(slot == -1){
- c.sendMessage("You are only allows to sell 10 items at any time.");
- c.sellingId = 0;
- c.sellingN = 0;
- c.sellingS = 0;
- return;
- }
- if(c.getItems().playerHasItem(c.sellingId, c.sellingN, c.sellingS)){
- c.getItems().deleteItem2(c.sellingId, c.sellingN);
- c.playerShop[slot] = c.sellingId;
- c.playerShopN[slot] = c.sellingN;
- c.playerShopP[slot] = Xamount;
- c.sendMessage("You put your items on sale.");
- }
- c.getShops().openPlayerShop(c);
- c.sellingId = 0;
- c.sellingN = 0;
- c.sellingS = 0;
- return;
- }
- <---Add this in Client.java under your first getPA().showOption(3, 0, "Attack", 1);--->
- } else if (!inWild() && !inDuelArena()){
- getPA().showOption(3, 0, "View shop", 1);
- <---Add this to your commands.java--->
- if(playerCommand.equalsIgnoreCase("collect")){
- if(c.playerCollect > 0){
- c.sendMessage("You succesfully collected "+c.playerCollect+" coins.");
- c.getItems().addItem(995, c.playerCollect);
- c.playerCollect = 0;
- }else{
- c.sendMessage("You dont have anything to collect");
- }
- }
- if(playerCommand.equalsIgnoreCase("myshop")){
- c.getShops().openPlayerShop(c);
- }
- <---Add this to PlayerSave.java--->
- case 10:
- if (token.equals("character-shop")) {
- p.playerShop[Integer.parseInt(token3[0])] = Integer.parseInt(token3[1]);
- p.playerShopP[Integer.parseInt(token3[0])] = Integer.parseInt(token3[2]);
- p.playerShopN[Integer.parseInt(token3[0])] = Integer.parseInt(token3[3]);
- }
- break;
- } else if (line.equals("[SHOP]")) { ReadMode = 10;
- /*SHOP*/
- characterfile.write("[SHOP]", 0, 6);
- characterfile.newLine();
- for (int i = 0; i < p.playerShop.length; i++) {
- if (p.playerShop[i] > 0) {
- characterfile.write("character-shop = ", 0, 17);
- characterfile.write(Integer.toString(i), 0, Integer.toString(i).length());
- characterfile.write(" ", 0, 1);
- characterfile.write(Integer.toString(p.playerShop[i]), 0, Integer.toString(p.playerShop[i]).length());
- characterfile.write(" ", 0, 1);
- characterfile.write(Integer.toString(p.playerShopP[i]), 0, Integer.toString(p.playerShopP[i]).length());
- characterfile.write(" ", 0, 1);
- characterfile.write(Integer.toString(p.playerShopN[i]), 0, Integer.toString(p.playerShopN[i]).length());
- characterfile.newLine();
- }
- }
- characterfile.newLine();
- That should be it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement