[Ядро]Разделения города на зоны

Тема в разделе "Scripts / Работа со скриптами", создана пользователем MyltiqpRykT, 12 мар 2019.

  1. MyltiqpRykT

    MyltiqpRykT Участник

    Регистрация:
    30 окт 2018
    Сообщения:
    16
    Симпатии:
    23
    Skype:
    bystreamer
    Многим интересно как разделить город на зоны для торговли и крафта как изображено на картинке ниже.
    [​IMG]

    Код:
    Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (revision 14)
    +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (working copy)
    @@ -23,6 +23,7 @@
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PrivateStoreType;
     import net.sf.l2j.gameserver.model.tradelist.TradeList;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
     import net.sf.l2j.gameserver.network.SystemMessageId;
     import net.sf.l2j.gameserver.util.Util;
     
    @@ -79,6 +80,12 @@
      if (!player.isInsideRadius(storePlayer, 150, true, false))
      return;
     
    + if(!player.isInsideZone(ZoneId.BUY))
    + {
    + player.sendMessage("You can't buy items on this area.");
    + return;
    + }
    +
      if (!(storePlayer.getPrivateStoreType() == PrivateStoreType.SELL || storePlayer.getPrivateStoreType() == PrivateStoreType.PACKAGE_SELL))
      return;
     
    Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRecipeShopListSet.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRecipeShopListSet.java (revision 14)
    +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRecipeShopListSet.java (working copy)
    @@ -61,13 +61,13 @@
      player.sendPacket(SystemMessageId.CANT_OPERATE_PRIVATE_STORE_DURING_COMBAT);
      return;
      }
    -
    - if (player.isInsideZone(ZoneId.NO_STORE))
    +
    + if(!player.isInsideZone(ZoneId.CRAFT))
      {
      player.sendPacket(SystemMessageId.NO_PRIVATE_WORKSHOP_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    - }
    + }
     
      if (_count == 0)
      player.forceStandUp();
    
    Index: java/net/sf/l2j/gameserver/model/zone/type/L2CraftZone.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/type/L2CraftZone.java (revision 0)
    +++ java/net/sf/l2j/gameserver/model/zone/type/L2CraftZone.java (working copy)
    @@ -0,0 +1,55 @@
    +/*
    + * This program is free software: you can redistribute it and/or modify it under
    + * the terms of the GNU General Public License as published by the Free Software
    + * Foundation, either version 3 of the License, or (at your option) any later
    + * version.
    + *
    + * This program is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    + * details.
    + *
    + * You should have received a copy of the GNU General Public License along with
    + * this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package net.sf.l2j.gameserver.model.zone.type;
    +
    +import net.sf.l2j.gameserver.model.actor.L2Character;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.zone.L2ZoneType;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
    +
    +/**
    + *
    + */
    +public class L2CraftZone extends L2ZoneType
    +{
    + public L2CraftZone(final int id)
    + {
    + super(id);
    + }
    +
    + @Override
    + protected void onEnter(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.CRAFT, true);
    + }
    +
    + @Override
    + protected void onExit(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.CRAFT, false);
    + }
    +
    + @Override
    + public void onDieInside(final L2Character character)
    + {
    + }
    +
    + @Override
    + public void onReviveInside(final L2Character character)
    + {
    + }
    +}
    \ No newline at end of file
    
    Index: java/net/sf/l2j/gameserver/model/zone/type/L2BuyZone.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/type/L2BuyZone.java (revision 0)
    +++ java/net/sf/l2j/gameserver/model/zone/type/L2BuyZone.java (working copy)
    @@ -0,0 +1,55 @@
    +/*
    + * This program is free software: you can redistribute it and/or modify it under
    + * the terms of the GNU General Public License as published by the Free Software
    + * Foundation, either version 3 of the License, or (at your option) any later
    + * version.
    + *
    + * This program is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    + * details.
    + *
    + * You should have received a copy of the GNU General Public License along with
    + * this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package net.sf.l2j.gameserver.model.zone.type;
    +
    +import net.sf.l2j.gameserver.model.actor.L2Character;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.zone.L2ZoneType;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
    +
    +/**
    + *
    + */
    +public class L2BuyZone extends L2ZoneType
    +{
    + public L2BuyZone(final int id)
    + {
    + super(id);
    + }
    +
    + @Override
    + protected void onEnter(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.BUY, true);
    + }
    +
    + @Override
    + protected void onExit(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.BUY, false);
    + }
    +
    + @Override
    + public void onDieInside(final L2Character character)
    + {
    + }
    +
    + @Override
    + public void onReviveInside(final L2Character character)
    + {
    + }
    +}
    \ No newline at end of file
    
    Index: java/net/sf/l2j/gameserver/model/zone/ZoneId.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/ZoneId.java (revision 14)
    +++ java/net/sf/l2j/gameserver/model/zone/ZoneId.java (working copy)
    @@ -38,7 +38,10 @@
      DANGER_AREA(15),
      CAST_ON_ARTIFACT(16),
      NO_RESTART(17),
    - SCRIPT(18);
    + SCRIPT(18),
    + SELL(19),
    + BUY(20),
    + CRAFT(21);
     
      private final int _id;
     
    Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (revision 14)
    +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (working copy)
    @@ -20,6 +20,7 @@
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PrivateStoreType;
     import net.sf.l2j.gameserver.model.tradelist.TradeList;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
     import net.sf.l2j.gameserver.network.SystemMessageId;
     
     public final class RequestPrivateStoreSell extends L2GameClientPacket
    @@ -74,6 +75,12 @@
      if (!player.isInsideRadius(storePlayer, 150, true, false))
      return;
     
    + if(!player.isInsideZone(ZoneId.SELL))
    + {
    + player.sendMessage("You can't sell items on this area.");
    + return;
    + }
    +
      if (storePlayer.getPrivateStoreType() != PrivateStoreType.BUY)
      return;
     
    Index: java/net/sf/l2j/gameserver/model/zone/type/L2SellZone.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/type/L2SellZone.java (revision 0)
    +++ java/net/sf/l2j/gameserver/model/zone/type/L2SellZone.java (working copy)
    @@ -0,0 +1,55 @@
    +/*
    + * This program is free software: you can redistribute it and/or modify it under
    + * the terms of the GNU General Public License as published by the Free Software
    + * Foundation, either version 3 of the License, or (at your option) any later
    + * version.
    + *
    + * This program is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    + * details.
    + *
    + * You should have received a copy of the GNU General Public License along with
    + * this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package net.sf.l2j.gameserver.model.zone.type;
    +
    +import net.sf.l2j.gameserver.model.actor.L2Character;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.zone.L2ZoneType;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
    +
    +/**
    + *
    + */
    +public class L2SellZone extends L2ZoneType
    +{
    + public L2SellZone(final int id)
    + {
    + super(id);
    + }
    +
    + @Override
    + protected void onEnter(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.SELL, true);
    + }
    +
    + @Override
    + protected void onExit(final L2Character character)
    + {
    + if (character instanceof L2PcInstance)
    + character.setInsideZone(ZoneId.SELL, false);
    + }
    +
    + @Override
    + public void onDieInside(final L2Character character)
    + {
    + }
    +
    + @Override
    + public void onReviveInside(final L2Character character)
    + {
    + }
    +}
    \ No newline at end of file
    После, заходим в data/xml/zones. Создаем SellZone.XML, BuyZone.xml и CraftZone.XML и вставляем следущее
    Код:
    <zone type="SellZone" shape="NPoly" minZ="-x" maxZ="-z">
    <node X="-x" Y="y" />
    <node X="-x" Y="y" />
    </zone>
    Автор : Leki
     
    CriDos, Deathcore и 4ydo нравится это.
  2. CriDos

    CriDos Участник

    Регистрация:
    9 май 2019
    Сообщения:
    6
    Симпатии:
    0
    Отлично, я как раз пишу сервер с основой L2J.
     
  3. Deathcore

    Deathcore Участник

    Регистрация:
    4 май 2019
    Сообщения:
    23
    Симпатии:
    4
    Skype:
    deathcore92ua
    спасибо, за скрипт !)))
     

Партнеры