Jump to content
  • 0

Question

Posted

Hello guys. I have imp,emented the nobess command. It work partial. It set you nobless but don't delete the items needed for nobless. Here is the code:

 

package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

public class Nobless implements IVoicedCommandHandler
{
  private static final String[] VOICED_COMMANDS = {"nobless"};
  
  public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  {
     if (command.equalsIgnoreCase("nobless"))
     {
        if (activeChar.isNoble())
                 {
              activeChar.sendMessage("You are allready Nobless.");
              return true;
                 }
           else if (activeChar.getLevel() < 76)
                 {
              activeChar.sendMessage("You need level 75 for Nobless");
              return true;
                 }
           else if (activeChar.getSubClasses().isEmpty())
           {
              activeChar.sendMessage("Try again when you make a subclass");
              return true;
           }
           else if(activeChar.getInventory().getItemByItemId(20191) != null && activeChar.getInventory().getItemByItemId(20191).getCount() >= 30)
           {
              activeChar.getInventory().destroyItemByItemId("Noblesse", 20191, 30, activeChar, activeChar.getTarget());
               activeChar.setNoble(true);
               activeChar.broadcastUserInfo();

           }
           else
           {
                 activeChar.sendMessage("You need 30 Valentine Cake Recipe for have Nobless Status.");
               return true;
           }
     }
     return false;
  }
  public String[] getVoicedCommandList()
  {
     return VOICED_COMMANDS;
  }
}

5 answers to this question

Recommended Posts

  • 0
Posted

activeChar.getInventory().getItemByItemId(20191) != null, can't be null with activeChar.getInventory().getItemByItemId(20191).getCount() >= 30

 

package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

public class Nobless implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = {"nobless"};
   
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	if (command.equalsIgnoreCase("nobless"))
	{
		if (activeChar.isNoble())
		{
			activeChar.sendMessage("You are allready Nobless.");
			return true;
		}
		else if (activeChar.getLevel() < 76)
		{
			activeChar.sendMessage("You need level 75 for Nobless");
			return true;
		}
		else if (activeChar.getSubClasses().isEmpty())
		{
			activeChar.sendMessage("Try again when you make a subclass");
			return true;
		}

		if(activeChar.getInventory().getItemByItemId(20191).getCount() >= 30)
		{
			activeChar.getInventory().destroyItemByItemId("Noblesse", 20191, 30, activeChar, null);
			activeChar.setNoble(true);
			activeChar.broadcastUserInfo();
		}
		else
		{
			activeChar.sendMessage("You need 30 Valentine Cake Recipe for have Nobless Status.");
			return false;
		}
	}
	return false;
}
public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}
}

  • 0
Posted

activeChar.getInventory().getItemByItemId(20191) != null, can't be null with activeChar.getInventory().getItemByItemId(20191).getCount() >= 30

 

package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

public class Nobless implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = {"nobless"};
   
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	if (command.equalsIgnoreCase("nobless"))
	{
		if (activeChar.isNoble())
		{
			activeChar.sendMessage("You are allready Nobless.");
			return true;
		}
		else if (activeChar.getLevel() < 76)
		{
			activeChar.sendMessage("You need level 75 for Nobless");
			return true;
		}
		else if (activeChar.getSubClasses().isEmpty())
		{
			activeChar.sendMessage("Try again when you make a subclass");
			return true;
		}

		if(activeChar.getInventory().getItemByItemId(20191).getCount() >= 30)
		{
			activeChar.getInventory().destroyItemByItemId("Noblesse", 20191, 30, activeChar, null);
			activeChar.setNoble(true);
			activeChar.broadcastUserInfo();
		}
		else
		{
			activeChar.sendMessage("You need 30 Valentine Cake Recipe for have Nobless Status.");
			return false;
		}
	}
	return false;
}
public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}
}

 

grrr i just wanted to write the same thing ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock