Package l2p.gameserver.model.base

Examples of l2p.gameserver.model.base.Transaction


    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null)
    {
      return;
    }
    Transaction transaction = activeChar.getTransaction();
    if(transaction == null)
    {
      return;
    }
    if(!transaction.isValid() || !transaction.isTypeOf(TransactionType.TRADE_REQUEST))
    {
      transaction.cancel();
      if(_response == 1)
      {
        activeChar.sendPacket(Msg.THAT_PLAYER_IS_NOT_ONLINE, Msg.ActionFail);
      }
      else
      {
        activeChar.sendPacket(Msg.TIME_EXPIRED, Msg.ActionFail);
      }
      return;
    }
    L2Player requestor = transaction.getOtherPlayer(activeChar);
    if(_response != 1 || activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
    {
      requestor.sendPacket(new SystemMessage(SystemMessage.C1_HAS_DENIED_YOUR_REQUEST_TO_TRADE).addString(activeChar.getName()), Msg.ActionFail);
      transaction.cancel();
      if(activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
      {
        activeChar.sendPacket(Msg.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
      }
      return;
    }
    transaction.cancel();
    new Transaction(TransactionType.TRADE, activeChar, requestor);
    requestor.sendPacket(new SystemMessage(SystemMessage.YOU_BEGIN_TRADING_WITH_C1).addString(activeChar.getName()), new TradeStart(requestor, activeChar));
    activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_BEGIN_TRADING_WITH_C1).addString(requestor.getName()), new TradeStart(activeChar, requestor));
  }
View Full Code Here


    if(target.isInTransaction())
    {
      activeChar.sendPacket(new SystemMessage(SystemMessage.S1_IS_BUSY_PLEASE_TRY_AGAIN_LATER).addString(target.getName()));
      return;
    }
    new Transaction(TransactionType.ALLY, activeChar, target, 10000);
    //leader of alliance request an alliance.
    SystemMessage sm = new SystemMessage(SystemMessage.S2_THE_LEADER_OF_S1_HAS_REQUESTED_AN_ALLIANCE);
    sm.addString(activeChar.getAlliance().getAllyName());
    sm.addString(activeChar.getName());
    target.sendPacket(sm, new AskJoinAlliance(activeChar.getObjectId(), activeChar.getName(), activeChar.getAlliance().getAllyName()));
View Full Code Here

      L2Player activeChar = getClient().getActiveChar();
      if(activeChar == null)
      {
        return;
      }
      Transaction transaction = activeChar.getTransaction();
      L2Player requestor;
      if(transaction == null || (requestor = transaction.getOtherPlayer(activeChar)) == null)
      {
        if(transaction != null)
        {
          transaction.cancel();
        }
        activeChar.sendPacket(SendTradeDone.Fail, Msg.ActionFail);
        return;
      }
      if(activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE || requestor.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
      {
        transaction.cancel();
        activeChar.sendPacket(SendTradeDone.Fail, Msg.ActionFail);
        activeChar.sendPacket(Msg.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
        requestor.sendPacket(Msg.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
        return;
      }
      if(!transaction.isTypeOf(TransactionType.TRADE))
      {
        transaction.cancel();
        activeChar.sendPacket(SendTradeDone.Fail, Msg.ActionFail, new SystemMessage("Something wrong. Maybe, cheater?"));
        requestor.sendPacket(SendTradeDone.Fail, Msg.ActionFail, new SystemMessage("Something wrong. Maybe, cheater?"));
        return;
      }
      if(_response == 1)
      {
        // first party accepted the trade
        // notify clients that "OK" button has been pressed.
        transaction.confirm(activeChar);
        requestor.sendPacket(new SystemMessage(SystemMessage.C1_HAS_CONFIRMED_THE_TRADE).addString(activeChar.getName()), Msg.TradePressOtherOk);
        if(!transaction.isConfirmed(activeChar) || !transaction.isConfirmed(requestor)) // Check for dual confirmation
        {
          activeChar.sendActionFailed();
          return;
        }
        //Can't exchange on a big distance
        if(!activeChar.isInRange(requestor, 1000))
        {
          transaction.cancel();
          activeChar.sendPacket(SendTradeDone.Fail, new SystemMessage(SystemMessage.C1_HAS_CANCELLED_THE_TRADE).addString(requestor.getName()));
          requestor.sendPacket(SendTradeDone.Fail, new SystemMessage(SystemMessage.C1_HAS_CANCELLED_THE_TRADE).addString(activeChar.getName()));
          return;
        }
        boolean trade1Valid = L2TradeList.validateTrade(activeChar, transaction.getExchangeList(activeChar));
        boolean trade2Valid = L2TradeList.validateTrade(requestor, transaction.getExchangeList(requestor));
        if(trade1Valid && trade2Valid)
        {
          transaction.tradeItems();
          requestor.sendPacket(Msg.YOUR_TRADE_IS_SUCCESSFUL, SendTradeDone.Success);
          activeChar.sendPacket(Msg.YOUR_TRADE_IS_SUCCESSFUL, SendTradeDone.Success);
        }
        else
        {
          if(!trade2Valid)
          {
            String msgToSend = requestor.getName() + " tried a trade dupe [!trade2Valid]";
            Log.add(msgToSend, "illegal-actions");
            GmListTable.broadcastMessageToGMs(msgToSend);
          }
          if(!trade1Valid)
          {
            String msgToSend = activeChar.getName() + " tried a trade dupe [!trade1Valid]";
            Log.add(msgToSend, "illegal-actions");
            GmListTable.broadcastMessageToGMs(msgToSend);
          }
          activeChar.sendPacket(Msg.THE_ATTEMPT_TO_TRADE_HAS_FAILED, SendTradeDone.Fail);
          requestor.sendPacket(Msg.THE_ATTEMPT_TO_TRADE_HAS_FAILED, SendTradeDone.Fail);
        }
      }
      else
      {
        activeChar.sendPacket(SendTradeDone.Fail);
        requestor.sendPacket(SendTradeDone.Fail, new SystemMessage(SystemMessage.C1_HAS_CANCELLED_THE_TRADE).addString(activeChar.getName()));
      }
      transaction.cancel();
    }
  }
View Full Code Here

    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null || _amount < 1)
    {
      return;
    }
    Transaction transaction = activeChar.getTransaction();
    if(transaction == null)
    {
      return;
    }
    if(!transaction.isValid() || !transaction.isTypeOf(TransactionType.TRADE))
    {
      transaction.cancel();
      activeChar.sendPacket(Msg.TIME_EXPIRED, Msg.ActionFail);
      return;
    }
    L2Player requestor = transaction.getOtherPlayer(activeChar);
    if(transaction.isConfirmed(activeChar) || transaction.isConfirmed(requestor))
    {
      activeChar.sendPacket(Msg.YOU_CANNOT_MOVE_ADDITIONAL_ITEMS_BECAUSE_TRADE_HAS_BEEN_CONFIRMED, Msg.ActionFail);
      return;
    }
    L2ItemInstance InvItem = activeChar.getInventory().getItemByObjectId(_objectId);
    if(InvItem == null || !InvItem.canBeTraded(activeChar))
    {
      activeChar.sendPacket(Msg.THIS_ITEM_CANNOT_BE_TRADED_OR_SOLD);
      return;
    }
    long InvItemCount = InvItem.getCount();
    TradeItem tradeItem = getItem(_objectId, transaction.getExchangeList(activeChar));
    long realCount = Math.min(_amount, InvItemCount);
    long leaveCount = InvItemCount - realCount;
    if(tradeItem == null)
    {
      // добавляем новую вещь в список
      tradeItem = new TradeItem(InvItem);
      tradeItem.setCount(realCount);
      transaction.getExchangeList(activeChar).add(tradeItem);
    }
    else
    {
      // меняем количество уже имеющегося
      if(!InvItem.canBeTraded(activeChar))
View Full Code Here

    if(!PartyRoomManager.getInstance().isLeader(activeChar))
    {
      activeChar.sendPacket(Msg.ONLY_THE_LEADER_CAN_GIVE_OUT_INVITATIONS);
      return;
    }
    new Transaction(TransactionType.PARTY_ROOM, activeChar, targetChar, 10000);
    targetChar.sendPacket(new ExAskJoinPartyRoom(activeChar.getName()));
    activeChar.sendPacket(new SystemMessage(SystemMessage.S1_HAS_INVITED_YOU_TO_ENTER_THE_PARTY_ROOM).addString(targetChar.getName()));
  }
View Full Code Here

      activeChar.sendMessage(new CustomMessage("l2p.gameserver.clientpackets.RequestJoinParty.InDimensionalRift", activeChar));
      activeChar.sendActionFailed();
    }
    if(!target.isInTransaction())
    {
      new Transaction(TransactionType.PARTY, activeChar, target, 10000);
      target.sendPacket(new AskJoinParty(activeChar.getName(), itemDistribution));
      activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_INVITED_C1_TO_JOIN_YOUR_PARTY).addString(target.getName()));
    }
    else
    {
View Full Code Here

  private void createNewParty(L2GameClient client, int itemDistribution, L2Player target, L2Player requestor)
  {
    if(!target.isInTransaction())
    {
      requestor.setParty(new L2Party(requestor, itemDistribution));
      new Transaction(TransactionType.PARTY, requestor, target, 10000);
      target.sendPacket(new AskJoinParty(requestor.getName(), itemDistribution));
      requestor.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_INVITED_C1_TO_JOIN_YOUR_PARTY).addString(target.getName()));
    }
    else
    {
View Full Code Here

    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null)
    {
      return;
    }
    Transaction transaction = activeChar.getTransaction();
    if(transaction == null)
    {
      return;
    }
    if(!transaction.isValid() || !transaction.isTypeOf(TransactionType.PARTY_ROOM))
    {
      transaction.cancel();
      activeChar.sendPacket(Msg.TIME_EXPIRED, Msg.ActionFail);
      return;
    }
    L2Player requestor = transaction.getOtherPlayer(activeChar);
    transaction.cancel();
    if(_response == 1)
    {
      if(requestor.getPartyRoom() <= 0)
      {
        activeChar.sendActionFailed();
View Full Code Here

    return false;
  }

  public SystemMessage canJoinParty(L2Player inviter)
  {
    Transaction transaction = getTransaction();
    if(transaction != null && transaction.isInProgress() && transaction.getOtherPlayer(this) != inviter)
    {
      return Msg.WAITING_FOR_ANOTHER_REPLY;
    } // занят
    if(isBlockAll() || getMessageRefusal()) // всех нафиг
    {
View Full Code Here

    L2Player player = getClient().getActiveChar();
    if(player == null)
    {
      return;
    }
    Transaction transaction = player.getTransaction();
    if(transaction == null)
    {
      return;
    }
    if(!transaction.isValid() || !transaction.isTypeOf(TransactionType.DUEL))
    {
      transaction.cancel();
      player.sendPacket(Msg.TIME_EXPIRED, Msg.ActionFail);
      return;
    }
    L2Player requestor = transaction.getOtherPlayer(player);
    transaction.cancel();
    if(_response == 1)
    {
      SystemMessage msg1, msg2;
      if(_duelType == 1)
      {
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.base.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.