Thread: [OSRS] Deadman mode logout timer [Kronos]

Results 1 to 3 of 3
  1. #1 [OSRS] Deadman mode logout timer [Kronos] 
    Registered Member
    Join Date
    Feb 2021
    Posts
    115
    Thanks given
    31
    Thanks received
    8
    Rep Power
    62
    ---------------------------------------------

    Looking to add a timer to using the logout button in-game (deadman mode mechanic)

    this will prevent players from instantly being able to logout - instead they will have to wait approximately 10 seconds countdown before the logout button will remove them from game ( this countdown timer can be interrupted by combat from another player/npc! )

    Using the base code from spawning animated armor in warrior's guild for this, so including that here
    Spoiler for Spawn animated armor in Warriors' Guild:

    Code:
    private void spawn(Player player, GameObject gameObject) {
            if(player.npcTarget) {
                player.sendMessage("You are already under attack!");
                return;
            }
            ArrayList<Item> items = player.getInventory().collectOneOfEach(armorIds);
            if(items == null) {
                player.sendMessage("To animate this armor, you'll need a full helm, platebody, and pair of platelegs.");
                return;
            }
            player.startEvent(event -> {
                player.lock();
                player.dialogue(new MessageDialogue("You place your armour on the platform where it disappears...").hideContinue());
                event.delay(1);
                player.animate(827);
                event.delay(3);
                for(Item armor : items)
                    armor.remove();
                event.delay(2);
                player.dialogue(new MessageDialogue("The animator hums, something appears to be working. You stand back...").hideContinue().lineHeight(31));
                event.delay(2);
                player.getMovement().force(0, 2, 0, 0, 45, 126, Direction.SOUTH);
                event.delay(1);
                player.animate(820, 5);
                event.delay(3);
                NPC npc = new NPC(npcId)
                        .spawn(gameObject.x, gameObject.y, 0, Direction.SOUTH, 0)
                        .targetPlayer(player, true);
                npc.forceText("I'M ALIVE!");
                npc.animate(4166, 1);
                event.delay(2);
                npc.attackTargetPlayer(() -> !player.getPosition().inBounds(ATTACK_BOUNDS), () -> {
                    if(npc.getCombat().isDead())
                        new GroundItem(8851, tokenCount).owner(player).position(npc.getPosition()).spawn();
                    for(int id : armorIds)
                        new GroundItem(id, 1).owner(player).position(npc.getPosition()).spawn();
                });
                player.closeInterface(InterfaceType.CHATBOX);
                player.unlock();
            });
        }




    this is as far as I have got with the code so far:

    Spoiler for 1st revision:

    Code:
    public void attemptLogout() {
            if (combat.isDead() || combat.isDefending(16)) { //TODO 16 (9.6) or 17 (10.2) ?
                sendMessage("You can't log out until 10 seconds after the end of combat.");
                return;
            }
            if (supplyChestRestricted) {
                sendMessage("The power of the supply chest prevents you from logging out!");
                return;
            }
            if (isLockedExclude(LockType.FULL_ALLOW_LOGOUT) && player.getAppearance().getNpcId() == -1)
                return;
            if (logoutListener != null && logoutListener.attemptAction != null && !logoutListener.attemptAction.allow(this))
                return;
    
    
            // TODO
            player.startEvent(event -> {
            player.sendMessage("Trying to escape? You must wait 10 seconds before logging out.");
            event.delay(16);
            if (player.getCombat().isDefending(16)) {
                logoutStage = 0;
            } else {
                logoutStage = 1;
            }
             //0=no logout, 1=logout required, -1=logout accepted
             //logoutStage = 1;
            packetSender.sendDiscordPresence("In Lobby");
            packetSender.sendLogout();
            });
        }



    Spoiler for 2nd revision:

    Code:
        public void attemptLogout() {
            if(combat.isDead() || combat.isDefending(16)) { //TODO 16 (9.6) or 17 (10.2) ?
                sendMessage("You can't log out until 10 seconds after the end of combat.");
                return;
            }
            if(supplyChestRestricted) {
                sendMessage("The power of the supply chest prevents you from logging out!");
                return;
            }
            if(isLockedExclude(LockType.FULL_ALLOW_LOGOUT) && player.getAppearance().getNpcId() == -1)
                return;
            if(logoutListener != null && logoutListener.attemptAction != null && !logoutListener.attemptAction.allow(this))
                return;
    
    
            player.startEvent(event -> {
                player.sendMessage("Running away? Not so fast!"); //There are X seconds remaining until you can logout...
                sendMessage("There are 7 seconds remaining until you can logout...");
    
    
                event.delay(2); // 6.0
                sendMessage("There are 6 seconds remaining until you can logout...");
    
    
                event.delay(2); // 4.8
                sendMessage("There are 5 seconds remaining until you can logout...");
    
    
                event.delay(2); // 3.6
                sendMessage("There are 4 seconds remaining until you can logout...");
    
    
                event.delay(2); // 2.4
                sendMessage("There are 3 seconds remaining until you can logout...");
    
    
                event.delay(2); // 1.2
                sendMessage("There are 2 seconds remaining until you can logout...");
    
    
                event.delay(2); // 0
                sendMessage("There is 1 second remaining until you can logout...");
                if (player.getCombat().isDefending(16)) {
                    logoutStage = 0;
                }
                else {
                    logoutStage = 1;
                    packetSender.sendDiscordPresence("In Lobby");
                    packetSender.sendLogout();
                }
            });
    
    
        }


    Last edited by Monomoy; 11-07-2022 at 09:23 PM.
    Reply With Quote  
     

  2. #2  
    Retired From RSPS

    iGarrett's Avatar
    Join Date
    Dec 2013
    Posts
    461
    Thanks given
    144
    Thanks received
    110
    Rep Power
    187
    I'm not sure how Kronos is but we did this back when i did work for some Project Insanity servers and it might be useful or put you in the correct direction.

    You could send a dialogue in the timer itself to start the countdown when called upon

    Code:
     public void runTimer(){
            int i = 10; //Time In Seconds
             while (i>0){
              c.getDH().sendDialogue( "You can not logout!', "You can not logout for" +i+ "Seconds!", null);
              try {
                i--;
                Thread.sleep(1000L);    // 1000L = 1000ms = 1 second
               }
               catch (InterruptedException e) {
               }
             }
        }
    }
    Then where you call your denyLogout() method you could call in that bit of code and it *should* work?
    As i said it has been a while but i hope i helped you in the correct direction.
    Quote Originally Posted by i am here View Post
    I have never messed with Eclipse. Is it a whole new revision or type of code?
    Quote Originally Posted by bibl View Post
    hahaha, good one m9. "deob" is short for "deobfuscated" which is not the same as decompiled.
    I'm GEEGIN' OUT
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member x's Avatar
    Join Date
    May 2019
    Posts
    195
    Thanks given
    61
    Thanks received
    54
    Rep Power
    63
    Quote Originally Posted by iGarrett View Post
    I'm not sure how Kronos is but we did this back when i did work for some Project Insanity servers and it might be useful or put you in the correct direction.

    You could send a dialogue in the timer itself to start the countdown when called upon

    Code:
     public void runTimer(){
            int i = 10; //Time In Seconds
             while (i>0){
              c.getDH().sendDialogue( "You can not logout!', "You can not logout for" +i+ "Seconds!", null);
              try {
                i--;
                Thread.sleep(1000L);    // 1000L = 1000ms = 1 second
               }
               catch (InterruptedException e) {
               }
             }
        }
    }
    Then where you call your denyLogout() method you could call in that bit of code and it *should* work?
    As i said it has been a while but i hope i helped you in the correct direction.
    would avoid using thread.sleep, it renders that specific thread unusable. This should only be used in small cases, my suggestion would be to use an eventcycle and inside of the event itself use your "senddialogue" method to send the message and then in the stop portion of the event do the teleport/logout code, also make sure you do stop checks for things like teleblock and getting attacked by other players. (put those stop checks obviously in the event)
    ▼▼▼ Click to checkout DarkScape a World PvP server in the works! ▼▼▼
    Attached image
    Reply With Quote  
     

  5. Thankful users:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 26
    Last Post: 07-07-2021, 06:54 PM
  2. Replies: 17
    Last Post: 03-28-2021, 03:58 PM
  3. [OSRS] Deadman Mode - Coming soon
    By Lurk in forum Projects
    Replies: 34
    Last Post: 09-26-2016, 06:17 PM
  4. Replies: 100
    Last Post: 07-10-2016, 12:51 PM
  5. OSRS: Deadman mode Season 2 team
    By hxze in forum Old School RS (2007)
    Replies: 21
    Last Post: 06-26-2016, 05:13 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •