Jump to content

Question

Posted (edited)

hello i try make a counter but is not show if is start

i need little help tnx

here is the code

long timer;

private ScheduledFuture<?> _startCounter = null;

	public void CounterStart()
	{
		timer = 1000*50;
		
		_startCounter = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Runnable()
		{
			@Override
			public void run()
			{
				countDown(); // start counter
			}
		}, 1000 * 10, 1000); // return counter 1 second
	}

	public void countDown()
	{
		int seconds = (int) (timer / 1000);
		seconds--;
		switch (seconds)
		{
			case 3600: // 1 hour left
			case 1800: // 30 minutes left
			case 900: // 15 minutes left
			case 600: // 10 minutes left
			case 300: // 5 minutes left
				Announcements.getInstance().gameAnnounceToAll("test300");
				break;
			case 240: // 4 minutes left
				Announcements.getInstance().gameAnnounceToAll("test240");
				break;
			case 180: // 3 minutes left
				Announcements.getInstance().gameAnnounceToAll("test180");
				break;
			case 120: // 2 minutes left
				Announcements.getInstance().gameAnnounceToAll("test120");
				break;
			case 60: // 1 minute left
				Announcements.getInstance().gameAnnounceToAll("test60");
				break;
			case 30: // 30 seconds left
				Announcements.getInstance().gameAnnounceToAll("test30");
				break;
			case 15: // 15 seconds left
				Announcements.getInstance().gameAnnounceToAll("test15");
				break;
			case 10: // 10 seconds left
				Announcements.getInstance().gameAnnounceToAll("test10");
				break;
			case 3: // 3 seconds left
				Announcements.getInstance().gameAnnounceToAll("test3");
				break;
			case 2: // 2 seconds left
				Announcements.getInstance().gameAnnounceToAll("test2");
				break;
			case 1: // 1 seconds left
				Announcements.getInstance().gameAnnounceToAll("test1");
				break;
			case 0:
				_startCounter.cancel(true);
				ChangeZone();
		}
	}
Edited by tazerman2

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

 

hello i try make a counter but is not show if is start

i need little help tnx

here is the code

long timer;

private ScheduledFuture<?> _startCounter = null;

	public void CounterStart()
	{
		timer = 1000*50;
		
		_startCounter = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Runnable()
		{
			@Override
			public void run()
			{
				countDown(); // start counter
			}
		}, 1000 * 10, 1000); // return counter 1 second
	}

	public void countDown()
	{
		int seconds = (int) (timer / 1000);
		seconds--;
		switch (seconds)
		{
			case 3600: // 1 hour left
			case 1800: // 30 minutes left
			case 900: // 15 minutes left
			case 600: // 10 minutes left
			case 300: // 5 minutes left
				Announcements.getInstance().gameAnnounceToAll("test300");
				break;
			case 240: // 4 minutes left
				Announcements.getInstance().gameAnnounceToAll("test240");
				break;
			case 180: // 3 minutes left
				Announcements.getInstance().gameAnnounceToAll("test180");
				break;
			case 120: // 2 minutes left
				Announcements.getInstance().gameAnnounceToAll("test120");
				break;
			case 60: // 1 minute left
				Announcements.getInstance().gameAnnounceToAll("test60");
				break;
			case 30: // 30 seconds left
				Announcements.getInstance().gameAnnounceToAll("test30");
				break;
			case 15: // 15 seconds left
				Announcements.getInstance().gameAnnounceToAll("test15");
				break;
			case 10: // 10 seconds left
				Announcements.getInstance().gameAnnounceToAll("test10");
				break;
			case 3: // 3 seconds left
				Announcements.getInstance().gameAnnounceToAll("test3");
				break;
			case 2: // 2 seconds left
				Announcements.getInstance().gameAnnounceToAll("test2");
				break;
			case 1: // 1 seconds left
				Announcements.getInstance().gameAnnounceToAll("test1");
				break;
			case 0:
				_startCounter.cancel(true);
				ChangeZone();
		}
	}

 

1,000 * 50 = 50,000

50,000 / 1000 = 50

50 - 1 = 49  

 

Next second it will be 49 / 1000 = 0,049

 

 

You see what you did there?

You have to convert first the timer in seconds and then everytime in scheduler to reduce it by 1 without this /1000

Edited by AccessDenied
Guest
This topic is now closed to further replies.


  • Posts

    • buenas no puedo poner el server On para que entren mis amigos   LoginServer # ================================================= # Settings authorization server # ================================================= # Host and port for client connections LoginserverHostname = 127.0.0.1 LoginserverPort = 2106 # Host and port for game servers LoginHost = 192.168.100.25 ( mi Ip interna) LoginPort = 9014     GameServer   # =============================== # Network Configuration Server  # # =============================== # IP which Bind Game server, * - all possible GameserverHostname = * GameserverPort = 7777 # This is transmitted to the clients connecting from an external network, so it has to be a public IP or resolvable hostname ExternalHostname = 186.158.144.71 ( Ip externa ovbio) # This is transmitted to the client from the same network, so it has to be a local IP or resolvable host name InternalHostname = 192.168.100.25 # AdvIpSystem Make more GameServerIDs. Every Ip should be Protected by a DDoS Guard. # Your Server will have Success with this system Online. AdvIPSystem = False # Address \ port LS LoginPort = 9014 LoginHost = 192.168.100.25 LoginUseCrypt = true # How to request ID of LS RequestServerID = 4 # Permission to take a different id, if requested busy AcceptAlternateID = False     en que estaria fallando ?    
    • mporeis na valeis l2jaCis i kapoio etimo project  free sources gia aCis edw https://acis.i-live.eu/index.php?topic=1974.0 server install ktl edw https://acis.i-live.eu/index.php?topic=10190.0 an dn vgaleis akrh steile mou discord margazeas2
    • Hello! I am new to l2 server creation and i need your help please!!! I want to make my own l2 interlude c6 server with custom thing in it.  I need help with where to start. What source pack to pick to start and what to do. Please if you can help me i would appreciate it very much !!!
    • Need Discord with rare badge? VISIT US AND SHOP WITH US! NEW STOCK   Aged, Early Supporter Discord Accounts I sell HQ Aged and Early, Discord Accounts that are inactive and not flagged by discord at cheap prices   If you want to contact me, you can add me on discord: worldcoldwar Features: Format - age : email : pass : token Not flagged and undetected by discord HQ % With OGE Emails, password etc can be changed Unverified Early Supporter 24M Boost Badge HypeSquad Events Early Verified Bot Developer Early Supporters SHOP LINK: disvault1.mypaylix.gg/ For PayPal payments, please open a ticket. If you experience any problems with cryptocurrency payments, please open a ticket as well.
  • 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..