• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Kick Idle Player

xanter1123

New Member
Joined
Jan 23, 2009
Messages
13
Reaction score
1
Hello, i got compiled my own server for privite use (friends etc), and wanted to config that to not kick idle players.
I changed value in config
Code:
kickIdlePlayerAfterMinutes = 15
for 999999 and it kicked same time when they logged in.
Tried to delete that line from config, still doesnt work.
Any idea how it can be done ?.

TFS 1.2
 
Code Fragment
Code:
    if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) {
        idleTime += interval;
        const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES);
        if (idleTime > (kickAfterMinutes * 60000) + 60000) {
            kickPlayer(true);
        } else if (client && idleTime == 60000 * kickAfterMinutes) {
            std::ostringstream ss;
            ss << "You have been idle for " << kickAfterMinutes << " minutes. You will be disconnected in one minute if you are still idle then.";
            client->sendTextMessage(TextMessage(MESSAGE_STATUS_WARNING, ss.str()));
        }
    }

What this code fragment states is
Code:
const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES);
and
Code:
kickIdlePlayerAfterMinutes
Are equivalent,

If we look at the formula when the player is kicked
Code:
(kickAfterMinutes * 60000) + 60000
Replacing kickAfterMinutes with 15, since this is the setting in config.lua
Code:
(15 * 60000) + 60000

15 * 60,000 = 15 minutes, + 60,000 = 16 minutes

Now if you delete the value in config, when the server runs a check it will immediately send the warning and kick the player in 1 minute thereafter, because anything times 0 equals 0.

https://github.com/otland/forgotten...effd207fdde3a1b7d9/src/player.cpp#L1549-L1559
 
Have you tried
Code:
kickIdlePlayerAfterMinutes = 9999

which avoids integer overflow?

9999 minutes should be just short of a week. If you need longer you might try

Code:
kickIdlePlayerAfterMinutes = 35000
Which should give about 24 days. If you really need it to be infinite you might just have to edit the source code and recompile.
 
Have you tried
Code:
kickIdlePlayerAfterMinutes = 9999

which avoids integer overflow?

9999 minutes should be just short of a week. If you need longer you might try

Code:
kickIdlePlayerAfterMinutes = 35000
Which should give about 24 days. If you really need it to be infinite you might just have to edit the source code and recompile.
Since kickIdlePlayerAfterMinutes is used as a mutiplier, and idleTime is an int32_t, it can only count up to 2,147,483,647.

The maximum time you can set it to is 35790 (35791 - 1 for the additional minute added) (2,147,483,647 / 60,000, since its an int the decimal value is truncated) which is roughly about 3 and a half weeks.

http://convertwizard.com/35791-minutes-to-hours
 
Last edited:
Have you tried
Code:
kickIdlePlayerAfterMinutes = 9999

which avoids integer overflow?

9999 minutes should be just short of a week. If you need longer you might try

Code:
kickIdlePlayerAfterMinutes = 35000
Which should give about 24 days. If you really need it to be infinite you might just have to edit the source code and recompile.

i have changed values in first
Code:
kickIdlePlayerAfterMinutes = 3600
and go that kick problem(kicked after few sec).
But im blind as duck, couldnt find this lane in code, after few change in data got it to work.
Thanks for respond guys and for open my eyes :).
 
Back
Top