Amida Nguyen Posted February 24, 2014 Posted February 24, 2014 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
Devlin Posted February 24, 2014 Posted February 24, 2014 (edited) 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 February 24, 2014 by Devlin
Amida Nguyen Posted February 24, 2014 Author Posted February 24, 2014 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?
Guest Elfocrash Posted March 7, 2014 Posted March 7, 2014 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.
Devlin Posted March 7, 2014 Posted March 7, 2014 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
Tryskell Posted March 8, 2014 Posted March 8, 2014 (edited) 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 March 8, 2014 by Tryskell
Recommended Posts