Advertisement
Guest User

Shopassistant.java

a guest
May 12th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.56 KB | None | 0 0
  1. package server.model.shops;
  2.  
  3. import server.Config;
  4. import server.Server;
  5. import server.model.items.Item;
  6. import server.model.players.Client;
  7.  
  8. public class ShopAssistant {
  9.  
  10. private Client c;
  11.  
  12. public ShopAssistant(Client client) {
  13. this.c = client;
  14. }
  15.  
  16. /**
  17. *Shops
  18. **/
  19.  
  20. public void openPlayerShop(Client o) {
  21. if (o == null || o.properLogout)
  22. return;
  23. c.getItems().resetItems(3823);
  24. resetShop(o);
  25. c.myShopClient = o;
  26. c.myShopId = 7390;
  27. c.isShopping = true;
  28. c.getPA().sendFrame248(3824, 3822);
  29. c.getPA().sendFrame126(o.playerShopTitle, 3901);
  30. }
  31.  
  32. public int[] fixArray(int[] array) {
  33. int arrayPos = 0;
  34. int[] newArray = new int[array.length];
  35. for (int x = 0; x < array.length; x++) {
  36. if (array[x] != 0) {
  37. newArray[arrayPos] = array[x];
  38. arrayPos++;
  39. }
  40. }
  41. return newArray;
  42. }
  43.  
  44. public void fixShop(Client o) {
  45. o.playerShop = fixArray(o.playerShop);
  46. o.playerShopN = fixArray(o.playerShopN);
  47. o.playerShopP = fixArray(o.playerShopP);
  48. }
  49.  
  50. public void resetShop(Client o) {
  51. synchronized (c) {
  52. fixShop(o);
  53. for (int x = 0; x < o.playerShop.length; x++) {
  54. if (o.playerShopN[x] <= 0) {
  55. o.playerShop[x] = 0;
  56. }
  57. }
  58. int TotalItems = 0;
  59. for (int i = 0; i < o.playerShop.length; i++) {
  60. if (o.playerShop[i] > 0) {
  61. TotalItems++;
  62. }
  63. }
  64. if (TotalItems > o.playerShop.length) {
  65. TotalItems = o.playerShop.length;
  66. }
  67. c.getOutStream().createFrameVarSizeWord(53);
  68. c.getOutStream().writeWord(3900);
  69. c.getOutStream().writeWord(TotalItems);
  70. int TotalCount = 0;
  71. for (int i = 0; i < o.playerShop.length; i++) {
  72. if (o.playerShop[i] > 0) {
  73. if (o.playerShopN[i] > 254) {
  74. c.getOutStream().writeByte(255);
  75. c.getOutStream().writeDWord_v2(o.playerShopN[i]);
  76. } else {
  77. c.getOutStream().writeByte(o.playerShopN[i]);
  78. }
  79. c.getOutStream().writeWordBigEndianA((o.playerShop[i] + 1));
  80. TotalCount++;
  81. }
  82. if (TotalCount > TotalItems) {
  83. break;
  84. }
  85. }
  86. c.getOutStream().endFrameVarSizeWord();
  87. c.flushOutStream();
  88. }
  89. }
  90.  
  91.  
  92.  
  93. public void updatePlayerShop() {
  94. for (int i = 1; i < Config.MAX_PLAYERS; i++) {
  95. if (Server.playerHandler.players[i] != null) {
  96. if (Server.playerHandler.players[i].isShopping == true
  97. && Server.playerHandler.players[i].myShopId == c.myShopId
  98. && i != c.playerId) {
  99. Client sh = (Client) Server.playerHandler.players[i];
  100. //sh.getShops().openShop(sh.myShopId);
  101. Server.playerHandler.players[i].updateShop = true;
  102. }
  103. }
  104. }
  105. }
  106.  
  107. public void updatePlayerOwnedShop(Client x) {
  108. if (x == null)
  109. return;
  110. for (int i = 1; i < Config.MAX_PLAYERS; i++) {
  111. if (Server.playerHandler.players[i] != null) {
  112. if (Server.playerHandler.players[i].myShopClient != null) {
  113. if (x.playerName
  114. .equals(Server.playerHandler.players[i].myShopClient.playerName)) {
  115. Client sh = (Client) Server.playerHandler.players[i];
  116. sh.getShops().openPlayerShop(x);
  117. }
  118. }
  119. }
  120. }
  121. }
  122.  
  123.  
  124. public void openShop(int ShopID){
  125. c.getItems().resetItems(3823);
  126. resetShop(ShopID);
  127. c.isShopping = true;
  128. c.myShopId = ShopID;
  129. c.getPA().sendFrame248(3824, 3822);
  130. c.getPA().sendFrame126(Server.shopHandler.ShopName[ShopID], 3901);
  131.  
  132. if (ShopID == 29 || ShopID == 36)
  133. {
  134. c.getPA().sendFrame126("More", 19680);
  135. }
  136. else if (ShopID == 34 || ShopID == 37)
  137. {
  138. c.getPA().sendFrame126("Less", 19680);
  139. }
  140. else if (ShopID == 32)
  141. {
  142. c.getPA().sendFrame126("Exchange", 19680);
  143. c.canExchange = true;
  144. }
  145. else
  146. {
  147. Server.playerHandler.CantSell = false;
  148. c.canExchange = false;
  149. c.getPA().sendFrame126("Player Stock", 19680);
  150. }
  151. if (ShopID == 38)
  152. c.getPA().sendFrame126("Voting Shop - You have " + c.getVotePoints() + " Voting Points", 3901);
  153. if (ShopID == 29 || ShopID == 34)
  154. c.getPA().sendFrame126("Pk Points Shop - You have " + c.getZPoints() + " Pk Points", 3901);
  155. if (ShopID == 7)
  156. c.getPA().sendFrame126("Dragon Points Shop - You have " + c.getdragonPoints() + " Dragon Points", 3901);
  157. if (ShopID == 30)
  158. c.getPA().sendFrame126("Slayer Points Shop - You have " + c.getslayerPoints() + " Slayer Points", 3901);
  159. }
  160.  
  161.  
  162. public boolean shopSellsItem(int itemID) {
  163. for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  164. if(itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170.  
  171. /**public void updatePlayerShop() {
  172. for (int i = 1; i < Config.MAX_PLAYERS; i++) {
  173. if (Server.playerHandler.players[i] != null) {
  174. if (Server.playerHandler.players[i].isShopping == true && Server.playerHandler.players[i].myShopId == c.myShopId && i != c.playerId) {
  175. Server.playerHandler.players[i].updateShop = true;
  176. Server.playerHandler.players[i].isShopping = false;
  177. }
  178. }
  179. }
  180. }*/
  181.  
  182.  
  183.  
  184. public void updateshop(int i){
  185. resetShop(i);
  186. }
  187.  
  188. public void resetShop(int ShopID) {
  189. //synchronized(c) {
  190. int TotalItems = 0;
  191. for (int i = 0; i < Server.shopHandler.MaxShopItems; i++) {
  192. if (Server.shopHandler.ShopItems[ShopID][i] > 0) {
  193. TotalItems++;
  194. }
  195. }
  196. if (TotalItems > Server.shopHandler.MaxShopItems) {
  197. TotalItems = Server.shopHandler.MaxShopItems;
  198. }
  199. c.getOutStream().createFrameVarSizeWord(53);
  200. c.getOutStream().writeWord(3900);
  201. c.getOutStream().writeWord(TotalItems);
  202. int TotalCount = 0;
  203. for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  204. if (Server.shopHandler.ShopItems[ShopID][i] > 0 || i <= Server.shopHandler.ShopItemsStandard[ShopID]) {
  205. if (Server.shopHandler.ShopItemsN[ShopID][i] > 254) {
  206. c.getOutStream().writeByte(255);
  207. c.getOutStream().writeDWord_v2(Server.shopHandler.ShopItemsN[ShopID][i]);
  208. } else {
  209. c.getOutStream().writeByte(Server.shopHandler.ShopItemsN[ShopID][i]);
  210. }
  211. if (Server.shopHandler.ShopItems[ShopID][i] > Config.ITEM_LIMIT || Server.shopHandler.ShopItems[ShopID][i] < 0) {
  212. Server.shopHandler.ShopItems[ShopID][i] = Config.ITEM_LIMIT;
  213. }
  214. c.getOutStream().writeWordBigEndianA(Server.shopHandler.ShopItems[ShopID][i]);
  215. TotalCount++;
  216. }
  217. if (TotalCount > TotalItems)
  218. break;
  219. }
  220. c.getOutStream().endFrameVarSizeWord();
  221. c.flushOutStream();
  222. //}
  223. }
  224.  
  225. public String getItemDescription(int ItemID) {
  226. String stuff = "NULL";
  227. for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  228. if (Server.itemHandler.ItemList[i] != null) {
  229. if (Server.itemHandler.ItemList[i].itemId == ItemID) {
  230. stuff = Server.itemHandler.ItemList[i].itemDescription;
  231. }
  232. }
  233. }
  234. return stuff;
  235. }
  236.  
  237. public double getItemWeight(int ItemID) {
  238. double itmWeight = 0;
  239. for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  240. if (Server.itemHandler.ItemList[i] != null) {
  241. if (Server.itemHandler.ItemList[i].itemId == ItemID) {
  242. itmWeight = Server.itemHandler.ItemList[i].itemWeight;
  243. }
  244. }
  245. }
  246. return itmWeight;
  247. }
  248.  
  249. public double getItemWeight2(int ItemID) {
  250. double itmWeight2 = 0;
  251. for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  252. if (Server.itemHandler.ItemList[i] != null) {
  253. if (Server.itemHandler.ItemList[i].itemId == ItemID) {
  254. itmWeight2 = Server.itemHandler.ItemList[i].itemWeight2;
  255. }
  256. }
  257. }
  258. return itmWeight2;
  259. }
  260.  
  261.  
  262.  
  263.  
  264.  
  265. public double getItemShopValue(int ItemID, int Type, int fromSlot) {
  266. double ShopValue = 1;
  267. double Overstock = 0;
  268. double TotPrice = 0;
  269. for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  270. if (Server.itemHandler.ItemList[i] != null) {
  271. if (Server.itemHandler.ItemList[i].itemId == ItemID) {
  272. ShopValue = Server.itemHandler.ItemList[i].ShopValue;
  273. }
  274. }
  275. }
  276.  
  277. TotPrice = ShopValue;
  278.  
  279.  
  280. if (Server.shopHandler.ShopBModifier[c.myShopId] == 1) {
  281. TotPrice *= 1;
  282. TotPrice *= 1;
  283. if (Type == 1) {
  284. TotPrice *= 1;
  285. }
  286. } else if (Type == 1) {
  287. TotPrice *= 1;
  288. }
  289. return TotPrice;
  290. }
  291.  
  292. public int getItemShopValue(int itemId) {
  293. for (int i = 0; i < Config.ITEM_LIMIT; i++) {
  294. if (Server.itemHandler.ItemList[i] != null) {
  295. if (Server.itemHandler.ItemList[i].itemId == itemId) {
  296. return (int)Server.itemHandler.ItemList[i].ShopValue;
  297. }
  298. }
  299. }
  300. return 0;
  301. }
  302.  
  303.  
  304.  
  305. /**
  306. *buy item from shop (Shop Price)
  307. **/
  308.  
  309. public void buyFromShopPrice(int removeId, int removeSlot){
  310. if (c.myShopId == 7390 && c.myShopClient != null
  311. && !c.myShopClient.playerName.equals(c.playerName)) {
  312. int value = c.myShopClient.playerShopP[removeSlot];
  313. String add = "";
  314. if (value >= 1000 && value < 1000000) {
  315. add = " (" + (value / 1000) + "K)";
  316. } else if (value >= 1000000) {
  317. add = " (" + (value / 1000000) + " million)";
  318. }
  319. c.sendMessage(c.getItems().getItemName(removeId)
  320. + ": currently costs " + value + " coins." + add);
  321. return;
  322. } else if (c.myShopId == 7390 && c.myShopClient != null
  323. && c.myShopClient.playerName.equals(c.playerName)) {
  324. c.sendMessage(c.getItems().getItemName(removeId)
  325. + ": currently costs " + c.playerShopP[removeSlot]
  326. + " coins.");
  327. return;
  328. }
  329. int ShopValue = (int)Math.floor(getItemShopValue(removeId, 0, removeSlot));
  330. ShopValue *= 1;
  331. String ShopAdd = "";
  332. if (c.myShopId == 18 || c.myShopId == 29 || c.myShopId == 38 || c.myShopId == 34)
  333. {
  334. c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " Pk Points.");
  335. return;
  336. }
  337. if (c.myShopId == 15) {
  338. c.sendMessage("This item current costs " + c.getItems().getUntradePrice(removeId) + " coins.");
  339. return;
  340. }
  341. if (c.myShopId == 7) {
  342. c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " Dragon points.");
  343. return;
  344. }
  345. if (c.myShopId == 30) {
  346. c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " Slayer points.");
  347. return;
  348. }
  349. if (c.myShopId == 48) {
  350. c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " Slayer points.");
  351. return;
  352. }
  353.  
  354.  
  355. int RVK = (int)(((ShopValue) + (0.5 * 1000)) / 1000);
  356. int RVM = (int)(((ShopValue) + (0.5 * 1000000)) / 1000000);
  357. if (ShopValue >= 1000 && ShopValue < 1000000) {
  358. ShopAdd = " (" + RVK + "K)";
  359. } else if (ShopValue >= 1000000) {
  360. ShopAdd = " (" + RVM + "M)";
  361. }
  362. c.sendMessage(c.getItems().getItemName(removeId)+": currently costs "+ShopValue+" coins"+ShopAdd);
  363. }
  364.  
  365. public int getSpecialItemValue(int id) {
  366. switch (id) {
  367. case 15017:
  368. return 75;
  369. case 537:
  370. return 2;
  371. case 6733:
  372. return 30;
  373. case 6737:
  374. return 30;
  375. case 6731:
  376. return 30;
  377. case 18353:
  378. return 120;
  379. case 18349:
  380. return 120;
  381. case 18351:
  382. return 120;
  383. case 18355:
  384. return 120;
  385. case 18357:
  386. return 120;
  387.  
  388. case 15243:
  389. return 2;
  390.  
  391.  
  392.  
  393. ///slay helm stuff
  394.  
  395. case 4164:
  396. case 4166:
  397. case 4168:
  398. case 4551:
  399. return 10;
  400.  
  401. case 15488:
  402. case 15490:
  403. case 8921:
  404. return 100;
  405.  
  406. case 13736:
  407. case 13738:
  408. case 13740:
  409. case 13742:
  410. case 13744:
  411. return 100;
  412.  
  413.  
  414. case 10828:
  415. return 15;
  416. case 20072:
  417. return 10;
  418. case 15441:
  419. return 15;
  420. case 15442:
  421. return 15;
  422. case 15443:
  423. return 15;
  424. case 15444:
  425. return 15;
  426. case 11284:
  427. return 40;
  428. case 14484:
  429. case 19780:
  430. return 200;
  431. case 6920:
  432. return 20;
  433. case 11732:
  434. return 10;
  435. case 13890:
  436. return 100;
  437. case 13870:
  438. case 13876:
  439. return 100;
  440. case 13873:
  441. return 100;
  442. case 13899:
  443. return 100;
  444. case 1419:
  445. return 500;
  446. case 1961:
  447. return 200;
  448. case 15332:
  449. return 1;
  450. case 19272:
  451. case 19275:
  452. case 19278:
  453. case 13107:
  454. case 13109:
  455. case 13111:
  456. case 13113:
  457. case 13115:
  458. case 13858:
  459. case 13861:
  460. case 13864:
  461. case 13896:
  462. case 13884:
  463. case 13887:
  464. case 13893:
  465. case 13905:
  466. case 13867:
  467. return 100;
  468. case 13883:
  469. case 13879:
  470. return 2;
  471. case 19281:
  472. return 1000;
  473. case 19284:
  474. return 2000;
  475. case 19287:
  476. return 3000;
  477. case 19290:
  478. return 4000;
  479. case 19293:
  480. return 10000;
  481. case 19296:
  482. return 5000;
  483. case 19299:
  484. return 6000;
  485. case 19302:
  486. return 7000;
  487. case 19305:
  488. return 8000;
  489. case 10499:
  490. return 20;
  491. case 8845:
  492. return 5;
  493. case 8847:
  494. return 15;
  495. case 8848:
  496. return 20;
  497. case 8849:
  498. case 8850:
  499. return 25;
  500. case 10531:
  501. case 10533:
  502. case 10534:
  503. case 10537:
  504. return 50;
  505. case 11694:
  506. return 80;
  507. case 6585:
  508. return 10;
  509. case 15051:
  510. return 300;
  511. case 11235:
  512. return 50;
  513. case 4151:
  514. return 30;
  515. case 15039:
  516. return 1000;
  517. case 7462:
  518. return 10;
  519. case 15241:
  520. return 200;
  521. case 15272:
  522. return 10;
  523. case 2528:
  524. return 250;
  525.  
  526. //Donator Sets
  527. //Guthix
  528. case 11926:
  529. return 0;
  530. case 11932:
  531. return 0;
  532. //Zammy
  533. case 11930:
  534. return 0;
  535. case 11936:
  536. return 0;
  537. //Sara
  538. case 11928:
  539. return 0;
  540. case 11934:
  541. return 0;
  542. //Aditional Items
  543. //Chest key
  544. case 432:
  545. return 350;
  546. case 1044:
  547. return 175;
  548. case 1042:
  549. return 250;
  550. case 1040:
  551. return 175;
  552. case 1038:
  553. return 200;
  554. case 1046:
  555. return 150;
  556. case 1048:
  557. return 200;
  558. case 1050:
  559. return 225;
  560. case 1053:
  561. return 150;
  562. case 1055:
  563. return 175;
  564. case 1057:
  565. return 200;
  566. case 10547:
  567. case 10548:
  568. case 10549:
  569. case 10550:
  570. case 10551:
  571. case 10555:
  572. return 10;
  573. case 11664:
  574. return 20;
  575. case 11663:
  576. return 20;
  577. case 11665:
  578. return 20;
  579. case 8842:
  580. return 20;
  581. case 8840:
  582. case 8839:
  583. return 40;
  584. case 6570:
  585. return 10;
  586. case 11696:
  587. return 80;
  588. case 11698:
  589. return 80;
  590. case 11700:
  591. return 80;
  592. case 11730:
  593. return 100;
  594. case 15001:
  595. return 160;
  596. case 11720:
  597. return 60;
  598. case 6199:
  599. return 100;
  600. case 4671:
  601. return 250;
  602. case 3062:
  603. return 150;
  604. case 11722:
  605. return 60;
  606. case 11718:
  607. return 60;
  608. case 12680:
  609. return 10;
  610. case 11726:
  611. return 60;
  612. case 11724:
  613. case 11728:
  614. return 60;
  615. case 13902:
  616. return 100;
  617. case 11283:
  618. return 120;
  619. case 15018:
  620. case 15019:
  621. case 15020:
  622. return 10;
  623. case 6914:
  624. case 6989:
  625. case 6924:
  626. case 6922:
  627. case 6918:
  628. case 6916:
  629. case 6889:
  630. return 250;
  631. //torva etc
  632. case 13362:
  633. return 200;
  634. case 13360:
  635. return 200;
  636. case 13358:
  637. return 200;
  638. case 13355:
  639. return 150;
  640. case 13354:
  641. return 150;
  642. case 13352:
  643. return 150;
  644. case 13350:
  645. return 150;
  646. case 13348:
  647. return 150;
  648. case 13346:
  649. return 150;
  650. case 962:
  651. return 250;
  652. case 1959:
  653. return 45;
  654. case 981:
  655. return 150;
  656. case 1037:
  657. return 350;
  658. case 19335:
  659. return 30;
  660. case 15220:
  661. return 10;
  662. case 12674:
  663. return 30;
  664. case 15492:
  665. return 50;
  666. //Primal
  667. case 16293:
  668. return 30;
  669. case 16359:
  670. return 30;
  671. case 16711:
  672. return 70;
  673. case 17259:
  674. return 80;
  675. case 16733:
  676. return 75;
  677. case 16667:
  678. return 70;
  679. case 16689:
  680. return 70;
  681. case 17361:
  682. return 75;
  683. case 16403:
  684. return 50;
  685. case 16425:
  686. return 70;
  687. case 15773:
  688. return 60;
  689. case 16909:
  690. return 60;
  691. case 16955:
  692. return 60;
  693. case 20075: //Rainbow phat
  694. return 350;
  695. case 18359:
  696. return 120;
  697. case 19748:
  698. return 25;
  699. case 11846:
  700. return 35;
  701. case 11848:
  702. return 35;
  703. case 15328:
  704. return 2;
  705. case 10925:
  706. return 1;
  707. case 18361:
  708. return 50;
  709. case 18363:
  710. return 50;
  711.  
  712. }
  713. return 0;
  714.  
  715. }
  716.  
  717.  
  718.  
  719. /**
  720. *Sell item to shop (Shop Price)
  721. **/
  722. public void sellToShopPrice(int removeId, int removeSlot) {
  723. if (c.myShopId == 7390) {
  724. c.sendMessage("You choose your price when using POS.");
  725. return;
  726. }
  727. for (int i : Config.ITEM_SELLABLE) {
  728.  
  729. if(c.myShopId == 38) {
  730. c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+" to this store.");
  731. return;
  732. }
  733. if(c.myShopId == 7 || c.myShopId == 29 || c.myShopId == 34 || c.myShopId == 30) {
  734. c.sendMessage("You can't sell to this store.");
  735. return;
  736. }
  737. if (i == removeId) {
  738. c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+".");
  739. return;
  740. }
  741. }
  742. /*if(c.isDonator == 0) {
  743. for (int i : Config.ITEM_DONATOR) {
  744. if (i == removeId || i+1 == removeId) {
  745. c.sendMessage("You can't sell a "+c.getItems().getItemName(removeId).toLowerCase()+" unless you are a donator.");
  746. return;
  747. }
  748.  
  749. }
  750. }*/
  751.  
  752. boolean IsIn = false;
  753. if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
  754. for (int j = 0; j <= Server.shopHandler.ShopItemsStandard[c.myShopId]; j++) {
  755. if (removeId == (Server.shopHandler.ShopItems[c.myShopId][j] - 1)) {
  756. IsIn = true;
  757. break;
  758. }
  759. }
  760. } else {
  761. IsIn = true;
  762. }
  763. if (Server.playerHandler.getCantSell() == true || IsIn == false) {
  764. c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+" to this store.");
  765. } else {
  766. int ShopValue = (int)Math.floor(getItemShopValue(removeId, 1, removeSlot));
  767. String ShopAdd = "";
  768. if (ShopValue >= 1000 && ShopValue < 1000000) {
  769. ShopAdd = " (" + (ShopValue / 1000) + "K)";
  770. } else if (ShopValue >= 1000000) {
  771. ShopAdd = " (" + (ShopValue / 1000000) + " million)";
  772. }
  773. if (c.myShopId == 2229 || c.myShopId == 3334)
  774. c.sendMessage(c.getItems().getItemName(removeId)+": shop will buy for "+getSpecialItemValue(removeId)+" Pk Points.");
  775. else
  776. c.sendMessage(c.getItems().getItemName(removeId)+": shop will buy for "+ShopValue+" coins"+ShopAdd);
  777. }
  778. }
  779.  
  780.  
  781.  
  782. public boolean sellItem(int itemID, int fromSlot, int amount) {
  783. if (c.myShopId == 7390) {
  784. for (int i : Config.ITEM_TRADEABLE) {
  785. if (i == itemID) {
  786. c.sendMessage("You can't sell this item.");
  787. return false;
  788. }
  789. }
  790. if (c.playerName.equals(c.myShopClient.playerName)) {
  791. c.sellingId = itemID;
  792. c.sellingN = amount;
  793. c.sellingS = fromSlot;
  794. c.xInterfaceId = 7390;
  795. c.outStream.createFrame(27);
  796. } else {
  797. c.sendMessage("You can only sell items on your own store.");
  798. }
  799. return true;
  800. }
  801. if(c.inTrade) {
  802. c.sendMessage("You cant sell items to the shop while your in trade!");
  803. return false;
  804. }
  805. if (c.myShopId == 7 || c.myShopId == 29 || c.myShopId == 34 || c.myShopId == 30) {
  806. return false;
  807. }
  808. if (c.myShopId == 38){
  809. c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+" to this store.");
  810. return false;
  811. }
  812. if (c.myShopId == 14)
  813. return false;
  814. for (int i : Config.ITEM_SELLABLE) {
  815. if (i == itemID) {
  816. c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+".");
  817. return false;
  818. }
  819. }
  820. /*if(c.isDonator == 0) {
  821. for (int i : Config.ITEM_DONATOR) {
  822. if (i == itemID || i+1 == itemID) {
  823. c.sendMessage("You can't sell a "+c.getItems().getItemName(itemID).toLowerCase()+".");
  824. return false;
  825. }
  826. }
  827. }*/
  828.  
  829. if (amount > 0 && itemID == (c.playerItems[fromSlot] - 1)) {
  830. if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
  831. boolean IsIn = false;
  832. for (int i = 0; i <= Server.shopHandler.ShopItemsStandard[c.myShopId]; i++) {
  833. if (itemID == (Server.shopHandler.ShopItems[c.myShopId][i] - 1)) {
  834. IsIn = true;
  835. break;
  836. }
  837. }
  838. if (IsIn == false) {
  839. c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+" to this store.");
  840. return false;
  841. }
  842. }
  843.  
  844. if (amount > c.playerItemsN[fromSlot] && (Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == true || Item.itemStackable[(c.playerItems[fromSlot] - 1)] == true)) {
  845. amount = c.playerItemsN[fromSlot];
  846. } else if (amount > c.getItems().getItemAmount(itemID) && Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == false && Item.itemStackable[(c.playerItems[fromSlot] - 1)] == false) {
  847. amount = c.getItems().getItemAmount(itemID);
  848. }
  849. //double ShopValue;
  850. //double TotPrice;
  851. int TotPrice2 = 0;
  852. //int Overstock;
  853. for (int i = amount; i > 0; i--) {
  854. TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 1, fromSlot));
  855. if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995) || c.myShopId == 29 || c.myShopId == 34 || c.myShopId == 7 || c.myShopId == 30) {
  856. if (Item.itemIsNote[itemID] == false) {
  857. c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
  858. } else {
  859. c.getItems().deleteItem(itemID, fromSlot, 1);
  860. }
  861. if (c.myShopId == 29 || c.myShopId == 34) {
  862. c.ZPoints += getSpecialItemValue(itemID);
  863. c.getPA().sendFrame126("Pk Points Shop - You have " + c.getZPoints() + " Pk Points", 3901);
  864. c.getPA().sendFrame126("@whi@PK Points: @gre@"+c.getZPoints(), 29168);
  865. }
  866. if (c.myShopId == 30) {
  867. c.slayerPoints += getSpecialItemValue(itemID);
  868. c.getPA().sendFrame126("Slayer Points Shop - You have " + c.getslayerPoints() + " Slayer Points", 3901);
  869. c.getPA().sendFrame126("@whi@Slayer Streak: @gre@"+c.getSlayerStreak(), 29166);
  870. }
  871. if (c.myShopId == 7) {
  872. c.dragonPoints += getSpecialItemValue(itemID);
  873. c.getPA().sendFrame126("Dragon Point Shop - You have " + c.getdragonPoints() + " Dragon Points", 3901);
  874. c.getPA().sendFrame126("@whi@Dragon Points: @gre@"+c.getdragonPoints(), 29167);
  875. } else {
  876. c.getItems().addItem(995, TotPrice2);
  877. if(c.myShopId != 1)
  878. addShopItem(itemID, 1);
  879. }
  880. } else {
  881. c.sendMessage("You don't have enough space in your inventory.");
  882. break;
  883. }
  884. }
  885. c.getItems().resetItems(3823);
  886. resetShop(c.myShopId);
  887. updatePlayerShop();
  888. return true;
  889. }
  890. return true;
  891. }
  892.  
  893. public boolean addShopItem(int itemID, int amount) {
  894. boolean Added = false;
  895. if (amount <= 0) {
  896. return false;
  897. }
  898. if (Item.itemIsNote[itemID] == true) {
  899. itemID = c.getItems().getUnnotedItem(itemID);
  900. }
  901. for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  902. if ((Server.shopHandler.ShopItems[c.myShopId][i] - 1) == itemID) {
  903. //Server.shopHandler.ShopItemsN[c.myShopId][i] += amount;DISABLED FOR UNLIMITED STOCKS
  904. Added = true;
  905. }
  906. }
  907. if (Added == false) {
  908. for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
  909. if (Server.shopHandler.ShopItems[c.myShopId][i] == 0) {
  910. Server.shopHandler.ShopItems[c.myShopId][i] = (itemID + 1);
  911. //Server.shopHandler.ShopItemsN[c.myShopId][i] = amount;DISABLED FOR UNLIMITED STOCKS
  912. Server.shopHandler.ShopItemsDelay[c.myShopId][i] = 0;
  913. break;
  914. }
  915. }
  916. }
  917. return true;
  918. }
  919.  
  920. public long buyDelay;
  921. public boolean buyItem(int itemID, int fromSlot, int amount) {
  922. if (c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && !c.playerName.equals(c.myShopClient.playerName)) {
  923. if (c.myShopClient.playerShop[fromSlot] != itemID)
  924. return false;
  925. int bought = 0;
  926. int price = c.myShopClient.playerShopP[fromSlot];
  927. if (amount > c.myShopClient.playerShopN[fromSlot])
  928. amount = c.myShopClient.playerShopN[fromSlot];
  929. for (int x = 0; x < amount; x++) {
  930. if (c.getItems().playerHasItem(995,
  931. c.myShopClient.playerShopP[fromSlot])
  932. && c.getItems().freeSlots() > 0) {
  933. c.getItems().deleteItem2(995,
  934. c.myShopClient.playerShopP[fromSlot]);
  935. c.getItems()
  936. .addItem(c.myShopClient.playerShop[fromSlot], 1);
  937. c.myShopClient.playerShopN[fromSlot]--;
  938. c.myShopClient.playerCollect += c.myShopClient.playerShopP[fromSlot];
  939. if (c.myShopClient.playerShopN[fromSlot] == 0) {
  940. c.myShopClient.playerShop[fromSlot] = 0;
  941. c.myShopClient.playerShopP[fromSlot] = 0;
  942. }
  943. bought++;
  944. } else {
  945. c.sendMessage("Not enough space or money.");
  946. break;
  947. }
  948. }
  949. if (bought > 0) {
  950. resetShop(c.myShopClient);
  951. c.getItems().resetItems(3823);
  952. ;
  953. c.sendMessage("You just bought " + bought + " "
  954. + c.getItems().getItemName(itemID) + " for "
  955. + (bought * price));
  956. c.myShopClient.sendMessage(c.playerName + " has bought "
  957. + bought + " " + c.getItems().getItemName(itemID)
  958. + " from you!");
  959. c.myShopClient.sendMessage("You now have "
  960. + c.myShopClient.playerCollect
  961. + " coins to collect (::collect)");
  962. fixShop(c.myShopClient);
  963. updatePlayerShop();
  964. resetShop(c.myShopClient);
  965. updatePlayerOwnedShop(c.myShopClient);
  966. // c.myShopClient.complete(5);
  967. // c.complete(6);
  968. }
  969. return false;
  970. } else if (c.myShopId == 7390 && c.myShopClient != null && !c.myShopClient.properLogout && c.playerName.equals(c.myShopClient.playerName)) {
  971. if (amount > c.myShopClient.playerShopN[fromSlot])
  972. amount = c.myShopClient.playerShopN[fromSlot];
  973. for (int x = 0; x < amount; x++) {
  974. if (c.getItems().freeSlots() > 0) {
  975. c.getItems()
  976. .addItem(c.myShopClient.playerShop[fromSlot], 1);
  977. c.myShopClient.playerShopN[fromSlot]--;
  978. if (c.myShopClient.playerShopN[fromSlot] == 0) {
  979. c.myShopClient.playerShop[fromSlot] = 0;
  980. c.myShopClient.playerShopP[fromSlot] = 0;
  981. fixShop(c);
  982. updatePlayerShop();
  983. resetShop(c.myShopClient);
  984. updatePlayerOwnedShop(c.myShopClient);
  985.  
  986. }
  987. } else {
  988. c.sendMessage("Not enought space.");
  989. break;
  990. }
  991. }
  992. resetShop(c.myShopClient);
  993. updatePlayerOwnedShop(c.myShopClient);
  994. c.getItems().resetItems(3823);
  995. return false;
  996. } else if (c.myShopId == 7390) {
  997. return false;
  998. }
  999. if(System.currentTimeMillis() - buyDelay < 1500) {
  1000. return false;
  1001. }
  1002.  
  1003. if (c.myShopId == 14) {
  1004. skillBuy(itemID);
  1005. return false;
  1006.  
  1007. } else if (c.myShopId == 15) {
  1008. buyVoid(itemID);
  1009. return false;
  1010.  
  1011. } /*else if (c.myShopId == 1) {
  1012. buyVoid(itemID);
  1013. return false;
  1014. }*/
  1015. if (!shopSellsItem(itemID))
  1016. return false;
  1017. if(itemID != itemID) {
  1018. c.sendMessage("Don't dupe or you will be IP Banned");
  1019. return false;
  1020. }
  1021.  
  1022.  
  1023. if (amount > 0) {
  1024. /*if (amount > Server.shopHandler.ShopItemsN[c.myShopId][fromSlot]) {
  1025. amount = Server.shopHandler.ShopItemsN[c.myShopId][fromSlot];
  1026. } DISABLED FOR UNLIMITED STOCKS */
  1027.  
  1028. //double ShopValue;
  1029. //double TotPrice;
  1030. int TotPrice2 = 0;
  1031. //int Overstock;
  1032. int Slot = 0;
  1033. int Slot1 = 0;//Tokkul
  1034. int Slot2 = 0;//Pking Points
  1035. int Slot3 = 0;//Donator Gold
  1036.  
  1037. if (c.myShopId == 18) {
  1038. handleOtherShop(itemID);
  1039. return false;
  1040. }
  1041. if (c.myShopId == 73) {
  1042. handleOtherShop(itemID);
  1043. return false;
  1044. }
  1045. if (c.myShopId == 7) {
  1046. handleOtherShop(itemID);
  1047. return true;
  1048. }
  1049. if (c.myShopId == 30) {
  1050. handleOtherShop(itemID);
  1051. return true;
  1052. }
  1053. if (c.myShopId == 29 || c.myShopId == 34 || c.myShopId == 38)
  1054. {
  1055. handleOtherShop(itemID);
  1056. return false;
  1057. }
  1058.  
  1059.  
  1060. for (int i = amount; i > 0; i--) {
  1061. TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot));
  1062. Slot = c.getItems().getItemSlot(995);
  1063. Slot1 = c.getItems().getItemSlot(6529);
  1064. Slot3 = c.getItems().getItemSlot(5555);
  1065. if (Slot == -1 && c.myShopId != 11 && c.myShopId != 29 && c.myShopId != 34 && c.myShopId != 38 && c.myShopId != 30 && c.myShopId != 47)
  1066. {
  1067. c.sendMessage("You don't have enough coins.");
  1068. break;
  1069. }
  1070. if(c.myShopId == 30) {
  1071. c.sendMessage("You don't have enough slayer Points.");
  1072. break;
  1073. }
  1074. if(Slot3 == -1 && c.myShopId == 11) {
  1075. c.sendMessage("You don't have enough donator gold.");
  1076. break;
  1077. }
  1078.  
  1079. if(TotPrice2 <= 1) {
  1080. TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot));
  1081. TotPrice2 *= 1.66;
  1082. }
  1083. if (c.myShopId == 29 || c.myShopId == 34 || c.myShopId == 38)
  1084. {
  1085. if (c.playerItemsN[Slot1] >= TotPrice2) {
  1086. if (c.getItems().freeSlots() > 0) {
  1087. buyDelay = System.currentTimeMillis();
  1088. c.getItems().deleteItem(6529, c.getItems().getItemSlot(6529), TotPrice2);
  1089. c.getItems().addItem(itemID, 1);
  1090. //Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;DISABLED FOR UNLIMITED STOCKS
  1091. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1092. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1093. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1094. }
  1095. } else {
  1096. c.sendMessage("You don't have enough space in your inventory.");
  1097. break;
  1098. }
  1099. } else {
  1100. c.sendMessage("You don't have enough tokkul.");
  1101. break;
  1102. }
  1103. }
  1104. else if(c.myShopId == 7) {
  1105. if (c.dragonPoints >= TotPrice2) {
  1106. if (c.getItems().freeSlots() > 0) {
  1107. c.dragonPoints -= TotPrice2;
  1108. c.getItems().addItem(itemID, 1);
  1109. Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  1110. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1111. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1112. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1113. }
  1114. } else {
  1115. c.sendMessage("You don't have enough space in your inventory.");
  1116. break;
  1117. }
  1118. } else {
  1119. c.sendMessage("You don't have enough Dragon Points.");
  1120. break;
  1121. }
  1122. }
  1123. else if(c.myShopId == 30) {
  1124. if (c.slayerPoints >= TotPrice2) {
  1125. if (c.getItems().freeSlots() > 0) {
  1126. c.slayerPoints -= TotPrice2;
  1127. c.getItems().addItem(itemID, 1);
  1128. Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  1129. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1130. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1131. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1132. }
  1133. } else {
  1134. c.sendMessage("You don't have enough space in your inventory.");
  1135. break;
  1136. }
  1137. } else {
  1138. c.sendMessage("You don't have enough Slayer Points.");
  1139. break;
  1140. }
  1141. }
  1142. else if(c.myShopId == 47) {
  1143. /*
  1144. if (c.pkPoints >= TotPrice2) {
  1145. if (c.getItems().freeSlots() > 0) {
  1146. buyDelay = System.currentTimeMillis();
  1147. c.pkPoints -= TotPrice2;
  1148. c.getItems().addItem(itemID, 1);
  1149. Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
  1150. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1151. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1152. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1153. }
  1154. } else {
  1155. c.sendMessage("You don't have enough space in your inventory.");
  1156. break;
  1157. }
  1158. } else {
  1159. c.sendMessage("You don't have enough Pk Points.");
  1160. break;
  1161. }
  1162. */
  1163. }
  1164. else if(c.myShopId == 48) {
  1165. if (c.magePoints >= TotPrice2) {
  1166. if (c.getItems().freeSlots() > 0) {
  1167. buyDelay = System.currentTimeMillis();
  1168. c.magePoints -= TotPrice2;
  1169. c.getItems().addItem(itemID, 1);
  1170. //Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;DISABLED FOR UNLIMITED STOCKS
  1171. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1172. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1173. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1174. }
  1175. } else {
  1176. c.sendMessage("You don't have enough space in your inventory.");
  1177. break;
  1178. }
  1179. } else {
  1180. c.sendMessage("You don't have enough slayer points.");
  1181. break;
  1182. }
  1183. }
  1184. else if(c.myShopId == 11) {
  1185. if (c.playerItemsN[Slot3] >= TotPrice2) {
  1186. if (c.getItems().freeSlots() > 0) {
  1187. buyDelay = System.currentTimeMillis();
  1188. c.getItems().deleteItem(5555, c.getItems().getItemSlot(5555), TotPrice2);
  1189. c.getItems().addItem(itemID, 1);
  1190. //Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;DISABLED FOR UNLIMITED STOCKS
  1191. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1192. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1193. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1194. }
  1195. } else {
  1196. c.sendMessage("You don't have enough space in your inventory.");
  1197. break;
  1198. }
  1199. } else {
  1200. c.sendMessage("You don't have enough donator gold.");
  1201. break;
  1202. }
  1203. }
  1204. else if(c.myShopId != 11 && c.myShopId != 29 && c.myShopId != 34 || c.myShopId != 38 || c.myShopId != 30 || c.myShopId != 47) {
  1205. if (c.playerItemsN[Slot] >= TotPrice2) {
  1206. if (c.getItems().freeSlots() > 0) {
  1207. buyDelay = System.currentTimeMillis();
  1208. c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
  1209. c.getItems().addItem(itemID, 1);
  1210. //Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;DISABLED FOR UNLIMITED STOCKS
  1211. Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
  1212. if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
  1213. Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
  1214. }
  1215. } else {
  1216. c.sendMessage("You don't have enough space in your inventory.");
  1217. break;
  1218. }
  1219. } else {
  1220. c.sendMessage("You don't have enough coins.");
  1221. break;
  1222. }
  1223. }
  1224. }
  1225. c.getItems().resetItems(3823);
  1226. resetShop(c.myShopId);
  1227. return true;
  1228. }
  1229. return false;
  1230. }
  1231. public boolean CheckDonor(int item)
  1232. {
  1233. if ((c.isDonator != 4 && c.isDonator != 1) && item == 11926)
  1234. {
  1235. c.sendMessage("You are not a Guthix Donator!");
  1236. }
  1237. else if ((c.isDonator != 4 && c.isDonator != 2) && item == 11930)
  1238. {
  1239. c.sendMessage("You are not a Zamorak Donator!");
  1240. }
  1241. else if ((c.isDonator != 4 && c.isDonator != 3) && item == 11928)
  1242. {
  1243. c.sendMessage("You are not a Saradomin Donator!");
  1244. }
  1245. else
  1246. {
  1247. return true;
  1248. }
  1249. return false;
  1250. }
  1251.  
  1252. public void handleOtherShop(int itemID) {
  1253.  
  1254. if (c.myShopId == 18) {
  1255. if (c.Commendations >= getSpecialItemValue(itemID)) {
  1256. if (c.getItems().freeSlots() > 0){
  1257. c.Commendations -= getSpecialItemValue(itemID);
  1258. c.getItems().addItem(itemID,1);
  1259. c.getItems().resetItems(3823);
  1260. }
  1261. } else {
  1262. c.sendMessage("You do not have enough PC points to buy this item.");
  1263. }
  1264. } else if (c.myShopId == 7){
  1265. if (c.getdragonPoints() >= getSpecialItemValue(itemID))
  1266. {
  1267. if (c.getItems().freeSlots() > 0){
  1268. c.dragonPoints -= getSpecialItemValue(itemID);
  1269. c.getItems().addItem(itemID, 1);
  1270. c.getItems().resetItems(3823);
  1271. c.getPA().sendFrame126("Dragon Point Shop - You have " + c.getdragonPoints() + " Dragon Points", 3901);
  1272. c.getPA().sendFrame126("@whi@Dragon Points: @gre@"+c.getdragonPoints(), 29167);
  1273. }
  1274. } else {
  1275. c.sendMessage("You do not have enough Dragon Points to buy this item.");
  1276. }
  1277. } else if (c.myShopId == 30){
  1278. if (c.getslayerPoints() >= getSpecialItemValue(itemID))
  1279. {
  1280. if (c.getItems().freeSlots() > 0){
  1281. c.slayerPoints -= getSpecialItemValue(itemID);
  1282. c.getItems().addItem(itemID, 1);
  1283. c.getItems().resetItems(3823);
  1284. c.getPA().sendFrame126("Slayer Points Shop - You have " + c.getslayerPoints() + " Slayer Points", 3901);
  1285. c.getPA().sendFrame126("@whi@Slayer Points: @gre@"+c.getSlayerPoints(), 29165);
  1286. }
  1287. } else {
  1288. c.sendMessage("You do not have enough Slayer Points to buy this item.");
  1289. }
  1290. } else if (c.myShopId == 38){
  1291. if (c.getVotePoints() >= getSpecialItemValue(itemID))
  1292. {
  1293. if (c.getItems().freeSlots() > 0){
  1294. c.votePoints -= getSpecialItemValue(itemID);
  1295. c.getItems().addItem(itemID, 1);
  1296. c.getItems().resetItems(3823);
  1297. c.getPA().sendFrame126("Voting Shop - You have " + c.getVotePoints() + " Voting Points", 3901);
  1298. c.getPA().sendFrame126("@or2@Voting Points - @yel@" + c.getVotePoints(), 29171); ;
  1299. }
  1300. } else {
  1301. c.sendMessage("You do not have enough Voting points to buy this item.");
  1302. }
  1303. } else if (c.myShopId == 29 || c.myShopId == 34) {
  1304. if (c.isDonator >= 0)
  1305. {
  1306. if (c.getZPoints() >= getSpecialItemValue(itemID))
  1307. {
  1308. if (c.getItems().freeSlots() > 0)
  1309. {
  1310. if (CheckDonor(itemID))
  1311. {
  1312. c.ZPoints -= getSpecialItemValue(itemID);
  1313. c.getItems().addItem(itemID, 1);
  1314. c.getItems().resetItems(3823);
  1315. c.getPA().sendFrame126("Pk Points Shop - You have " + c.getZPoints() + " Pk Points", 3901);
  1316. c.getPA().sendFrame126("@whi@PK Points: @gre@"+c.getZPoints(), 29168);
  1317. }
  1318. }
  1319. }
  1320. else
  1321. {
  1322. c.sendMessage("You do not have enough Pk Points to buy this item.");
  1323. }
  1324. }
  1325. else
  1326. {
  1327. c.sendMessage("You must be a donator to buy this item.");
  1328. }
  1329.  
  1330. }
  1331. if (c.myShopId == 73) {
  1332. /*
  1333. if (c.pkPoints >= getSpecialItemValue(itemID)) {
  1334. if (c.getItems().freeSlots() > 0){
  1335. c.pkPoints -= getSpecialItemValue(itemID);
  1336. c.getItems().addItem(itemID,1);
  1337. c.getItems().resetItems(3823);
  1338. }
  1339. } else {
  1340. c.sendMessage("You do not have enough PK points to buy this item.");
  1341. }
  1342. */
  1343.  
  1344. }
  1345. if (c.myShopId == 74) {
  1346. /*
  1347. if (c.pkPoints >= getSpecialItemValue(itemID)) {
  1348. if (c.getItems().freeSlots() > 0){
  1349. c.pkPoints -= getSpecialItemValue(itemID);
  1350. c.getItems().addItem(itemID,1);
  1351. c.getItems().resetItems(3823);
  1352. }
  1353. } else {
  1354. c.sendMessage("You do not have enough PK points to buy this item.");
  1355. }
  1356. */
  1357. }
  1358. if (c.myShopId == 48) {
  1359. if (c.magePoints >= getSpecialItemValue(itemID)) {
  1360. if (c.getItems().freeSlots() > 0){
  1361. c.magePoints -= getSpecialItemValue(itemID);
  1362. c.getItems().addItem(itemID,1);
  1363. c.getItems().resetItems(3823);
  1364. }
  1365. } else {
  1366. c.sendMessage("You do not have enough Slayer points to buy this item.");
  1367. }
  1368.  
  1369. }
  1370. }
  1371.  
  1372. public void openSkillCape() {
  1373. int capes = get99Count();
  1374. if (capes > 1)
  1375. capes = 1;
  1376. else
  1377. capes = 0;
  1378. c.myShopId = 14;
  1379. setupSkillCapes(capes, get99Count());
  1380. }
  1381.  
  1382.  
  1383.  
  1384. /*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},
  1385. {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},
  1386. {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}};*/
  1387. public int[] skillCapes = {9747,9753,9750,9768,9756,9759,9762,9801,9807,9783,9798,9804,9780,9795,9792,9774,9771,9777,9786,9810,9765,9948,12169,12524};
  1388. public int get99Count() {
  1389. int count = 0;
  1390. for (int j = 0; j < c.playerLevel.length; j++) {
  1391. if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  1392. count++;
  1393. }
  1394. }
  1395. return count;
  1396. }
  1397.  
  1398. public void setupSkillCapes(int capes, int capes2) {
  1399. c.getItems().resetItems(3823);
  1400. c.isShopping = true;
  1401. c.myShopId = 14;
  1402. c.getPA().sendFrame248(3824, 3822);
  1403. c.getPA().sendFrame126("Skillcape Shop", 3901);
  1404.  
  1405. int TotalItems = 0;
  1406. TotalItems = capes2;
  1407. if (TotalItems > Server.shopHandler.MaxShopItems) {
  1408. TotalItems = Server.shopHandler.MaxShopItems;
  1409. }
  1410. c.getOutStream().createFrameVarSizeWord(53);
  1411. c.getOutStream().writeWord(3900);
  1412. c.getOutStream().writeWord(TotalItems);
  1413. int TotalCount = 0;
  1414. for (int i = 0; i < 24; i++) {
  1415. if (c.getLevelForXP(c.playerXP[i]) < 99)
  1416. continue;
  1417. c.getOutStream().writeByte(1);
  1418. if(i < 23)
  1419. c.getOutStream().writeWordBigEndianA(skillCapes[i] + 2);
  1420. else
  1421. c.getOutStream().writeWordBigEndianA(skillCapes[i] + 1);
  1422. TotalCount++;
  1423. }
  1424. c.getOutStream().endFrameVarSizeWord();
  1425. c.flushOutStream();
  1426. }
  1427.  
  1428. public void skillBuy(int item) {
  1429. int nn = get99Count();
  1430. if (nn > 1)
  1431. nn = 1;
  1432. else
  1433. nn = 0;
  1434. for (int j = 0; j < skillCapes.length; j++) {
  1435. if (skillCapes[j] == item || skillCapes[j]+1 == item) {
  1436. if (c.getItems().freeSlots() > 1) {
  1437. if (c.getItems().playerHasItem(995,99000)) {
  1438. if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  1439. c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
  1440. c.getItems().addItem(skillCapes[j] + nn,1);
  1441. c.getItems().addItem(skillCapes[j] + 2,1);
  1442. } else {
  1443. c.sendMessage("You must have 99 in the skill of the cape you're trying to buy.");
  1444. }
  1445. } else {
  1446. c.sendMessage("You need 99k to buy this item.");
  1447. }
  1448. } else {
  1449. c.sendMessage("You must have at least 1 inventory spaces to buy this item.");
  1450. }
  1451. }
  1452. /*if (skillCapes[j][1 + nn] == item) {
  1453. if (c.getItems().freeSlots() >= 1) {
  1454. if (c.getItems().playerHasItem(995,99000)) {
  1455. if (c.getLevelForXP(c.playerXP[j]) >= 99) {
  1456. c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
  1457. c.getItems().addItem(skillCapes[j] + nn,1);
  1458. c.getItems().addItem(skillCapes[j] + 2,1);
  1459. } else {
  1460. c.sendMessage("You must have 99 in the skill of the cape you're trying to buy.");
  1461. }
  1462. } else {
  1463. c.sendMessage("You need 99k to buy this item.");
  1464. }
  1465. } else {
  1466. c.sendMessage("You must have at least 1 inventory spaces to buy this item.");
  1467. }
  1468. break;
  1469. }*/
  1470. }
  1471. c.getItems().resetItems(3823);
  1472. }
  1473.  
  1474. public void openVoid() {
  1475. /*synchronized(c) {
  1476. c.getItems().resetItems(3823);
  1477. c.isShopping = true;
  1478. c.myShopId = 15;
  1479. c.getPA().sendFrame248(3824, 3822);
  1480. c.getPA().sendFrame126("Void Recovery", 3901);
  1481.  
  1482. int TotalItems = 5;
  1483. c.getOutStream().createFrameVarSizeWord(53);
  1484. c.getOutStream().writeWord(3900);
  1485. c.getOutStream().writeWord(TotalItems);
  1486. for (int i = 0; i < c.voidStatus.length; i++) {
  1487. c.getOutStream().writeByte(c.voidStatus[i]);
  1488. c.getOutStream().writeWordBigEndianA(2519 + i * 2);
  1489. }
  1490. c.getOutStream().endFrameVarSizeWord();
  1491. c.flushOutStream();
  1492. }*/
  1493. }
  1494.  
  1495. public void buyVoid(int item) {
  1496. /*if (item > 2527 || item < 2518)
  1497. return;
  1498. //c.sendMessage("" + item);
  1499. if (c.voidStatus[(item-2518)/2] > 0) {
  1500. if (c.getItems().freeSlots() >= 1) {
  1501. if (c.getItems().playerHasItem(995,c.getItems().getUntradePrice(item))) {
  1502. c.voidStatus[(item-2518)/2]--;
  1503. c.getItems().deleteItem(995,c.getItems().getItemSlot(995), c.getItems().getUntradePrice(item));
  1504. c.getItems().addItem(item,1);
  1505. openVoid();
  1506. } else {
  1507. c.sendMessage("This item costs " + c.getItems().getUntradePrice(item) + " coins to rebuy.");
  1508. }
  1509. } else {
  1510. c.sendMessage("I should have a free inventory space.");
  1511. }
  1512. } else {
  1513. c.sendMessage("I don't need to recover this item from the void knights.");
  1514. }*/
  1515. }
  1516.  
  1517.  
  1518. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement