Jump to content

[Share] OnlinePlayersVoicedCommand


Recommended Posts

ok i wrote a little voice command that shows the online players to the one that calls it

 

Curent ver: Kamael:Hellbound or ct1.5 :P

 

package net.sf.l2j.gameserver.handler.voicedcommandhandlers;


import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;

/**
*
* @author Ombladon
*
* this class...
* shows the amount of online players to any1 who calls it.
*/
public class OnlinePlayers implements IVoicedCommandHandler
{


private static final String[] VOICED_COMMANDS = {"online"};

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
if (command.startsWith("online"))
{
showPlayers(activeChar, target);
}

return true;

}



public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}


public void showPlayers (L2PcInstance player, String target)

{
SystemMessage sm = new SystemMessage(SystemMessageId.S1);
sm = new SystemMessage(SystemMessageId.S1);
sm.addString("======<Online Players>======");
player.sendPacket(sm);
sm = new SystemMessage(SystemMessageId.S1);
sm.addString("There are "+L2World.getInstance().getAllPlayers().size()+" players on.");
player.sendPacket(sm);

sm = new SystemMessage(SystemMessageId.S1);
sm.addString("=======================");
player.sendPacket(sm);
}


}

Cheerz,

¤!¦•[†OmbladoN†]•¦!¤

Link to comment
Share on other sites

lol just put that file in : net.sf.l2j.gameserver.handler.voicedcommandhandlers

 

and register it in net.sf.l2j.gameserver.GameServer.java

using this code:

Index: D:/L2J/workspace/Hellbound/java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- D:/L2J/workspace/Hellbound/java/net/sf/l2j/gameserver/GameServer.java	(revision 2048)
+++ D:/L2J/workspace/Hellbound/java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -204,6 +204,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.PartyInfo;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Time;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Banking;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Wedding;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.stats;
import net.sf.l2j.gameserver.idfactory.IdFactory;
@@ -631,6 +632,7 @@
		_voicedCommandHandler = VoicedCommandHandler.getInstance();
		_voicedCommandHandler.registerVoicedCommandHandler(new stats());

+		_voicedCommandHandler.registerVoicedCommandHandler(new OnlinePlayers());
		if(Config.L2JMOD_ALLOW_WEDDING)
			_voicedCommandHandler.registerVoicedCommandHandler(new Wedding());

 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...
  • 9 months later...
  • 5 months later...
Guest
This topic is now closed to further replies.


×
×
  • Create New...