From 13e4a0b6408df693b4b02b8096e7d54f0f226221 Mon Sep 17 00:00:00 2001 From: randy Date: Sat, 9 Nov 2024 09:08:05 -0700 Subject: [PATCH] Added code to customize logout timer. Set to 1 hour. --- .../main/core/net/packet/PacketProcessor.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Server/src/main/core/net/packet/PacketProcessor.kt b/Server/src/main/core/net/packet/PacketProcessor.kt index 51e4324e9..875d3693f 100644 --- a/Server/src/main/core/net/packet/PacketProcessor.kt +++ b/Server/src/main/core/net/packet/PacketProcessor.kt @@ -307,8 +307,24 @@ object PacketProcessor { pkt.player.interfaceManager.switchWindowMode(pkt.windowMode) } is Packet.TrackingAfkTimeout -> { - //if (pkt.player.details.rights != Rights.ADMINISTRATOR) - //pkt.player.packetDispatch.sendLogout() + /* After 5 minutes idle, the client sends an afk packet every 10 seconds. + *This code counts the number of afk packets recieved, resetting the count if they are more than 100 ticks apart. + *This allows us to customize the afk logout timer + */ + if (pkt.player.details.rights != Rights.ADMINISTRATOR) { + if (GameWorld.ticks - pkt.player.getAttribute("afk:lasttick", 0) > 100) { + pkt.player.setAttribute("afk:count", 0) + } else { + pkt.player.setAttribute("afk:count", pkt.player.getAttribute("afk:count", 0) + 1) + } + pkt.player.setAttribute("afk:lasttick", GameWorld.ticks) + if (pkt.player.getAttribute("afk:count", 0) == 300) { + pkt.player.sendMessage("You have been idle for 55 minutes and will be logged out soon.") + } + if (pkt.player.getAttribute("afk:count", 0) >= 330) { + pkt.player.packetDispatch.sendLogout() + } + } } is Packet.TrackingCameraPos -> { //TODO Refactor the player monitor to be actually useful and log this