We moved our repositories to BitBucket!

If you can't login or you can't register to the forums do not rise an issue, instead please write to support (at) l2jserver.com

Check our wiki!

Report server issues here

Forum has been updated to phpBB 3.2, let's see if this fixes some minor bugs we had.

Thank you for visiting http://www.l2jserver.com/

[HELP] Reuse timer code in java [SOLVED]

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
sponer
Posts: 86
Joined: Sat Jul 02, 2011 6:02 am

[HELP] Reuse timer code in java [SOLVED]

Post by sponer » Tue Oct 06, 2015 7:16 pm

Hello guys...
I want to put a reuse timer code into my buffer but I have no idea if it's even possible...
I want a reuse timer like python's one with a little reuse bar above the character's head...
Could you please help me with that?
Last edited by sponer on Thu Oct 08, 2015 1:45 pm, edited 1 time in total.

User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: [HELP] Reuse timer code in java

Post by UnAfraid » Tue Oct 06, 2015 7:24 pm

There's SetupGauge packet that makes exactly what you want
Image

User avatar
sponer
Posts: 86
Joined: Sat Jul 02, 2011 6:02 am

Re: [HELP] Reuse timer code in java

Post by sponer » Tue Oct 06, 2015 10:22 pm

UnAfraid wrote:There's SetupGauge packet that makes exactly what you want
I saw the packet and I created it...

Code: Select all

SetupGauge timer = new SetupGauge(1, 10000);
player.sendPacket(timer);
but It's just the timer... how can I make it, the buffer or the action (like Heal or Remove Buffs) won't respond until the end of time?

User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: [HELP] Reuse timer code in java

Post by UnAfraid » Wed Oct 07, 2015 12:30 pm

Store the time in your buffer like:

Code: Select all

private static final long REUSE_TIME = 30 * 1000;
private static final Map<Integer, Long> REUSE_TIMES = new ConcurrentHashMap<>();

public void applyReuse(L2PcInstance player) {
     REUSE_TIMES.put(player.getObjectId(), System.currentTimeMillis() + REUSE_TIME);
     player.sendPacket(new SetupGauge(1, REUSE_TIME / 1000));
}

public boolean hasReuse(L2PcInstance player) {
    return REUSE_TIMES.getOrDefault(player.getObjectId(), 0L) > System.currentTimeMillis();
}
Image

User avatar
sponer
Posts: 86
Joined: Sat Jul 02, 2011 6:02 am

Re: [HELP] Reuse timer code in java

Post by sponer » Wed Oct 07, 2015 1:19 pm

UnAfraid wrote:Store the time in your buffer like:

Code: Select all

private static final long REUSE_TIME = 30 * 1000;
private static final Map<Integer, Long> REUSE_TIMES = new ConcurrentHashMap<>();

public void applyReuse(L2PcInstance player) {
     REUSE_TIMES.put(player.getObjectId(), System.currentTimeMillis() + REUSE_TIME);
     player.sendPacket(new SetupGauge(1, REUSE_TIME / 1000));
}

public boolean hasReuse(L2PcInstance player) {
    return REUSE_TIMES.getOrDefault(player.getObjectId(), 0L) > System.currentTimeMillis();
}
Thank you very much, I appreciate your help :)

Post Reply