Jump to content

I Need Code The Function: Reward To Player Base On Online-Time


Recommended Posts

I need code the function: reward to player base on online-time. Ex: when player online in-game 1 hour, he will receive 1 Gold Bar, but when he log out of game, the online-time will reset to 0

Link to comment
Share on other sites

if (player.getUptime() >= val*60*60*1000)

 

val stands for hours.

 

and for reseting the time, go at Logout.java and add this line:

 

player.setUptime(0);

 

By the way, dunno what project are you using. The codes that I wrote you are based on l2jfrozen methods.

Edited by Devlin
Link to comment
Share on other sites

if (player.getUptime() >= val*60*60*1000)

 

val stands for hours.

 

and for reseting the time, go at Logout.java and add this line:

 

player.setUptime(0);

 

By the way, dunno what project are you using. The codes that I wrote you are based on l2jfrozen methods.

 

Are you check my PM?

Link to comment
Share on other sites

  • 2 weeks later...
Guest Elfocrash

if (player.getUptime() >= val*60*60*1000)

 

val stands for hours.

 

and for reseting the time, go at Logout.java and add this line:

 

player.setUptime(0);

 

By the way, dunno what project are you using. The codes that I wrote you are based on l2jfrozen methods.

This wont work on any kind of project ever unless you check in as a task.

Also the time of uptime is automaticaly reset on logout.

Link to comment
Share on other sites

This wont work on any kind of project ever unless you check in as a task.

Also the time of uptime is automaticaly reset on logout.

For sure it needs a task.

 

About the reset, I didn't know :P

Link to comment
Share on other sites

A simple task with a counter linked to L2PcInstance can do the trick. Inside the run section you ++ the counter and make checks regarding it.

 

An exemple for monster derby track which I'm currently recoding for aCis, making checks every seconds to call events :

 

Called by

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Announcement(), 0, 1000);

And running

	class Announcement implements Runnable
	{
		public Announcement()
		{
		}
		
		@Override
		public void run()
		{
			if (_finalCountdown >= 1200)
				_finalCountdown = 0;
			
			switch (_finalCountdown)
			{
				case 0:
					makeAnnouncement(SystemMessageId.MONSRACE_TICKETS_AVAILABLE_FOR_S1_RACE);
					break;
				
				case 30: // 30 sec
				case 60: // 1 min
					...
				
				case 1080: // 18 min
					makeAnnouncement(SystemMessageId.MONSRACE_RACE_START);
					break;
			}
			_finalCountdown += 1;
		}
	}

As you can see on my exemple, it runs the task every second, increasing _finalCountdown value and checking if that variable reached a particular number.

			if (_finalCountdown >= 1200)
				_finalCountdown = 0;

exists to make a cycle of 20min (reset to 0 when it happens).

 

Instead of 1000 (one second), you put 60000 (one minute) for scheduleGeneralAtFixedRate timer and then you can reward for case 30, 60, 120, etc (30min, 1hour, 2hours,..).

Edited by Tryskell
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • rename the l2.bin into l2.exe
    • L2LIVE.PRO- Dynamic Mid-rates Essence Seven Signs GRAND OPENING - July 5, 20:00 GMT+3 (EEST) TEST SERVER IS OPEN - COME AND CHECK IT OUT TODAY! Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu   Server description * EXP/SP: Dynamic (x1- x100 based on your level, *before* Sayha and EXP buffs * Adena: x50 / Item Drop: x10 / Fishing EXP increased / Attribute EXP increased * Simplified gameplay to stay in the loop while not spending hours and hours farming * Starter Pack containing very useful items for beginners * MP replenishing potions with auto-consumption * No overpowered donations L2LIVE shop * All spellbook coupons, pet spellbook coupons and master books are sold via Game Assistant * Additionally you can buy SP pouches, enchanted talismans, pet training guides and various other consumables for Adena and L-Coin * More items such as cloaks, more talismans, agathions, belts, pendants, enchantment scrolls of various grades, evolution stones, etc will be added! Shop server as a shortcut, and all retail-like ways of earning items are still here! L-Coins * Drops with small change and in random amounts from Lv60+ monsters  * All raidbosses drop random amount of L-Coin Pouches generating up to 420 Lcoin per unit. **Grand Olympiad and Events** * Grand Olympiad is held week day * Format is 1v1, unlimited weekly fights  * Heroes are declared weekly at Sunday * There are three automated events - TvT, CTF and Deathmatch, running at evenings * Orc Fortress, Battle with Balok, Keber Hunter, Archievements Box, Daily Gift Calendar provisional events are active too Custom user commands * .offlineplay command, your character will keep playing till death or server restart * .offlineshop command, keeps your shop sitting until all items are purchased * .apon / .apoff - enable/disable HP/MP autoconsume And lots of other small improvements are waiting for you!   Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu
    • I can use this folder system for High Five offline server?   The folder does not have a l2.exe file.   Thank you very much if anyone can help me.   https://drive.google.com/file/d/13kU-g_4JJ-sP-kg2F7pqkUOVKmQdubFm/view
  • Topics

×
×
  • Create New...