Page 1 of 1
[HELP] Reuse timer code in java [SOLVED]
Posted: Tue Oct 06, 2015 7:16 pm
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?
Re: [HELP] Reuse timer code in java
Posted: Tue Oct 06, 2015 7:24 pm
by UnAfraid
There's SetupGauge packet that makes exactly what you want
Re: [HELP] Reuse timer code in java
Posted: Tue Oct 06, 2015 10:22 pm
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?
Re: [HELP] Reuse timer code in java
Posted: Wed Oct 07, 2015 12:30 pm
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();
}
Re: [HELP] Reuse timer code in java
Posted: Wed Oct 07, 2015 1:19 pm
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