Jump to content
  • 0

Help Class Master NPC ( how to make it)


Question

Posted

hi guys, this week i try to make one server with my friend ( we use l2AvA Files ) but i have some problems with class master NPC ( dont work).
The npc comes with this code
1150415698_DialogoNPC.PNG.8819de4655169aeac71d9f23517e78c1.PNG

i take the code for another npc ( gm shop) and i make this button ..2.thumb.PNG.08496bdcff161498b5a66ea1c97a7ffe.PNG

the problem is what action can i use here?  i try with bypass "-h scripts_services_community_CareerManager"(but dont work)
throws this error

5.PNG.f6573423209f241221be18d89af09f52.PNG

 

btw this is the file

4.PNG.fef7a6940836d54ca8a85b28cad122f1.PNG

 

package services.community;

import java.util.StringTokenizer;

import l2ro.gameserver.Config;
import l2ro.gameserver.data.htm.HtmCache;
import l2ro.gameserver.data.xml.holder.ItemHolder;
import l2ro.gameserver.handler.bbs.CommunityBoardManager;
import l2ro.gameserver.handler.bbs.ICommunityBoardHandler;
import l2ro.gameserver.model.Player;
import l2ro.gameserver.model.base.ClassId;
import l2ro.gameserver.model.items.ItemInstance;
import l2ro.gameserver.network.serverpackets.ShowBoard;
import l2ro.gameserver.network.serverpackets.SystemMessage2;
import l2ro.gameserver.network.serverpackets.components.SystemMsg;
import l2ro.gameserver.scripts.ScriptFile;
import l2ro.gameserver.templates.item.ItemTemplate;
import l2ro.gameserver.utils.Util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CareerManager implements ScriptFile, ICommunityBoardHandler
{
    private static final Logger _log = LoggerFactory.getLogger(CareerManager.class);
    
    @Override
    public void onLoad()
    {
        if (Config.COMMUNITYBOARD_ENABLED/* && Config.BBS_PVP_CB_ENABLED*/)
        {
            _log.info("CommunityBoard: Manage Career service loaded.");
            CommunityBoardManager.getInstance().registerHandler(this);
        }
    }

    @Override
    public void onReload()
    {
        if (Config.COMMUNITYBOARD_ENABLED/* && Config.BBS_PVP_CB_ENABLED*/)
            CommunityBoardManager.getInstance().removeHandler(this);
    }

    @Override
    public void onShutdown()
    {}

    @Override
    public String[] getBypassCommands()
    {
        return new String[] { "_bbscareer;", "_bbscareer;sub;", "_bbscareer;classmaster;change_class;" };
    }

    @SuppressWarnings("incomplete-switch")
    @Override
    public void onBypassCommand(Player activeChar, String command)
    {
        if (!checkCondition(activeChar))
            return;

        if (command.startsWith("_bbscareer;classmaster;change_class;"))
        {
            StringTokenizer st = new StringTokenizer(command, ";");
            st.nextToken();
            st.nextToken();
            st.nextToken();
            final int classId = Integer.parseInt(st.nextToken());
            
            // Synerge - Check if the player can actually transfer to that class
            if (!checkIfCanTransferToClass(activeChar, classId))
            {
                // TODO: Cheater?
                _log.warn("CareerManager: The player " + activeChar.getName() + " wanted to transfer to a class that he cannot to. Cheater?");
                return;
            }
                        
            final int price = Integer.parseInt(st.nextToken());
            ItemTemplate item = ItemHolder.getInstance().getTemplate(Config.CLASS_MASTERS_PRICE_ITEM);
            ItemInstance pay = activeChar.getInventory().getItemByItemId(item.getItemId());
            if (pay != null && pay.getCount() >= price)
            {
                activeChar.getInventory().destroyItem(pay, price, "Class Changer");
                changeClass(activeChar, classId);
                onBypassCommand(activeChar, "_bbscareer;");
            }
            else if (Config.CLASS_MASTERS_PRICE_ITEM == 57)
            {
                activeChar.sendPacket(new SystemMessage2(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA));
            }
            else
            {
                activeChar.sendPacket(new SystemMessage2(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA));
            }
        }
        else if (command.startsWith("_bbscareer;"))
        {
            ClassId classId = activeChar.getClassId();
            int jobLevel = classId.getLevel();
            int level = activeChar.getLevel();
            StringBuilder html = new StringBuilder();
            html.append("<br>");
            html.append("<table width=600>");
            html.append("<tr><td>");
            if (Config.ALLOW_CLASS_MASTERS_LIST.isEmpty() || !Config.ALLOW_CLASS_MASTERS_LIST.contains(jobLevel))
                jobLevel = 4;

            if ((level >= 20 && jobLevel == 1 || level >= 40 && jobLevel == 2 || level >= 76 && jobLevel == 3) && Config.ALLOW_CLASS_MASTERS_LIST.contains(jobLevel))
            {
                ItemTemplate item = ItemHolder.getInstance().getTemplate(Config.CLASS_MASTERS_PRICE_ITEM);
                html.append("You have to pay: <font color=\"LEVEL\">");
                html.append(Util.formatAdena(Config.CLASS_MASTERS_PRICE_LIST[jobLevel])).append("</font> <font color=\"LEVEL\">").append(item.getName()).append("</font> to change profession<br>");
                html.append("<center><table width=600><tr>");
                for (ClassId cid : ClassId.values())
                {
                    if (cid == ClassId.inspector)
                        continue;
                    if (cid.childOf(classId) && cid.level() == classId.level() + 1)
                        html.append("<td><center><button value=\"").append(cid.name()).append("\" action=\"bypass _bbscareer;classmaster;change_class;").append(cid.getId()).append(";").append(Config.CLASS_MASTERS_PRICE_LIST[jobLevel]).append("\" width=150 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td>");

                }
                html.append("</tr></table></center>");
                html.append("</td>");
                html.append("</tr>");
                html.append("</table>");
            }
            String content = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "pages/career.htm", activeChar);
            content = content.replace("%career%", html.toString());
            ShowBoard.separateAndSend(content, activeChar);
        }
    }

    private static void changeClass(Player player, int classId)
    {
        if (player.getClassId().getLevel() == 3)
            player.sendPacket(SystemMsg.CONGRATULATIONS__YOUVE_COMPLETED_YOUR_THIRDCLASS_TRANSFER_QUEST); // ??? 3 ?????
        else
            player.sendPacket(SystemMsg.CONGRATULATIONS__YOUVE_COMPLETED_A_CLASS_TRANSFER); // ??? 1 ? 2 ?????

        player.setClassId(classId, false, false);
        player.broadcastUserInfo(true);
    }

    @Override
    public void onWriteCommand(Player player, String bypass, String arg1, String arg2, String arg3, String arg4, String arg5)
    {}

    private static boolean checkCondition(Player player)
    {
        if (player == null)
            return false;

        if (!Config.USE_BBS_PROF_IS_COMBAT && (player.getPvpFlag() != 0 || player.isInDuel() || player.isInCombat() || player.isAttackingNow()))
        {
            player.sendMessage("During combat, you can not use this feature.");
            return false;
        }

        return true;
    }
    
    /**
     * @param player
     * @param newClassId
     * @return Returns true if the player can transfer to the selected class
     */
    private static boolean checkIfCanTransferToClass(Player player, int newClassId)
    {
        if (player == null)
            return false;

        final ClassId currentClassId = player.getClassId();
        final int jobLevel = player.getLevel();
        final int level = player.getLevel();
        
        if (Config.ALLOW_CLASS_MASTERS_LIST.isEmpty() || !Config.ALLOW_CLASS_MASTERS_LIST.contains(jobLevel))
            return false;

        if ((level >= 20 && jobLevel == 1 || level >= 40 && jobLevel == 2 || level >= 76 && jobLevel == 3) && Config.ALLOW_CLASS_MASTERS_LIST.contains(jobLevel))
        {        
            for (ClassId cid : ClassId.values())
            {
                if (cid.getId() != newClassId)
                    continue;
                
                if (cid == ClassId.inspector)
                    return false;
                
                if (cid.childOf(currentClassId) && cid.level() == currentClassId.level() + 1)
                    return true;
    
            }
        }
        
        return false;
    }
}

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.


  • Posts

    • Tool that allows you to download the Lineage 2 game client directly from the official publisher CDNs. It fetches the CDN's file list and downloads every patch file, decompresses it (LZMA / Zip) and writes the finished client to disk — and can resume or repair an existing installation instead of starting over. It runs several client downloads at once through a batch queue, so you can prepare multiple regions or versions in a single session.   Supported: NCSoft CDNs (TW / KR / JP / NA) and  4game CDNs(RU / EU)   Download: https://drive.google.com/file/d/11SDcNASqO2GKOBT79LFu7mqvSRSJZvBS
    • https://l2avokado.com/ Hello everyone,   After some time of development, we've decided to open L2Avokado to the public in its current development stage. We're looking for players who enjoy Interlude and would like to help shape the project before its official release.   This isn't a "launch" announcement. Instead, we're inviting the community to log in, explore the server, test the systems we've built, and provide honest feedback. Whether it's bug reports, balance suggestions, progression ideas, or quality-of-life improvements, we'd love to hear them.   Our goal has always been to create an Interlude server that feels familiar while offering a fresh progression experience. We've intentionally avoided custom weapons, armor, and client modifications. Instead, we've focused on redesigning progression through reworked hunting grounds, quests, crafting, and gameplay systems while remaining compatible with a clean Interlude client.   At this stage, the core progression path has been implemented, including the main hunting grounds, quests, custom systems, and events. However, as the project is still under active development, there will inevitably be bugs, balance issues, and areas that require further polishing.   This is exactly why we'd like your help.   We're looking for players who are willing to: Test gameplay and progression. Report bugs and exploits. Suggest balance improvements. Share ideas for new features or quality-of-life changes. Help us build a server that the community genuinely enjoys playing.   The Client and System downloads are already available on our website, so you can jump straight into the game. We're also working on a dedicated launcher that will simplify installation and future updates.   If you're interested in helping develop a unique Interlude project and want your feedback to genuinely influence the direction of the server, we'd love to have you with us.   We look forward to seeing you in-game and hearing your thoughts on Discord. https://l2avokado.com/
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..