Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Бафер через альт б
#1
Доброе время суток. Помогите добавить исключение для бафера чтобы нельзя было бафаться когда персонаж в бою, на олимпе. вот скрипт бафера:
Код:
package ru.l2open.gameserver.communitybbs.Manager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import ru.l2open.Config;
import ru.l2open.L2DatabaseFactory;
import ru.l2open.gameserver.cache.HtmCache;
import ru.l2open.gameserver.datatables.SkillTable;
import ru.l2open.gameserver.model.*;
import ru.l2open.gameserver.model.L2Skill;
import ru.l2open.gameserver.model.actor.instance.L2PcInstance;
import ru.l2open.gameserver.network.serverpackets.ExShowScreenMessage;

public class BuffBBSManager extends BaseBBSManager
{

    private static BuffBBSManager _instance = new BuffBBSManager();
    public int allskillid_1[][];

    public BuffBBSManager()
    {
        Load();
    }
    
    public static BuffBBSManager getInstance()
    {
        if(_instance == null)
            _instance = new BuffBBSManager();
        return _instance;
    }
    public void Load()
    {
        Connection connn = null;
        try
        {
            connn = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement count = connn.prepareStatement("SELECT COUNT(*) FROM communitybuff;");
            ResultSet countt = count.executeQuery();
            countt.next();
            allskillid_1 = new int[countt.getInt(1)][4];
            PreparedStatement table = connn.prepareStatement("SELECT * FROM communitybuff");
            ResultSet skills = table.executeQuery();
            for(int i = 0; i < allskillid_1.length; i++)
            {
                skills.next();
                allskillid_1[i][0] = skills.getInt(2);
                allskillid_1[i][1] = skills.getInt(3);
                allskillid_1[i][2] = skills.getInt(4);
                allskillid_1[i][3] = skills.getInt(5);
            }

            count.close();
            countt.close();
            skills.close();
            table.close();
        }
        catch(Exception ignored) { }
    }
    public void parsecmd(String command, L2PcInstance activeChar)
    {
        String[] parts = command.split("_");
        boolean petbuff = false;

        if (!(parts[2].startsWith("buff")))
            return;
        String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/60.htm");
        separateAndSend(content, activeChar);
        
            if(parts[4] != null && parts[4].startsWith(" Player"))
                petbuff = false;
            if(parts[4] != null && parts[4].startsWith(" Pet"))
                petbuff = true;
            if(parts[3].startsWith("FIGHERLIST"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        FIGHERLIST(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    FIGHERLIST(activeChar, petbuff);
                }
            if(parts[3].startsWith("DANCEFIGHTERLIST"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        DANCEFIGHTERLIST(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    DANCEFIGHTERLIST(activeChar, petbuff);
                }
            if(parts[3].startsWith("MAGELIST"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        MAGELIST(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    MAGELIST(activeChar, petbuff);
                }
            if(parts[3].startsWith("DANCEMAGELIST"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        DANCEMAGELIST(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    DANCEMAGELIST(activeChar, petbuff);
                }
            if(parts[3].startsWith("SAVE"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        SAVE(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    SAVE(activeChar, petbuff);
                }
            if(parts[3].startsWith("BUFF"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        BUFF(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    BUFF(activeChar, petbuff);
                }
            if(parts[3].startsWith("CANCEL"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        CANCEL(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    CANCEL(activeChar, petbuff);
                }
            if(parts[3].startsWith("REGMP"))
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                        REGMP(activeChar, petbuff);
                    else
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                } else
                {
                    REGMP(activeChar, petbuff);
                }
            for(int key = 0; key < allskillid_1.length; key++)
            {
                L2Skill skill;
                int skilllevel;
                if(Config.BUFF_PEACE)
                {
                    if(activeChar.isInsideZone((byte)2))
                    {
                        skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[key][0]);
                        skill = SkillTable.getInstance().getInfo(allskillid_1[key][0], skilllevel);
                        if(parts[3].startsWith(skill.getName()))
                            SKILL(activeChar, petbuff, key, skill);
                    } else
                    {
                        activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not in town!", 3000));
                    }
                    continue;
                }
                skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[key][0]);
                skill = SkillTable.getInstance().getInfo(allskillid_1[key][0], skilllevel);
                if(parts[3].startsWith(skill.getName()))
                    SKILL(activeChar, petbuff, key, skill);
            }
    }

    private void FIGHERLIST(L2PcInstance activeChar, boolean petbuff)
    {
        int arr$[][] = allskillid_1;
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; i$++)
        {
            int aSkillid[] = arr$[i$];
            if(aSkillid[1] != 1 && aSkillid[1] != 3)
                continue;
            L2Skill skill;
            int skilllevel;
            if(Config.MANI_BUFF)
            {
                if(activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
                {
                    skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
                    skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
                    if(!petbuff)
                        skill.getEffects(activeChar, activeChar);
                    else
                        skill.getEffects(activeChar.getPet(), activeChar.getPet());
                } else
                {
                    activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                }
                continue;
            }
            skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if(!petbuff)
                skill.getEffects(activeChar, activeChar);
            else
                skill.getEffects(activeChar.getPet(), activeChar.getPet());
        }

    }

    private void DANCEFIGHTERLIST(L2PcInstance activeChar, boolean petbuff)
    {
        int arr$[][] = allskillid_1;
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; i$++)
        {
            int aSkillid[] = arr$[i$];
            if(aSkillid[1] != 4 && aSkillid[1] != 6)
                continue;
            L2Skill skill;
            int skilllevel;
            if(Config.MANI_BUFF)
            {
                if(activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
                {
                    skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
                    skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
                    if(!petbuff)
                        skill.getEffects(activeChar, activeChar);
                    else
                        skill.getEffects(activeChar.getPet(), activeChar.getPet());
                } else
                {
                    activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                }
                continue;
            }
            skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if(!petbuff)
                skill.getEffects(activeChar, activeChar);
            else
                skill.getEffects(activeChar.getPet(), activeChar.getPet());
        }

    }

    private void MAGELIST(L2PcInstance activeChar, boolean petbuff)
    {
        int arr$[][] = allskillid_1;
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; i$++)
        {
            int aSkillid[] = arr$[i$];
            if(aSkillid[1] != 2 && aSkillid[1] != 3)
                continue;
            L2Skill skill;
            int skilllevel;
            if(Config.MANI_BUFF)
            {
                if(activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
                {
                    skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
                    skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
                    if(!petbuff)
                        skill.getEffects(activeChar, activeChar);
                    else
                        skill.getEffects(activeChar.getPet(), activeChar.getPet());
                } else
                {
                    activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                }
                continue;
            }
            skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if(!petbuff)
                skill.getEffects(activeChar, activeChar);
            else
                skill.getEffects(activeChar.getPet(), activeChar.getPet());
        }

    }

    private void DANCEMAGELIST(L2PcInstance activeChar, boolean petbuff)
    {
        int arr$[][] = allskillid_1;
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; i$++)
        {
            int aSkillid[] = arr$[i$];
            if(aSkillid[1] != 5 && aSkillid[1] != 6)
                continue;
            L2Skill skill;
            int skilllevel;
            if(Config.MANI_BUFF)
            {
                if(activeChar.destroyItemByItemId(null, aSkillid[3], aSkillid[2], activeChar, true))
                {
                    skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
                    skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
                    if(!petbuff)
                        skill.getEffects(activeChar, activeChar);
                    else
                        skill.getEffects(activeChar.getPet(), activeChar.getPet());
                } else
                {
                    activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                }
                continue;
            }
            skilllevel = SkillTable.getInstance().getMaxLevel(aSkillid[0]);
            skill = SkillTable.getInstance().getInfo(aSkillid[0], skilllevel);
            if(!petbuff)
                skill.getEffects(activeChar, activeChar);
            else
                skill.getEffects(activeChar.getPet(), activeChar.getPet());
        }

    }

    private void BUFF(L2PcInstance activeChar, boolean petbuff)
    {
        Connection con = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement statement = con.prepareStatement("SELECT * FROM community_skillsave WHERE charId=?;");
            statement.setInt(1, activeChar.getObjectId());
            ResultSet rcln = statement.executeQuery();
            rcln.next();
            if(!petbuff)
            {
                char allskills[] = rcln.getString(2).toCharArray();
                if(allskills.length == allskillid_1.length)
                {
                    for(int i = 0; i < allskillid_1.length; i++)
                        if(allskills[i] == '1')
                            if(Config.MANI_BUFF)
                            {
                                if(activeChar.destroyItemByItemId(null, allskillid_1[i][3], allskillid_1[i][2], activeChar, true))
                                {
                                    int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
                                    L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
                                    skill.getEffects(activeChar, activeChar);
                                    activeChar.getLevel();
                                } else
                                {
                                    activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                                }
                            } else
                            {
                                int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
                                L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
                                skill.getEffects(activeChar, activeChar);
                            }

                }
            } else
            {
                char petskills[] = rcln.getString(3).toCharArray();
                if(petskills.length == allskillid_1.length)
                {
                    for(int i = 0; i < allskillid_1.length; i++)
                    {
                        if(petskills[i] != '1')
                            continue;
                        if(Config.MANI_BUFF)
                        {
                            if(activeChar.destroyItemByItemId(null, allskillid_1[i][3], allskillid_1[i][2], activeChar, true))
                            {
                                int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
                                L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
                                skill.getEffects(activeChar.getPet(), activeChar.getPet());
                            } else
                            {
                                activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
                            }
                        } else
                        {
                            int skilllevel = SkillTable.getInstance().getMaxLevel(allskillid_1[i][0]);
                            L2Skill skill = SkillTable.getInstance().getInfo(allskillid_1[i][0], skilllevel);
                            skill.getEffects(activeChar.getPet(), activeChar.getPet());
                        }
                    }

                }
            }
            rcln.close();
            statement.close();
        }
        catch(Exception ignored)
        {
            try
            {
                if(con != null)
                    con.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

        }
        try
        {
            if(con != null)
                con.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
        try
        {
            if(con != null)
                con.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
    }

    private void CANCEL(L2PcInstance activeChar, boolean petbuff)
    {
        if(!petbuff)
            activeChar.stopAllEffects();
        else
            activeChar.getPet().stopAllEffects();
    }

    private void REGMP(L2PcInstance activeChar, boolean petbuff)
    {
        if(!petbuff)
            activeChar.setCurrentMp(activeChar.getMaxMp());
        else
            activeChar.getPet().setCurrentMp(activeChar.getPet().getMaxMp());
    }

    private void SKILL(L2PcInstance activeChar, boolean petbuff, int key, L2Skill skill)
    {
        if(Config.MANI_BUFF)
        {
            if(activeChar.destroyItemByItemId(null, allskillid_1[key][3], allskillid_1[key][2], activeChar, true))
            {
                if(!petbuff)
                    skill.getEffects(activeChar, activeChar);
                else
                    skill.getEffects(activeChar.getPet(), activeChar.getPet());
            } else
            {
                activeChar.sendPacket(new ExShowScreenMessage("Sorry, you not have item!", 3000));
            }
        }
        else
            if(!petbuff)
                skill.getEffects(activeChar, activeChar);
            else
                skill.getEffects(activeChar.getPet(), activeChar.getPet());
    }

    private void SAVE(L2PcInstance activeChar, boolean petbuff)
    {
        Connection con = null;
        try
        {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement stat = con.prepareStatement("SELECT COUNT(*) FROM community_skillsave WHERE charId=?;");
            stat.setInt(1, activeChar.getObjectId());
            ResultSet rset = stat.executeQuery();
            rset.next();
            String allbuff = "";
            if(!petbuff)
            {
                L2Effect skill[] = activeChar.getAllEffects();
                boolean flag = true;
                int arr$[][] = allskillid_1;
                int len$ = arr$.length;
                for(int i$ = 0; i$ < len$; i$++)
                {
                    int aSkillid[] = arr$[i$];
                    for(int j = 0; j < skill.length; j++)
                    {
                        if(aSkillid[0] == skill[j].getId())
                        {
                            allbuff = (new StringBuilder()).append(allbuff).append(1).toString();
                            flag = false;
                        }
                        if(j == skill.length - 1 && flag)
                            allbuff = (new StringBuilder()).append(allbuff).append(0).toString();
                    }

                    flag = true;
                }
                if(rset.getInt(1) == 0)
                {
                    PreparedStatement statement1 = con.prepareStatement("INSERT INTO community_skillsave (charId,skills) values (?,?)");
                    statement1.setInt(1, activeChar.getObjectId());
                    statement1.setString(2, allbuff);
                    statement1.execute();
                    statement1.close();
                } else
                {
                    PreparedStatement statement = con.prepareStatement("UPDATE community_skillsave SET skills=? WHERE charId=?;");
                    statement.setString(1, allbuff);
                    statement.setInt(2, activeChar.getObjectId());
                    statement.execute();
                    statement.close();
                }
            } else
            {
                L2Effect skill[] = activeChar.getPet().getAllEffects();
                boolean flag = true;
                int arr$[][] = allskillid_1;
                int len$ = arr$.length;
                for(int i$ = 0; i$ < len$; i$++)
                {
                    int aSkillid[] = arr$[i$];
                    for(int j = 0; j < skill.length; j++)
                    {
                        if(aSkillid[0] == skill[j].getId())
                        {
                            allbuff = (new StringBuilder()).append(allbuff).append(1).toString();
                            flag = false;
                        }
                        if(j == skill.length - 1 && flag)
                            allbuff = (new StringBuilder()).append(allbuff).append(0).toString();
                    }
                    flag = true;
                }
                if(rset.getInt(1) == 0)
                {
                    PreparedStatement statement1 = con.prepareStatement("INSERT INTO community_skillsave (charId,pet) values (?,?)");
                    statement1.setInt(1, activeChar.getObjectId());
                    statement1.setString(2, allbuff);
                    statement1.execute();
                    statement1.close();
                } else
                {
                    PreparedStatement statement = con.prepareStatement("UPDATE community_skillsave SET pet=? WHERE charId=?;");
                    statement.setString(1, allbuff);
                    statement.setInt(2, activeChar.getObjectId());
                    statement.execute();
                    statement.close();
                }
            }
            rset.close();
            stat.close();
        }
        catch(Exception ignored)
        {
            try
            {
                if(con != null)
                    con.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
        try
        {
            if(con != null)
                con.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
        try
        {
            if(con != null)
                con.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
    }

    public void parsewrite(String s, String s1, String s2, String s3, String s4, L2PcInstance l2pcinstance)
    {
    }
}
Ответ
#2
Вот тебе набросал примерно что должно у тебя там быть, не имея исходного кода полностью, сложно написать. Собственно если разбираешься, то это поможет тебе...Cool

Код:
public boolean checkCondition(L2PcInstance activeChar)
    {
        if(activeChar == null)
            return false;
        // Проверяем по уровню
        if(activeChar.getLevel() > Config.BUFFER_MAX_LVL || activeChar.getLevel() < Config.BUFFER_MIN_LVL)
        {
            activeChar.sendMessage("Ваш уровень не отвечает требованиям!");
            return false;
        }

        if(activeChar.isDead() || activeChar.isAlikeDead() || activeChar.isCastingNow() || activeChar.isAttackingNow())
        {
            activeChar.sendMessage("Нельзя использовать бафф в вашем состоянии!");
            return;
        }

        if(activeChar.isInCombat())
        {
            activeChar.sendMessage("Нельзя использовать бафф во время боя!");
            return;
        }
        
        //Можно ли юзать бафера во время осады?
        if(!Config.BUFFER_ALLOW_SIEGE)
        {
            Residence castle = TownManager.getInstance().getClosestTown(activeChar).getCastle();
            Siege siege = castle.getSiege();
            if(siege != null)
            {
                activeChar.sendMessage("Нельзя использовать бафф во время осады!");
                return false;
            }
        }
        return true;
    }
[Изображение: e0d394556cfe7fc77265f431b11359ca.gif]
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Скрипт для альт+б Jm0t 0 1,803 03-21-2019, 04:18 PM
Последний пост: Jm0t
  ACP через Панель Spiral 2 1,754 05-20-2018, 08:11 PM
Последний пост: Spiral
  Classic 1.5 баф в Альт Б virusoflove 6 2,452 02-23-2017, 02:48 AM
Последний пост: virusoflove
  альт+G java HiredKiller 10 3,402 12-15-2015, 09:40 AM
Последний пост: HiredKiller
  Дюп через Kamaloka.java dantest 7 2,300 09-14-2015, 09:01 PM
Последний пост: dantest
  Бафер Rezzimx 0 1,178 09-27-2014, 12:02 PM
Последний пост: Rezzimx
  БАфер pyworld 4 1,916 03-04-2014, 11:07 AM
Последний пост: MrShyr
  ХФ прохождение скила типа Сancel через celestial Munhgauzen 8 3,079 11-10-2013, 09:31 PM
Последний пост: Munhgauzen
  Как на оверподобной сборке сэмулировать через макрос безоткатный юз скила Munhgauzen 8 2,084 11-07-2013, 02:34 PM
Последний пост: Aristocrat
  Бафер с профилями и вип бафами Meraklinx 4 1,721 09-15-2013, 01:13 AM
Последний пост: KID

Перейти к форуму:


Пользователи, просматривающие эту тему: 2 Гость(ей)