void Player::setNextActionTask(SchedulerTask* task, bool resetIdleTime /*= true */)
{
if (actionTaskEvent != 0) {
g_scheduler.stopEvent(actionTaskEvent);
actionTaskEvent = 0;
}
if (task) {
actionTaskEvent = g_scheduler.addEvent(task);
if (resetIdleTime) {
this->resetIdleTime();
}
}
}
uint32_t Player::getNextActionTime() const
{
return std::max<int64_t>(SCHEDULER_MINTICKS, nextAction - OTSYS_TIME());
}
void Player::onThink(uint32_t interval)
{
Creature::onThink(interval);
sendPing();
MessageBufferTicks += interval;
if (MessageBufferTicks >= 1500) {
MessageBufferTicks = 0;
addMessageBuffer();
}
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) {
client->sendTextMessage(TextMessage(MESSAGE_STATUS_WARNING, fmt::format("There was no variation in your behaviour for {:d} minutes. You will be disconnected in one minute if there is no change in your actions until then.", kickAfterMinutes)));
}
}
if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
checkSkullTicks(interval / 1000);
}
/*addOfflineTrainingTime(interval);
if (lastStatsTrainingTime != getOfflineTrainingTime() / 60 / 1000) {
sendStats();
}*/
}