Page 1 of 1

Gameserver Show OnlinePlayers

Posted: Wed Jan 12, 2011 7:25 am
by pajington
Greetings guys, i am newbie in l2j so be patient with me please, if i write this code into java/com/l2jserver/gameserver/gameserver.java i cannot save it and i get an error : "The public type OnlinePlayers must be defined in its own file"

Code: Select all

 package com.l2jserver.gameserver; import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.model.L2World; public class OnlinePlayers{    private static OnlinePlayers _instance;    class AnnounceOnline implements Runnable    {        public void run()        {            System.out.println(L2World.getInstance().getAllPlayers().size()+ " online players");            ThreadPoolManager.getInstance().scheduleGeneral(new AnnounceOnline(), 300000); //Delay between system.out.printin 300000=5min        }    }    private OnlinePlayers()    {        ThreadPoolManager.getInstance().scheduleGeneral(new AnnounceOnline(), 180000); //Schedule load    }    public static OnlinePlayers getInstance()    {        if (_instance == null)            _instance = new OnlinePlayers();        return _instance;    }} 
what's the problem please ?
-and then, after i will compile it through build.xml I need just to copy l2jserver.jar from "build" folder to gameserver folder ?
Thanks.

Re: Gameserver Show OnlinePlayers

Posted: Wed Jan 12, 2011 7:41 am
by jurchiks
It needs to be in a separate class...
Also, your version won't announce anything to anyone, system.out.println prints the text in gameserver console.
Here's the original, and it works: viewtopic.php?f=69&t=13069
Don't try to make things up if you don't know java.

Re: Gameserver Show OnlinePlayers

Posted: Wed Jan 12, 2011 8:23 am
by pajington
y i know that it'll be showed just in console....thanks for the link ;)