Ejemplo n.º 1
0
  public void handleOtherShop(int itemID) {
    if (c.myShopId == 18) {
      if (c.pkPoints >= getSpecialItemValue(itemID)) {
        if (c.getItems().freeSlots() > 0) {
          c.pkPoints -= getSpecialItemValue(itemID);
          c.getItems().addItem(itemID, 1);
          c.getItems().resetItems(3823);
        }
      } else {
        c.sendMessage("You do not have enough EXL points to buy this item.");
      }
    }
    if (c.myShopId == 73) {
      if (c.pkPoints >= getSpecialItemValue(itemID)) {
        if (c.getItems().freeSlots() > 0) {
          c.pkPoints -= getSpecialItemValue(itemID);
          c.getItems().addItem(itemID, 1);
          c.getItems().resetItems(3823);
        }
      } else {
        c.sendMessage("You do not have enough EXL points to buy this item.");
      }
    }

    if (c.myShopId == 10) {
      if (c.donorPoints >= getSpecialItemValue(itemID)) {
        if (c.getItems().freeSlots() > 0) {
          c.donorPoints -= getSpecialItemValue(itemID);
          c.getItems().addItem(itemID, 1);
          c.getItems().resetItems(3823);
        }
      } else {
        c.sendMessage("You do not have enough Donator points to buy this item.");
      }
    }
    if (c.myShopId == 74) {
      if (c.pkPoints >= getSpecialItemValue(itemID)) {
        if (c.getItems().freeSlots() > 0) {
          c.pkPoints -= getSpecialItemValue(itemID);
          c.getItems().addItem(itemID, 1);
          c.getItems().resetItems(3823);
        }
      } else {
        c.sendMessage("You do not have enough EXL points to buy this item.");
      }
    }
    if (c.myShopId == 48) {
      if (c.SPoints >= getSpecialItemValue(itemID)) {
        if (c.getItems().freeSlots() > 0) {
          c.SPoints -= getSpecialItemValue(itemID);
          c.getItems().addItem(itemID, 1);
          c.getItems().resetItems(3823);
        }
      } else {
        c.sendMessage("You do not have enough Slayer Points to buy this item.");
      }
    }
  }
Ejemplo n.º 2
0
  public boolean buyItem(int itemID, int fromSlot, int amount) {
    if (c.myShopId == 7390
        && c.myShopClient != null
        && !c.myShopClient.properLogout
        && !c.playerName.equals(c.myShopClient.playerName)) {
      int bought = 0;
      int price = c.myShopClient.playerShopP[fromSlot];
      if (amount > c.myShopClient.playerShopN[fromSlot])
        amount = c.myShopClient.playerShopN[fromSlot];
      for (int x = 0; x < amount; x++) {
        if (c.getItems().playerHasItem(7478, c.myShopClient.playerShopP[fromSlot])
            && c.getItems().freeSlots() > 0) {
          c.getItems().deleteItem2(7478, c.myShopClient.playerShopP[fromSlot]);
          c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
          c.myShopClient.playerShopN[fromSlot]--;
          c.myShopClient.playerCollect += c.myShopClient.playerShopP[fromSlot];
          if (c.myShopClient.playerShopN[fromSlot] == 0) {
            c.myShopClient.playerShop[fromSlot] = 0;
            c.myShopClient.playerShopP[fromSlot] = 0;
          }
          bought++;
        } else {
          c.sendMessage("Not enought space or money.");
          break;
        }
      }
      if (bought > 0) {
        resetShop(c.myShopClient);
        c.getItems().resetItems(3823);
        ;
        c.sendMessage(
            "You just bought "
                + bought
                + " "
                + c.getItems().getItemName(itemID)
                + " for "
                + (bought * price));
        c.myShopClient.sendMessage(
            c.playerName
                + " has bought "
                + bought
                + " "
                + c.getItems().getItemName(itemID)
                + " from you!");
        c.myShopClient.sendMessage(
            "You now have " + c.myShopClient.playerCollect + " DT's to collect (::collect)");
      }
      return false;
    } else if (c.myShopId == 7390
        && c.myShopClient != null
        && !c.myShopClient.properLogout
        && c.playerName.equals(c.myShopClient.playerName)) {
      if (amount > c.myShopClient.playerShopN[fromSlot])
        amount = c.myShopClient.playerShopN[fromSlot];
      for (int x = 0; x < amount; x++) {
        if (c.getItems().freeSlots() > 0) {
          c.getItems().addItem(c.myShopClient.playerShop[fromSlot], 1);
          c.myShopClient.playerShopN[fromSlot]--;
          if (c.myShopClient.playerShopN[fromSlot] == 0) {
            c.myShopClient.playerShop[fromSlot] = 0;
            c.myShopClient.playerShopP[fromSlot] = 0;
            fixShop(c);
          }
        } else {
          c.sendMessage("Not enought space.");
          break;
        }
      }
      resetShop(c.myShopClient);
      c.getItems().resetItems(3823);
      return false;
    } else if (c.myShopId == 7390) {
      return false;
    }
    if (System.currentTimeMillis() - buyDelay < 1500) {
      return false;
    }

    if (c.myShopId == 14) {
      skillBuy(itemID);
      return false;

    } else if (c.myShopId == 15) {
      buyVoid(itemID);
      return false;

    } else if (c.myShopId == 1) {
      buyVoid(itemID);
      return false;
    }
    if (itemID != itemID) {
      c.sendMessage("Don't dupe or you will be IP Banned");
      return false;
    }

    if (!shopSellsItem(itemID)) return false;

    if (amount > 0) {
      if (amount > Server.shopHandler.ShopItemsN[c.myShopId][fromSlot]) {
        amount = Server.shopHandler.ShopItemsN[c.myShopId][fromSlot];
      }
      // double ShopValue;
      // double TotPrice;
      int TotPrice2 = 0;
      // int Overstock;
      int Slot = 0;
      int Slot1 = 0; // Tokkul
      int Slot2 = 0; // Pking Points
      int Slot3 = 0; // Donator Gold
      int Slot4 = 0; // Dragon Tokens

      if (c.myShopId == 18) {
        handleOtherShop(itemID);
        return false;
      }
      if (c.myShopId == 73) {
        handleOtherShop(itemID);
        return false;
      }
      if (c.myShopId == 74) {
        handleOtherShop(itemID);
        return false;
      }
      if (c.myShopId == 10) {
        handleOtherShop(itemID);
        return false;
      }
      if (c.myShopId == 11) {
        handleOtherShop(itemID);
        return false;
      }
      if (c.myShopId == 48) {
        handleOtherShop(itemID);
        return false;
      }
      if (amount > 1000) {
        TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot)) * amount;
        Slot = c.getItems().getItemSlot(995);
        if (Slot == -1 && TotPrice2 != 0) {
          c.sendMessage("You don't have enough coins.");
        }
        if (TotPrice2 <= 1) {
          TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot));
        }
        if (TotPrice2 <= 0) {
          if (c.getItems().freeSlots() > 0) {
            c.getItems().addItem(itemID, amount);
            Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
            Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
            if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
              Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
            }
          } else {
            c.sendMessage("Not enough space in your inventory.");
          }
        } else if (c.playerItemsN[Slot] >= TotPrice2) {
          if (c.getItems().freeSlots() > 0) {
            c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
            c.getItems().addItem(itemID, amount);
            Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= amount;
            Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
            if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
              Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
            }
          } else {
            c.sendMessage("Not enough space in your inventory.");
          }
        } else {
          c.sendMessage("You don't have enough coins.");
        }
      } else {
      }
      for (int i = amount; i > 0; i--) {
        TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot));
        Slot = c.getItems().getItemSlot(995);
        Slot1 = c.getItems().getItemSlot(6529);
        Slot3 = c.getItems().getItemSlot(5555);
        Slot4 = c.getItems().getItemSlot(7478);
        if (Slot == -1
            && c.myShopId != 11
            && c.myShopId != 29
            && c.myShopId != 30
            && c.myShopId != 31
            && c.myShopId != 47) {
          c.sendMessage("You don't have enough coins.");
          break;
        }
        if (Slot1 == -1 && c.myShopId == 29 || c.myShopId == 30 || c.myShopId == 31) {
          c.sendMessage("You don't have enough tokkul.");
          break;
        }
        if (Slot4 == -1 && c.myShopId == 78) {
          c.sendMessage("You don't have enough DT's.");
          break;
        }

        if (TotPrice2 <= 1) {
          TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot));
          TotPrice2 *= 1.66;
        }
        if (c.myShopId == 29 || c.myShopId == 30 || c.myShopId == 31) {
          if (c.playerItemsN[Slot1] >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.getItems().deleteItem(6529, c.getItems().getItemSlot(6529), TotPrice2);
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough tokkul.");
            break;
          }
        } else if (c.myShopId == 47) {
          if (c.pkPoints >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.pkPoints -= TotPrice2;
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough reflexion Points.");
            break;
          }
        } else if (c.myShopId == 48) {
          if (c.SPoints >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.SPoints -= TotPrice2;
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough Slayer Points.");
            break;
          }
        } else if (c.myShopId == 11) {
          if (c.lvlPoints >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.lvlPoints -= TotPrice2;
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough lvl Points.");
            break;
          }
        } else if (c.myShopId == 10) {
          if (c.donorPoints >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.donorPoints -= TotPrice2;
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough Donor Points.");
            break;
          }
        } else if (c.myShopId == 78) {
          if (c.playerItemsN[Slot4] >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.getItems().deleteItem(7478, c.getItems().getItemSlot(7478), TotPrice2);
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough DT's.");
            break;
          }
        } else if (c.myShopId != 11 && c.myShopId != 29
            || c.myShopId != 30
            || c.myShopId != 31
            || c.myShopId != 47) {
          if (c.playerItemsN[Slot] >= TotPrice2) {
            if (c.getItems().freeSlots() > 0) {
              buyDelay = System.currentTimeMillis();
              c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
              c.getItems().addItem(itemID, 1);
              Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
              Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
              if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
                Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
              }
            } else {
              c.sendMessage("You don't have enough space in your inventory.");
              break;
            }
          } else {
            c.sendMessage("You don't have enough coins.");
            break;
          }
        }
      }
      c.getItems().resetItems(3823);
      resetShop(c.myShopId);
      updatePlayerShop();
      return true;
    }
    return false;
  }