Advertisement
Guest User

P.O.S RSPS - Released by BamBam to piss off PasiipaZ frm R-S

a guest
Jul 20th, 2011
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.23 KB | None | 0 0
  1. Released by BamBam to piss off PasiipaZ from Rune-Server.org
  2.  
  3.  
  4. <---Add this anywhere in ShopAssistance.java--->
  5.  
  6.  
  7.  
  8.  
  9.     public void openPlayerShop(Client o){  
  10.         if(o == null || o.properLogout)
  11.             return;
  12.         c.getItems().resetItems(3823);
  13.         resetShop(o);
  14.         c.myShopClient = o;
  15.         c.myShopId = 7390;
  16.         c.isShopping = true;
  17.         c.getPA().sendFrame248(3824, 3822);
  18.         c.getPA().sendFrame126("Welcome to "+o.playerName+"'s shop.", 3901);
  19.     }
  20.     public int[] fixArray(int[] array){
  21.         int arrayPos = 0;
  22.         int[] newArray = new int[array.length];
  23.         for(int x = 0; x < array.length; x++){
  24.             if(array[x] != 0){
  25.                 newArray[arrayPos] = array[x];
  26.                 arrayPos++;
  27.             }
  28.         }
  29.         return newArray;
  30.     }
  31.  
  32.     public void fixShop(Client o){
  33.         o.playerShop = fixArray(o.playerShop);
  34.         o.playerShopN = fixArray(o.playerShopN);
  35.         o.playerShopP = fixArray(o.playerShopP);   
  36.     }
  37.  
  38.     public void resetShop(Client o) {
  39.         synchronized(c) {
  40.             fixShop(o);
  41.             for (int x = 0; x < 10; x++) {
  42.                 if (o.playerShopN[x] <= 0) {
  43.                     o.playerShop[x] = 0;
  44.                 }
  45.             }
  46.             int TotalItems = 0;
  47.             for (int i = 0; i < 10; i++) {
  48.                 if (o.playerShop[i] > 0) {
  49.                     TotalItems++;
  50.                 }
  51.             }
  52.             if (TotalItems > 10) {
  53.                 TotalItems = 10;
  54.             }
  55.             c.getOutStream().createFrameVarSizeWord(53);
  56.             c.getOutStream().writeWord(3900);
  57.             c.getOutStream().writeWord(TotalItems);
  58.             int TotalCount = 0;
  59.             for (int i = 0; i < o.playerShop.length; i++) {
  60.                 if (o.playerShop[i] > 0) {
  61.                     if (o.playerShopN[i] > 254) {
  62.                         c.getOutStream().writeByte(255);                   
  63.                         c.getOutStream().writeDWord_v2(o.playerShopN[i]);  
  64.                     } else {
  65.                         c.getOutStream().writeByte(o.playerShopN[i]);
  66.                     }
  67.                     c.getOutStream().writeWordBigEndianA((o.playerShop[i]+1));
  68.                     TotalCount++;
  69.                 }
  70.                 if (TotalCount > TotalItems) {
  71.                     break;
  72.                 }
  73.             }
  74.             c.getOutStream().endFrameVarSizeWord();
  75.             c.flushOutStream();
  76.         }
  77.     }
  78.     /*end of player owned shops*/
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. <---Add this in ShopAssistance.java under--->
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. String ShopAdd = ""; in public void buyFromShopPrice(int removeId, int removeSlot){ method.
  93.  
  94.        
  95.         if (c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.playerName.equals(c.playerName)) {
  96.             c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + c.myShopClient.playerShopP[removeSlot] + " coins.");
  97.             return;
  98.         } else if (c.myShopId == 7390 && c.myShopClient != null && c.myShopClient.playerName.equals(c.playerName)) {
  99.             c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + c.playerShopP[removeSlot] + " coins.");
  100.             return;
  101.         }
  102.  
  103.  
  104.  
  105.  
  106.  
  107. <---add this in the public double getItemShopValue(int ItemID, int Type, int fromSlot) under double TotPrice = 0;--->
  108.  
  109.  
  110.  
  111.  
  112.         if(c.myShopId == 7390){
  113.             return c.myShopClient.playerShopP[fromSlot];
  114.         }
  115.  
  116.  
  117.  
  118.  
  119. <---Add this in the public boolean buyItem(int itemID, int fromSlot, int amount) method--->
  120.  
  121.  
  122.  
  123.  
  124.         if(c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && !c.playerName.equals(c.myShopClient.playerName)){
  125.             int bought = 0;
  126.             int price = c.myShopClient.playerShopP[fromSlot];
  127.             if(amount > c.myShopClient.playerShopN[fromSlot])
  128.                 amount = c.myShopClient.playerShopN[fromSlot];
  129.             for(int x = 0; x < amount; x++){
  130.                 if(c.getItems().playerHasItem(995, c.myShopClient.playerShopP[fromSlot]) && c.getItems().freeSlots() > 0){
  131.                     c.getItems().deleteItem2(995, c.myShopClient.playerShopP[fromSlot]);
  132.                     c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
  133.                     c.myShopClient.playerShopN[fromSlot]--;
  134.                     c.myShopClient.playerCollect += c.myShopClient.playerShopP[fromSlot];
  135.                     if(c.myShopClient.playerShopN[fromSlot] == 0){
  136.                         c.myShopClient.playerShop[fromSlot] = 0;
  137.                         c.myShopClient.playerShopP[fromSlot] = 0;
  138.                     }
  139.                     bought++;
  140.                 }else{
  141.                     c.sendMessage("Not enought space or money.");
  142.                     break;
  143.                 }
  144.             }
  145.             if(bought > 0){
  146.             resetShop(c.myShopClient);
  147.             c.getItems().resetItems(3823);;
  148.             c.sendMessage("You just bought "+bought+" "+c.getItems().getItemName(itemID)+" for "+ (bought*price) +" gold.");
  149.             c.myShopClient.sendMessage(c.playerName+" has bought "+bought+" "+c.getItems().getItemName(itemID)+" from you!");
  150.             //c.myShopClient.sendMessage("You now have "+c.myShopClient.playerCollect+" coins to collect (::collect)");
  151.             }
  152.             return false;
  153.         }else if(c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && c.playerName.equals(c.myShopClient.playerName)){
  154.             if(amount > c.myShopClient.playerShopN[fromSlot])
  155.                 amount = c.myShopClient.playerShopN[fromSlot];
  156.             for(int x = 0; x < amount; x++){
  157.                 if(c.getItems().freeSlots() > 0){
  158.                     c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
  159.                     c.myShopClient.playerShopN[fromSlot]--;
  160.                     if(c.myShopClient.playerShopN[fromSlot] == 0){
  161.                         c.myShopClient.playerShop[fromSlot] = 0;
  162.                         c.myShopClient.playerShopP[fromSlot] = 0;
  163.                         fixShop(c);
  164.                     }
  165.                 }else{
  166.                     c.sendMessage("Not enought space.");
  167.                     break;
  168.                 }
  169.             }
  170.             resetShop(c.myShopClient);
  171.             c.getItems().resetItems(3823);
  172.             return false;
  173.         }else if(c.myShopId == 7390){
  174.             return false;
  175.         }
  176.  
  177.  
  178.  
  179.  
  180.  
  181. <---Add this in the public boolean sellItem(int itemID, int fromSlot, int amount) method--->
  182.  
  183.  
  184.  
  185.  
  186.         if(c.myShopId == 7390){
  187.             for (int i : Config.ITEM_TRADEABLE)  {
  188.                 if(i == itemID) {
  189.                     c.sendMessage("You can't sell this item.");
  190.                     return false;
  191.                 }      
  192.             }
  193.             if(c.playerName.equals(c.myShopClient.playerName)){
  194.             c.sellingId = itemID;
  195.             c.sellingN = amount;
  196.             c.sellingS = fromSlot;
  197.             c.xInterfaceId = 7390;
  198.             c.outStream.createFrame(27);
  199.             }else{
  200.                 c.sendMessage("You can only sell items to your own shop.");
  201.             }
  202.             return true;
  203.         }
  204.  
  205.  
  206.  
  207.  
  208. <---Add this to public void sellToShopPrice(int removeId, int removeSlot) method--->
  209.  
  210.  
  211.  
  212.         if(c.myShopId == 7390){
  213.             c.sendMessage("You choose your price when using Player Owned Shops.");
  214.             return;
  215.         }
  216.  
  217.  
  218.  
  219. <---Open up Player.java and add these.--->
  220.  
  221.  
  222.  
  223.  
  224.     public Client myShopClient;
  225.    
  226.     public int sellingId;
  227.     public int sellingN;
  228.     public int sellingS;
  229.     public int playerCollect;
  230.     public int playerShop[] = new int[10];
  231.     public int playerShopN[] = new int[10];
  232.     public int playerShopP[] = new int[10];
  233.  
  234.  
  235. <---Open up BankX2.java and add this.--->
  236.  
  237.  
  238.  
  239.  
  240.                 if(c.sellingId > 0 && c.sellingN > 0 && c.xInterfaceId == 7390){
  241.             for (int i : Config.ITEM_TRADEABLE)  {
  242.                 if(i == c.sellingId) {
  243.                     c.sendMessage("You can't sell this item.");
  244.                     c.sellingId = 0;
  245.                     c.sellingN = 0;
  246.                     c.sellingS = 0;
  247.                     return;
  248.                 }      
  249.             }
  250.             if(c.sellingN > c.getItems().getItemAmount(c.sellingId))
  251.                 c.sellingN = c.getItems().getItemAmount(c.sellingId);
  252.             int slot = -1;
  253.             for(int x = 0; x < 10; x++){
  254.                 if(c.playerShop[x] == 0){
  255.                     slot = x;
  256.                     break;
  257.                 }
  258.             }
  259.             if(slot == -1){
  260.                 c.sendMessage("You are only allows to sell 10 items at any time.");
  261.                 c.sellingId = 0;
  262.                 c.sellingN = 0;
  263.                 c.sellingS = 0;
  264.                 return;
  265.             }
  266.             if(c.getItems().playerHasItem(c.sellingId, c.sellingN, c.sellingS)){
  267.                 c.getItems().deleteItem2(c.sellingId, c.sellingN);
  268.                 c.playerShop[slot] = c.sellingId;
  269.                 c.playerShopN[slot] = c.sellingN;
  270.                 c.playerShopP[slot] = Xamount;
  271.                 c.sendMessage("You put your items on sale.");
  272.             }
  273.             c.getShops().openPlayerShop(c);
  274.             c.sellingId = 0;
  275.             c.sellingN = 0;
  276.             c.sellingS = 0;
  277.             return;
  278.         }
  279.  
  280.  
  281.  
  282.  
  283. <---Add this in Client.java under your first getPA().showOption(3, 0, "Attack", 1);--->
  284.  
  285.  
  286. } else if (!inWild() && !inDuelArena()){
  287.     getPA().showOption(3, 0, "View shop", 1);  
  288.  
  289.  
  290. <---Add this to your commands.java--->
  291.  
  292.         if(playerCommand.equalsIgnoreCase("collect")){
  293.             if(c.playerCollect > 0){
  294.             c.sendMessage("You succesfully collected "+c.playerCollect+" coins.");
  295.             c.getItems().addItem(995, c.playerCollect);
  296.             c.playerCollect = 0;
  297.             }else{
  298.             c.sendMessage("You dont have anything to collect");
  299.             }
  300.         }
  301.         if(playerCommand.equalsIgnoreCase("myshop")){
  302.             c.getShops().openPlayerShop(c);
  303.         }
  304.  
  305.  
  306.  
  307.  
  308.  
  309. <---Add this to PlayerSave.java--->
  310.  
  311.  
  312.                 case 10:
  313.                     if (token.equals("character-shop")) {
  314.                         p.playerShop[Integer.parseInt(token3[0])] = Integer.parseInt(token3[1]);
  315.                         p.playerShopP[Integer.parseInt(token3[0])] = Integer.parseInt(token3[2]);
  316.                         p.playerShopN[Integer.parseInt(token3[0])] = Integer.parseInt(token3[3]);
  317.                     }
  318.                 break; 
  319.  
  320.  
  321.  
  322.  
  323.                 } else if (line.equals("[SHOP]")) {     ReadMode = 10;
  324.  
  325.  
  326.  
  327.             /*SHOP*/
  328.             characterfile.write("[SHOP]", 0, 6);
  329.             characterfile.newLine();
  330.             for (int i = 0; i < p.playerShop.length; i++) {
  331.                 if (p.playerShop[i] > 0) {
  332.                     characterfile.write("character-shop = ", 0, 17);
  333.                     characterfile.write(Integer.toString(i), 0, Integer.toString(i).length());
  334.                     characterfile.write("   ", 0, 1);
  335.                     characterfile.write(Integer.toString(p.playerShop[i]), 0, Integer.toString(p.playerShop[i]).length());
  336.                     characterfile.write("   ", 0, 1);
  337.                     characterfile.write(Integer.toString(p.playerShopP[i]), 0, Integer.toString(p.playerShopP[i]).length());
  338.                     characterfile.write("   ", 0, 1);
  339.                     characterfile.write(Integer.toString(p.playerShopN[i]), 0, Integer.toString(p.playerShopN[i]).length());
  340.                     characterfile.newLine();
  341.                 }
  342.             }
  343.             characterfile.newLine();
  344.  
  345.  
  346.  
  347.  
  348. That should be it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement