A Project for Chronicle 4 based on L2JServer.


    Global Trade Antiflood !

    Share
    avatar
    jamaica

    Posts : 135
    Join date : 2013-02-24
    Age : 28
    Location : Romania

    Global Trade Antiflood !

    Post  jamaica on 22nd August 2013, 20:43

    idk how usefull can be this on c4 but i guess it will be pretty usefull...so...there he is ^.^

    Code:
    Index: java/net/sf/l2j/gameserver/util/FloodProtector.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/util/FloodProtector.java   (revision 2497)
    +++ java/net/sf/l2j/gameserver/util/FloodProtector.java   (working copy)
    @@ -50,7 +50,7 @@
        // reuse delays for protected actions (in game ticks 1 tick = 100ms)
        private static final int[] REUSEDELAY = new int[]
        {
    -      4, 42, 42, 16, 100, 10, 20
    +      4, 42, 42, 16, 100, 10, 20, 50
        };
        
        // protected actions
    @@ -61,6 +61,7 @@
        public static final int PROTECTED_HEROVOICE = 4;
        public static final int PROTECTED_MULTISELL = 5;
        public static final int PROTECTED_SUBCLASS = 6;
    +   public static final int PROTECTED_TRADECHAT = 7;
        
        // =========================================================
        // Constructor
    Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java   (revision 2497)
    +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java   (working copy)
    @@ -23,6 +23,7 @@
     import net.sf.l2j.gameserver.model.L2World;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
    +import net.sf.l2j.gameserver.util.FloodProtector;
     
     /**
      * A chat handler
    @@ -48,6 +49,12 @@
           
           if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
           {
    +         if (!activeChar.isGM() && !FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_TRADECHAT))
    +         {
    +            activeChar.sendMessage("Action failed. Players are only able to speak in the global channel once every 5 seconds.");
    +            return;
    +         }
    +         
              for (L2PcInstance player : pls)
              {
                 if (!BlockList.isBlocked(player, activeChar))

      Current date/time is 24th September 2017, 09:45