Advertisement
Plim

Npc Chat script

Apr 27th, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. public boolean useBypass(String command, L2PcInstance player, L2Character target)
  2. {
  3.     if(player.getInventory().getItemByItemId(1700) != null)
  4.     {
  5.         try
  6.         {
  7.             target = (L2Npc) player.getTarget();
  8.             //Send the first packet normally
  9.             target.broadcastPacket(new CreatureSay(target.getObjectId(), Say2.ALL, target.getName(),"Hello"));
  10.              
  11.             //Schedule the next CreatureSay after 5 secs
  12.             ThreadPoolManager.getInstance().scheduleGeneral(new NpcTalk(new CreatureSay(target.getObjectId(), Say2.ALL, target.getName(),"I said... Hello!!!"), target), 5000);
  13.  
  14.             return true;
  15.  
  16.         }
  17.         catch (Exception e)
  18.         {
  19.             _log.warning("error: " + e);
  20.             return false;  
  21.         }
  22.     }
  23.                
  24. }
  25.  
  26. //Runnable class that implements what you need
  27. private class NpcTalk implements Runnable
  28. {
  29.     private L2Character _target;
  30.  
  31.     public NpcTalk(CreatureSay cs, L2Character target)
  32.     {
  33.         _packet = cs;
  34.         _target = target;
  35.     }
  36.  
  37.     @Override
  38.     public void run()
  39.     {
  40.         _target.broadcastPacket(new CreatureSay(_target.getObjectId(), Say2.ALL, _target.getName(),"Hello"));
  41.     }
  42.    
  43. }
  44.  
  45. public String[] getBypassList()
  46. {
  47.     return COMMANDS;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement