Any?
|
Can any 1 post me a working log out timer, i need to fix the way of duplicate
Need to LOG OUT Timer it must say you cannot log out in combat smth like this please help
Something like:
Ik, the code is messy, I wrote it here, on forums.Code:if (!p.inCombat() && p.combatTimer == 0) { p.logOut(); } else { p.sendMessage("you are in combat! wait " + p.combatTimer + " seconds to log out"); }
Well, the timer itself is actually a packet, but you can use his code for implementation in the packet.
Declare this:
Then, in your combat method, when you get hit add:Code:/** * The last time that the player was hit in combat. */ public long lastHitTime;
Then in your logout method, at the top, add:Code:lastHitTime = System.currentTimeMillis();
That will make it so that you cannot log out without being out of combat for 10 seconds.Code:if (System.currentTimeMillis() - lastHitTime < 10000) { sendMessage("You must be out of combat for 10 seconds to log out."); return; }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |