[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 »

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 »

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 »

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 »

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 »

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