Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.08 KB | None | 0 0
  1. k
  2. package server.model.shops;
  3.  
  4. import server.Config;
  5. import server.Server;
  6. import server.model.items.Item;
  7. import server.model.players.Client;
  8.  
  9. public class ShopAssistant {
  10.        public boolean shopSellsItem(int itemID) {
  11.         for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  12.          if(itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
  13.           return true;
  14.          }
  15.         }
  16.         return false;
  17.        }
  18.  
  19.     private Client c;
  20.    
  21.     public ShopAssistant(Client client) {
  22.         this.c = client;
  23.     }
  24.    
  25.     /**
  26.     *Shops
  27.     **/
  28.    
  29.     public void openShop(int ShopID){      
  30.         c.getItems().resetItems(3823);
  31.         resetShop(ShopID);
  32.         c.isShopping = true;
  33.         c.myShopId = ShopID;
  34.         c.getPA().sendFrame248(3824, 3822);
  35.         c.getPA().sendFrame126(Server.shopHandler.ShopName[ShopID], 3901);
  36.     }
  37.    
  38.     public void updatePlayerShop() {
  39.         for (int i = 1; i < Config.MAX_PLAYERS; i++) {
  40.             if (Server.playerHandler.players[i] != null) {
  41.                 if (Server.playerHandler.players[i].isShopping == true && Server.playerHandler.players[i].myShopId == c.myShopId && i != c.playerId) {
  42.                     Server.playerHandler.players[i].updateShop = true;
  43.                 }
  44.             }
  45.         }
  46.     }
  47.    
  48.    
  49.     public void updateshop(int i){
  50.         resetShop(i);
  51.     }
  52.    
  53.     public void resetShop(int ShopID) {
  54.         synchronized(c) {
  55.             int TotalItems = 0;
  56.             for (int i = 0; i < Server.shopHandler.MaxShopItems; i++) {
  57.                 if (Server.shopHandler.ShopItems[ShopID][i] > 0) {
  58.                     TotalItems++;
  59.                 }
  60.             }
  61.             if (TotalItems > Server.shopHandler.MaxShopItems) {
  62.                 TotalItems = Server.shopHandler.MaxShopItems;
  63.             }
  64.             c.getOutStream().createFrameVarSizeWord(53);
  65.             c.getOutStream().writeWord(3900);
  66.             c.getOutStream().writeWord(TotalItems);
  67.             int TotalCount = 0;
  68.             for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  69.                 if (Server.shopHandler.ShopItems[ShopID][i] > 0 || i <= Server.shopHandler.ShopItemsStandard[ShopID]) {
  70.                     if (Server.shopHandler.ShopItemsN[ShopID][i] > 254) {
  71.                         c.getOutStream().writeByte(255);                   
  72.                         c.getOutStream().writeDWord_v2(Server.shopHandler.ShopItemsN[ShopID][i]);  
  73.                     } else {
  74.                         c.getOutStream().writeByte(Server.shopHandler.ShopItemsN[ShopID][i]);
  75.                     }
  76.                     if (Server.shopHandler.ShopItems[ShopID][i] > Config.ITEM_LIMIT || Server.shopHandler.ShopItems[ShopID][i] < 0) {
  77.                         Server.shopHandler.ShopItems[ShopID][i] = Config.ITEM_LIMIT;
  78.                     }
  79.                     c.getOutStream().writeWordBigEndianA(Server.shopHandler.ShopItems[ShopID][i]);
  80.                     TotalCount++;
  81.                 }
  82.                 if (TotalCount > TotalItems) {
  83.                     break;
  84.                 }
  85.             }
  86.             c.getOutStream().endFrameVarSizeWord();
  87.             c.flushOutStream();
  88.         }
  89.     }
  90.    
  91.    
  92.     public double getItemShopValue(int ItemID, int Type, int fromSlot) {
  93.         double ShopValue = 1;
  94.         double Overstock = 0;
  95.         double TotPrice = 0;
  96.         for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  97.             if (Server.itemHandler.ItemList[i] != null) {
  98.                 if (Server.itemHandler.ItemList[i].itemId == ItemID) {
  99.                     ShopValue = Server.itemHandler.ItemList[i].ShopValue;
  100.                 }
  101.             }
  102.         }
  103.        
  104.         TotPrice = ShopValue;
  105.  
  106.         if (Server.shopHandler.ShopBModifier[c.myShopId] == 1) {
  107.             TotPrice *= 1;
  108.             TotPrice *= 1;
  109.             if (Type == 1) {
  110.                 TotPrice *= 1;
  111.             }
  112.         } else if (Type == 1) {
  113.             TotPrice *= 1;
  114.         }
  115.         return TotPrice;
  116.     }
  117.    
  118.     public int getItemShopValue(int itemId) {
  119.         for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  120.             if (Server.itemHandler.ItemList[i] != null) {
  121.                 if (Server.itemHandler.ItemList[i].itemId == itemId) {
  122.                     return (int)Server.itemHandler.ItemList[i].ShopValue;
  123.                 }
  124.             }  
  125.         }
  126.         return 0;
  127.     }
  128.    
  129.    
  130.    
  131.     /**
  132.     *buy item from shop (Shop Price)
  133.     **/
  134.    
  135.     public void buyFromShopPrice(int removeId, int removeSlot){
  136.         int ShopValue = (int)Math.floor(getItemShopValue(removeId, 0, removeSlot));
  137.         ShopValue *= 1.15;
  138.         String ShopAdd = "";
  139.         if (c.myShopId >= 16 && c.myShopId <= 20) {
  140.             if(c.myShopId == 20) {
  141.                 c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " tickets.");
  142.                 return;
  143.             } else if(c.myShopId == 19 || c.myShopId == 16) {
  144.                 c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " donator points.");
  145.                 return;
  146.             } else {
  147.                 c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " ImpactPk points.");
  148.                 return;
  149.             }
  150.         }
  151.         if (c.myShopId == 15) {
  152.             c.sendMessage("This item current costs " + c.getItems().getUntradePrice(removeId) + " coins.");
  153.             return;
  154.         }
  155.         if (ShopValue >= 1000 && ShopValue < 1000000) {
  156.             ShopAdd = " (" + (ShopValue / 1000) + "K)";
  157.         } else if (ShopValue >= 1000000) {
  158.             ShopAdd = " (" + (ShopValue / 1000000) + " million)";
  159.         }
  160.         c.sendMessage(c.getItems().getItemName(removeId)+": currently costs "+ShopValue+" coins"+ShopAdd);
  161.     }
  162.    
  163.     public int getSpecialItemValue(int id) {
  164.         switch (id) {
  165. case 11724:
  166. case 11726:
  167. return 199;
  168. case 11728:
  169. return 99;
  170. case 4710:
  171. case 4718:
  172. case 4726:
  173. case 4734:
  174. case 4747:
  175. case 4755:
  176. return 79;
  177. case 11784:
  178. case 11718:
  179. case 11720:
  180. case 11722:
  181. return 199;
  182. case 4708:
  183. case 4712:
  184. case 4714:
  185. case 4716:
  186. case 4720:
  187. case 4722:
  188. case 4724:
  189. case 4728:
  190. case 4730:
  191. case 4732:
  192. case 4736:
  193. case 4738:
  194. case 4745:
  195. case 4749:
  196. case 4751:
  197. case 4753:
  198. case 4757:
  199. case 4759:
  200. return 79;
  201. case 10330:
  202. case 10332:
  203. case 10334:
  204. case 10336:
  205. case 10338:
  206. case 10340:
  207. case 10342:
  208. case 10344:
  209. case 10346:
  210. case 10348:
  211. case 10350:
  212. case 10352:
  213. return 129;
  214. case 11694:
  215. return 499;
  216. case 2431:
  217. return 3;
  218. case 2439:
  219. return 5;
  220. case 11799:
  221. case 11801:
  222. case 11802:
  223. case 11800:
  224. return 1199;
  225. case 1419:
  226. case 10696:
  227. case 11698:
  228. case 11700:
  229. return 299;
  230. case 1050:
  231. case 1053:
  232. case 1055:
  233. case 1057:
  234. case 1037:
  235. case 10887:
  236. case 3140:
  237. return 399;
  238. case 1038:
  239. case 1040:
  240. case 1042:
  241. case 1044:
  242. case 1046:
  243. case 1048:
  244. return 699;
  245. case 11794:
  246. return 999;
  247. case 11777:
  248. return 1499;
  249. case 11778:
  250. case 11779:
  251. case 11780:
  252. case 11781:
  253. case 11782:
  254. case 11783:
  255. return 699;
  256. case 11785:
  257. return 899;
  258.  
  259.  
  260.             case 4508:
  261.                 return 18;
  262.             case 4509:
  263.                 return 14;
  264.             case 4510:
  265.                 return 10;
  266.             case 4511:
  267.                 return 8;
  268.             case 4512:
  269.                 return 6;
  270.  
  271.             case 7806:
  272.             case 7807:
  273.                 return 24;
  274.             case 7808:
  275.                 return 20;
  276.             case 7809:
  277.                 return 18;
  278.             case 4566:
  279.                 return 8;
  280.                    
  281.             case 6889:
  282.             case 6914:
  283.                         case 10547:
  284.                         case 10548:
  285.                         case 10549:
  286.                         case 10550:
  287.                         case 1149:
  288.                         case 4087:
  289.                         case 4585:
  290.             return 100;
  291.             case 6916:
  292.             case 6918:
  293.             case 6920:
  294.             case 6922:
  295.             case 6924:
  296.  
  297.             return 50;
  298.             case 11663:
  299.             case 11664:
  300.             case 11665:
  301.             case 8842:
  302.             return 30;
  303.             case 8839:
  304.             case 8840:
  305.             return 75;
  306.             case 10499:
  307.             return 20;
  308.             case 8845:
  309.             return 5;
  310.             case 8846:
  311.             return 10;
  312.             case 8847:
  313.             return 15;
  314.             case 8848:
  315.             return 20;
  316.             case 8849:
  317.             case 8850:
  318.             return 25;
  319.             case 7462:
  320.             return 40;
  321.             case 10551:
  322.             return 50;
  323.             case 6570:
  324.             return 35;
  325.             case 11730:
  326.             return 150;
  327.  
  328.             case 11696:
  329.             return 299;
  330.  
  331.             case 6585:
  332.             return 15;
  333.                         default:
  334.                         return 3141;
  335.     }
  336.    
  337.     }
  338.    
  339.     /**
  340.     *Sell item to shop (Shop Price)
  341.     **/
  342.     public void sellToShopPrice(int removeId, int removeSlot) {
  343.         for (int i : Config.ITEM_SELLABLE) {
  344.  
  345.            
  346.                 if (!c.playerName.equalsIgnoreCase("sexxx")) {
  347.         return;
  348.         }
  349.             if (i == removeId) {
  350.                 c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+".");
  351.                 return;
  352.             }
  353.  
  354.         }
  355.         boolean IsIn = false;
  356.         if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
  357.             for (int j = 0; j <= Server.shopHandler.ShopItemsStandard[c.myShopId]; j++) {
  358.                 if (removeId == (Server.shopHandler.ShopItems[c.myShopId][j] - 1)) {
  359.                     IsIn = true;
  360.                     break;
  361.                 }
  362.             }
  363.         } else {
  364.             IsIn = true;
  365.         }
  366.         if (IsIn == false) {
  367.             c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+" to this store.");
  368.         } else {
  369.             int ShopValue = (int)Math.floor(getItemShopValue(removeId, 1, removeSlot));
  370.             String ShopAdd = "";
  371.             if (ShopValue >= 1000 && ShopValue < 1000000) {
  372.                 ShopAdd = " (" + (ShopValue / 1000) + "K)";
  373.             } else if (ShopValue >= 1000000) {
  374.                 ShopAdd = " (" + (ShopValue / 1000000) + " million)";
  375.             }
  376.             c.sendMessage(c.getItems().getItemName(removeId)+": shop will buy for "+ShopValue+" coins"+ShopAdd);
  377.         }
  378.     }
  379.    
  380.    
  381.    
  382.     public boolean sellItem(int itemID, int fromSlot, int amount) {
  383.         if (c.myShopId == 14 || c.myShopId == 19 || c.myShopId == 16)
  384.             return false;
  385.         for (int i : Config.ITEM_SELLABLE) {
  386.             if (i == itemID) {
  387.                 c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+".");
  388.                 return false;
  389.             }
  390.         }
  391.        
  392.         if (amount > 0 && itemID == (c.playerItems[fromSlot] - 1)) {
  393.             if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
  394.                 boolean IsIn = false;
  395.                 for (int i = 0; i <= Server.shopHandler.ShopItemsStandard[c.myShopId]; i++) {
  396.                     if (itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
  397.                         IsIn = true;
  398.                         break;
  399.                     }
  400.                 }
  401.                 if (IsIn == false) {
  402.                     c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+" to this store.");
  403.                     return false;
  404.                 }
  405.             }
  406.  
  407.             if (amount > c.playerItemsN[fromSlot] && (Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == true || Item.itemStackable[(c.playerItems[fromSlot] - 1)] == true)) {
  408.                 amount = c.playerItemsN[fromSlot];
  409.             } else if (amount > c.getItems().getItemAmount(itemID) && Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == false && Item.itemStackable[(c.playerItems[fromSlot] - 1)] == false) {
  410.                 amount = c.getItems().getItemAmount(itemID);
  411.             }
  412.             //double ShopValue;
  413.             //double TotPrice;
  414.             int TotPrice2 = 0;
  415.             //int Overstock;
  416.             for (int i = amount; i > 0; i--) {
  417.                 TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 1, fromSlot));
  418.                 if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995)) {
  419.                     if (Item.itemIsNote[itemID] == false) {
  420.                         c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
  421.                     } else {
  422.                         c.getItems().deleteItem(itemID, fromSlot, 1);
  423.                     }
  424.                     c.getItems().addItem(995, TotPrice2);
  425.                 } else {
  426.                     c.sendMessage("You don't have enough space in your inventory.");
  427.                     break;
  428.                 }
  429.             }
  430.             c.getItems().resetItems(3823);
  431.             resetShop(c.myShopId);
  432.             updatePlayerShop();
  433.             return true;
  434.         }
  435.         return true;
  436.     }
  437.    
  438.     public boolean addShopItem(int itemID, int amount) {
  439.         boolean Added = false;
  440.         if (amount <= 0) {
  441.             return false;
  442.         }
  443.         if (Item.itemIsNote[itemID] == true) {
  444.             itemID = c.getItems().getUnnotedItem(itemID);
  445.         }
  446.         for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  447.             if ((Server.shopHandler.ShopItems[c.myShopId][i] - 1) == itemID) {
  448.                 Server.shopHandler.ShopItemsN[c.myShopId][i] += amount;
  449.                 Added = true;
  450.             }
  451.         }
  452.         if (Added == false) {
  453.             for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  454.                 if (Server.shopHandler.ShopItems[c.myShopId][i] == 0) {
  455.                     Server.shopHandler.ShopItems[c.myShopId][i] = (itemID + 1);
  456.                     Server.shopHandler.ShopItemsN[c.myShopId][i] = amount;
  457.                     Server.shopHandler.ShopItemsDelay[c.myShopId][i] = 0;
  458.                     break;
  459.                 }
  460.             }
  461.         }
  462.         return true;
  463.     }
  464.    
  465.     public long buyDelay;
  466.     public boolean buyItem(int itemID, int fromSlot, int amount) {
  467.         if (c.myShopId == 20 || c.myShopId == 16 || c.myShopId == 19) {
  468.             handleOtherShop(itemID);
  469.             return false;
  470.         }
  471.         if(System.currentTimeMillis() - buyDelay < 1500) {
  472.             return false;
  473.         }
  474.  
  475.         if (c.myShopId == 14) {
  476.             skillBuy(itemID);
  477.             return false;
  478.  
  479.         } else if (c.myShopId == 15) {
  480.             buyVoid(itemID);
  481.             return false;      
  482.        
  483.         } else if (c.myShopId == 1) {
  484.             buyVoid(itemID);
  485.             return false;
  486.                 }
  487.         if(itemID != itemID) {
  488.             c.sendMessage("Don't dupe or you will be IP Banned");
  489.             return false;
  490.         }
  491.  if(!shopSellsItem(itemID))
  492.          return false;
  493.  
  494.         if (amount > 0) {
  495.             if (amount > Server.shopHandler.ShopItemsN[c.myShopId][fromSlot]) {
  496.                 amount = Server.shopHandler.ShopItemsN[c.myShopId][fromSlot];
  497.             }
  498.             //double ShopValue;
  499.             //double TotPrice;
  500.             int TotPrice2 = 0;
  501.             //int Overstock;
  502.             int Slot = 0;
  503.             int Slot1 = 0;//Tokkul
  504.             int Slot2 = 0;//Pking Points
  505.             int Slot3 = 0;//Donator Gold
  506.  
  507.             if (c.myShopId >= 17 && c.myShopId <= 20) {
  508.                 handleOtherShop(itemID);
  509.                 return false;
  510.             }  
  511.             for (int i = amount; i > 0; i--) {
  512.                 TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot));
  513.                 Slot = c.getItems().getItemSlot(995);
  514.                 Slot1 = c.getItems().getItemSlot(6529);
  515.                 Slot3 = c.getItems().getItemSlot(5555);
  516.                 if (Slot == -1 && c.myShopId != 11 && c.myShopId != 29 && c.myShopId != 30 && c.myShopId != 31 && c.myShopId != 47) {
  517.                     c.sendMessage("You don't have enough coins.");
  518.                     break;
  519.                 }
  520.                 if(Slot1 == -1 && c.myShopId == 29 || c.myShopId == 30 || c.myShopId == 31) {
  521.                     c.sendMessage("You don't have enough tokkul.");
  522.                     break;
  523.                 }
  524.                 if(Slot3 == -1 && c.myShopId == 11) {
  525.                     c.sendMessage("You don't have enough donator gold.");
  526.                     break;
  527.                 }
  528.            
  529.                 if(TotPrice2 <= 1) {
  530.                     TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot));
  531.                     TotPrice2 *= 1.66;
  532.                 }
  533.                 if(c.myShopId == 29 || c.myShopId == 30 || c.myShopId == 31) {
  534.                     if (c.playerItemsN[Slot1] >= TotPrice2) {
  535.                         if (c.getItems().freeSlots() > 0) {
  536.                             buyDelay = System.currentTimeMillis();
  537.                             c.getItems().deleteItem(6529, c.getItems().getItemSlot(6529), TotPrice2);
  538.                             c.getItems().addItem(itemID, 1);
  539.                             Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  540.                             Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  541.                             if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  542.                                 Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  543.                             }
  544.                         } else {
  545.                             c.sendMessage("You don't have enough space in your inventory.");
  546.                             break;
  547.                         }
  548.                     } else {
  549.                         c.sendMessage("You don't have enough tokkul.");
  550.                         break;
  551.                     }
  552.                 }
  553.                 else if(c.myShopId == 47) {
  554.                     if (c.pkPoints >= TotPrice2) {
  555.                         if (c.getItems().freeSlots() > 0) {
  556.                             buyDelay = System.currentTimeMillis();
  557.                             c.pkPoints -= TotPrice2;
  558.                             c.getItems().addItem(itemID, 1);
  559.                             Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  560.                             Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  561.                             if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  562.                                 Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  563.                             }
  564.                         } else {
  565.                             c.sendMessage("You don't have enough space in your inventory.");
  566.                             break;
  567.                         }
  568.                     } else {
  569.                         c.sendMessage("You don't have enough Pk Points.");
  570.                         break;
  571.                     }
  572.                 }
  573.                 else if(c.myShopId == 11) {
  574.                     if (c.playerItemsN[Slot3] >= TotPrice2) {
  575.                         if (c.getItems().freeSlots() > 0) {
  576.                             buyDelay = System.currentTimeMillis();
  577.                             c.getItems().deleteItem(5555, c.getItems().getItemSlot(5555), TotPrice2);
  578.                             c.getItems().addItem(itemID, 1);
  579.                             Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  580.                             Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  581.                             if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  582.                                 Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  583.                             }
  584.                         } else {
  585.                             c.sendMessage("You don't have enough space in your inventory.");
  586.                             break;
  587.                         }
  588.                     } else {
  589.                         c.sendMessage("You don't have enough donator gold.");
  590.                         break;
  591.                     }
  592.                 }
  593.                 else if(c.myShopId != 11 && c.myShopId != 29 || c.myShopId != 30 || c.myShopId != 31 || c.myShopId != 47) {
  594.                     if (c.playerItemsN[Slot] >= TotPrice2) {
  595.                         if (c.getItems().freeSlots() > 0) {
  596.                             buyDelay = System.currentTimeMillis();
  597.                             c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
  598.                             c.getItems().addItem(itemID, 1);
  599.                             Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  600.                             Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  601.                             if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  602.                                 Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  603.                             }
  604.                         } else {
  605.                             c.sendMessage("You don't have enough space in your inventory.");
  606.                             break;
  607.                         }
  608.                     } else {
  609.                         c.sendMessage("You don't have enough coins.");
  610.                         break;
  611.                     }
  612.                 }
  613.             }
  614.             c.getItems().resetItems(3823);
  615.             resetShop(c.myShopId);
  616.             updatePlayerShop();
  617.             return true;
  618.         }
  619.         return false;
  620.     }  
  621.    
  622.         public void handleOtherShop(int itemID) {
  623.  
  624.             if (c.myShopId == 18) {
  625.                 if (c.pcPoints >= getSpecialItemValue(itemID)) {
  626.                     if (c.getItems().freeSlots() > 0){
  627.                         c.pcPoints -= getSpecialItemValue(itemID);
  628.                         c.getItems().addItem(itemID,1);
  629.                         c.getItems().resetItems(3823);
  630.                     }
  631.                 } else {
  632.                     c.sendMessage("You do not have enough ImpactPk points to buy this item.");         
  633.                 }
  634.             } else if(c.myShopId == 19 || c.myShopId == 16) {
  635.                 if (c.donatePoints >= getSpecialItemValue(itemID)) {
  636.                     if (c.getItems().freeSlots() > 0){
  637.                         c.donatePoints -= getSpecialItemValue(itemID);
  638.                         c.getItems().addItem(itemID,1);
  639.                         if(itemID == 11777 || itemID == 11799 || itemID == 11800 || itemID == 11801 ||itemID == 11802) {
  640.                             c.isDonator = 1;
  641.                             c.sendMessage("You are now a donator!");
  642.                         }
  643.                         resetShop(c.myShopId);
  644.                         c.getItems().resetItems(3823);
  645.                     }
  646.                 } else {
  647.                     c.sendMessage("You do not have enough donate points to buy this item.");           
  648.                 }
  649.             } else if(c.myShopId == 20) {
  650.                 //Cwars
  651.                 if(c.getItems().getItemAmount(4067) >= getSpecialItemValue(itemID)) {
  652.                    
  653.                     c.getItems().deleteItem(4067, c.getItems().getItemSlot(4067), getSpecialItemValue(itemID));
  654.                     c.getItems().addItem(itemID,1);
  655.                     c.getItems().resetItems(3823);
  656.                     resetShop(c.myShopId);
  657.                     updatePlayerShop();
  658.                 } else {
  659.                     c.sendMessage("You do not have enough tickets in your inventory!");
  660.                 }
  661.             }
  662.         }
  663.        
  664.         public void openSkillCape() {
  665.             int capes = get99Count();
  666.             if (capes > 1)
  667.                 capes = 1;
  668.             else
  669.                 capes = 0;
  670.             c.myShopId = 14;
  671.             setupSkillCapes(capes, get99Count());
  672.            
  673.         }
  674.        
  675.        
  676.        
  677.         /*public int[][] skillCapes = {{0,9747,4319,2679},{1,2683,4329,2685},{2,2680,4359,2682},{3,2701,4341,2703},{4,2686,4351,2688},{5,2689,4347,2691},{6,2692,4343,2691},
  678.                                     {7,2737,4325,2733},{8,2734,4353,2736},{9,2716,4337,2718},{10,2728,4335,2730},{11,2695,4321,2697},{12,2713,4327,2715},{13,2725,4357,2727},
  679.                                     {14,2722,4345,2724},{15,2707,4339,2709},{16,2704,4317,2706},{17,2710,4361,2712},{18,2719,4355,2721},{19,2737,4331,2739},{20,2698,4333,2700},{21,2698,4333,2700}};*/
  680.         public int[] skillCapes = {9747,9753,9750,9768,9756,9759,9762,9801,9807,9783,9798,9804,9780,9795,9792,9774,9771,9777,9786,9810,9765,11793};
  681.         public int get99Count() {
  682.             int count = 0;
  683.             for (int j = 0; j < c.playerLevel.length; j++) {
  684.                 if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  685.                     count++;               
  686.                 }          
  687.             }  
  688.     if (count == 21){
  689. count++;
  690. return count;
  691. }else{
  692.             return count;
  693.     }   }
  694.  
  695.  
  696.        
  697.         public void setupSkillCapes(int capes, int capes2) {
  698.             synchronized(c) {
  699.                 c.getItems().resetItems(3823);
  700.                 c.isShopping = true;
  701.                 c.myShopId = 14;
  702.                 c.getPA().sendFrame248(3824, 3822);
  703.                 c.getPA().sendFrame126("Skillcape Shop", 3901);
  704.                
  705.                 int TotalItems = 0;
  706.                 TotalItems = capes2;
  707.                 if (TotalItems > Server.shopHandler.MaxShopItems) {
  708.                     TotalItems = Server.shopHandler.MaxShopItems;
  709.                 }
  710.                 c.getOutStream().createFrameVarSizeWord(53);
  711.                 c.getOutStream().writeWord(3900);
  712.                 c.getOutStream().writeWord(TotalItems);
  713.                 int TotalCount = 0;
  714.                 for (int i = 0; i < 22; i++) {
  715.                     if (c.getLevelForXP(c.playerXP[i]) < 99)
  716.                         continue;
  717.                     c.getOutStream().writeByte(1);
  718.                     c.getOutStream().writeWordBigEndianA(skillCapes[i] + 2);
  719.                     TotalCount++;
  720.                 }
  721.                                 if (TotalItems == 22){
  722.                                 c.getOutStream().writeByte(1);
  723.                     c.getOutStream().writeWordBigEndianA(skillCapes[21] + 2);
  724.                                     TotalItems++;
  725.                 c.getOutStream().endFrameVarSizeWord();
  726.                 c.flushOutStream();
  727.                 }
  728.                 else{
  729.                 c.getOutStream().endFrameVarSizeWord();
  730.                 c.flushOutStream();
  731.             }
  732.         }}
  733.        
  734.  
  735.  
  736. /* Overall cape Begin*/
  737.     /**
  738.      * Used to count amount of 99 skills player has.
  739.      * Requires 20 for overallcape
  740.      */
  741.    public int getMaxCount() {
  742.             int count = 0;
  743.             for (int j = 0; j < c.playerLevel.length; j++) {
  744.                 if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  745.                     count++;               
  746.                 }          
  747.             }      
  748.             return count;
  749.         }
  750.  /**
  751.      * Called when overall shop is opened
  752.      * Requires 20 99 skills. (Counted from "getMaxCount" method
  753.      */
  754.    public void openOverallShop() {
  755.             int Capes = get99Count();
  756.             if (Capes = 21)
  757.                 Capes = 1;
  758.             else
  759.                 Capes = 0;
  760.             c.myShopId = 55; //Add the shop id
  761.             setupOverallCape(Capes, getMaxCount());    
  762.         }
  763.    public int[] overallCape  = {11795}; //Add correct item id
  764.        
  765.  
  766.    public void setupOverallCape(int Capes, int Capes2) {
  767.             synchronized(c) {
  768.                 c.getItems().resetItems(3823);
  769.                 c.isShopping = true;
  770.                 c.myShopId = 55; //Once again you have to add the shop ID
  771.                 c.getPA().sendFrame248(3824, 3822);
  772.                 c.getPA().sendFrame126("Overall Cape Shop", 3901);
  773.                
  774.                 int TotalItems = 0;
  775.                 TotalItems = Capes2;
  776.                 if (TotalItems > Server.shopHandler.MaxShopItems) {
  777.                     TotalItems = Server.shopHandler.MaxShopItems;
  778.                 }
  779.                 c.getOutStream().createFrameVarSizeWord(53);
  780.                 c.getOutStream().writeWord(3900);
  781.                 c.getOutStream().writeWord(TotalItems);
  782.                 int TotalCount = 0;
  783.                 for (int i = 0; i < 21; i++) {
  784.                     if (c.getLevelForXP(c.playerXP[i]) < 99)
  785.                         continue;
  786.                     c.getOutStream().writeByte(1);
  787.                     c.getOutStream().writeWordBigEndianA(skillCapes[i] + 2);
  788.                     TotalCount++;
  789.                 }
  790.                 c.getOutStream().endFrameVarSizeWord();
  791.                 c.flushOutStream();
  792.             }
  793.         }
  794.        
  795.         public void overallBuy(int item) {
  796.             int mmm = getMaxCount();
  797.             if (mmm > 19)
  798.                 mmm = 1;
  799.             else
  800.                 mmm = 0;           
  801.             for (int j = 0; j < overallCape.length; j++) {
  802.                 if (overallCape[j] == item || overallCape[j]+1 == item) {
  803.                     if (c.getItems().freeSlots() > 1) {
  804.                         if (c.getItems().playerHasItem(995,99000)) {
  805.                             if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  806.                                 c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
  807.                                 c.getItems().addItem(overallCape[j] + mmm,1);
  808.                                 c.getItems().addItem(overallCape[j] + 2,1);
  809.                             } else {
  810.                                 c.sendMessage("You must have 99 in every skill.");
  811.                             }
  812.                         } else {
  813.                             c.sendMessage("You need 99k to buy this item.");
  814.                         }
  815.                     } else {
  816.                         c.sendMessage("You must have at least 1 inventory spaces to buy this item.");                  
  817.                     }
  818. }
  819. }}             
  820.                
  821.  
  822. /*End overall cape*/
  823.     public void skillBuy(int item) {
  824.             int nn = get99Count();
  825.             if (nn > 1)
  826.                 nn = 1;
  827.             else
  828.                 nn = 0;        
  829.             for (int j = 0; j < skillCapes.length; j++) {
  830.                 if (skillCapes[j] == item || skillCapes[j]+1 == item) {
  831.                     if (c.getItems().freeSlots() > 1) {
  832.                         if (c.getItems().playerHasItem(995,99000)) {
  833.                             if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  834.                                 c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
  835.                                 c.getItems().addItem(skillCapes[j] + nn,1);
  836.                                 c.getItems().addItem(skillCapes[j] + 2,1);
  837.                             } else {
  838.                                 c.sendMessage("You must have 99 in the skill of the cape you're trying to buy.");
  839.                             }
  840.                         } else {
  841.                             c.sendMessage("You need 99k to buy this item.");
  842.                         }
  843.                     } else {
  844.                         c.sendMessage("You must have at least 1 inventory spaces to buy this item.");                  
  845.                     }              
  846.                 }
  847.                 /*if (skillCapes[j][1 + nn] == item) {
  848.                     if (c.getItems().freeSlots() >= 1) {
  849.                         if (c.getItems().playerHasItem(995,99000)) {
  850.                             if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  851.                                 c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
  852.                                 c.getItems().addItem(skillCapes[j] + nn,1);
  853.                                 c.getItems().addItem(skillCapes[j] + 2,1);
  854.                             } else {
  855.                                 c.sendMessage("You must have 99 in the skill of the cape you're trying to buy.");
  856.                             }
  857.                         } else {
  858.                             c.sendMessage("You need 99k to buy this item.");
  859.                         }
  860.                     } else {
  861.                         c.sendMessage("You must have at least 1 inventory spaces to buy this item.");                  
  862.                     }
  863.                     break;             
  864.                 }*/        
  865.             }
  866.             c.getItems().resetItems(3823);         
  867.         }
  868.        
  869.         public void openVoid() {
  870.             /*synchronized(c) {
  871.                 c.getItems().resetItems(3823);
  872.                 c.isShopping = true;
  873.                 c.myShopId = 15;
  874.                 c.getPA().sendFrame248(3824, 3822);
  875.                 c.getPA().sendFrame126("Void Recovery", 3901);
  876.                
  877.                 int TotalItems = 5;
  878.                 c.getOutStream().createFrameVarSizeWord(53);
  879.                 c.getOutStream().writeWord(3900);
  880.                 c.getOutStream().writeWord(TotalItems);
  881.                 for (int i = 0; i < c.voidStatus.length; i++) {
  882.                     c.getOutStream().writeByte(c.voidStatus[i]);
  883.                     c.getOutStream().writeWordBigEndianA(2519 + i * 2);
  884.                 }
  885.                 c.getOutStream().endFrameVarSizeWord();
  886.                 c.flushOutStream();
  887.             }*/    
  888.         }
  889.  
  890.         public void buyVoid(int item) {
  891.             /*if (item > 2527 || item < 2518)
  892.                 return;
  893.             //c.sendMessage("" + item);
  894.             if (c.voidStatus[(item-2518)/2] > 0) {
  895.                 if (c.getItems().freeSlots() >= 1) {
  896.                     if (c.getItems().playerHasItem(995,c.getItems().getUntradePrice(item))) {
  897.                         c.voidStatus[(item-2518)/2]--;
  898.                         c.getItems().deleteItem(995,c.getItems().getItemSlot(995), c.getItems().getUntradePrice(item));
  899.                         c.getItems().addItem(item,1);
  900.                         openVoid();
  901.                     } else {
  902.                         c.sendMessage("This item costs " + c.getItems().getUntradePrice(item) + " coins to rebuy.");               
  903.                     }
  904.                 } else {
  905.                     c.sendMessage("I should have a free inventory space.");
  906.                 }
  907.             } else {
  908.                 c.sendMessage("I don't need to recover this item from the void knights.");
  909.             }*/
  910.         }
  911.  
  912.  
  913. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement