• 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!

TFS 0.X Players staying online at training area - IP 0.0.0.0

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,403
Solutions
17
Reaction score
151
Location
Brazil
Hello guys, how are you? I dont know why, but recently, players are quitting game and staying online (just getting hitted by trainer, dont hit and not conjure spell), the area its not preventing to log-out. There's a way to prevent this? Here's my idle.lua

Lua:
local config = {
    idleWarning = getConfigValue('idleWarningTime'),
    idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
    if(getTileInfo(getCreaturePosition(cid)).noLogout or getCreatureNoMove(cid) or
        getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) then
        return true
    end

    local idleTime = getPlayerIdleTime(cid) + interval
    doPlayerSetIdleTime(cid, idleTime)
    if(config.idleKick > 0 and idleTime > config.idleKick) then
        doRemoveCreature(cid)
    elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
        local message = "There was no variation in your behaviour for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
        if(config.idleKick > 0) then
            message = message .. ". You will be disconnected in "
            local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
            if(diff > 1) then
                message = message .. diff .. " minutes"
            else
                message = message .. "one minute"
            end

            message = message .. " if there is no change in your actions until then."
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
    end

    return true
end
 
Hello guys, how are you? I dont know why, but recently, players are quitting game and staying online (just getting hitted by trainer, dont hit and not conjure spell), the area its not preventing to log-out. There's a way to prevent this? Here's my idle.lua

Lua:
local config = {
    idleWarning = getConfigValue('idleWarningTime'),
    idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
    if(getTileInfo(getCreaturePosition(cid)).noLogout or getCreatureNoMove(cid) or
        getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) then
        return true
    end

    local idleTime = getPlayerIdleTime(cid) + interval
    doPlayerSetIdleTime(cid, idleTime)
    if(config.idleKick > 0 and idleTime > config.idleKick) then
        doRemoveCreature(cid)
    elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
        local message = "There was no variation in your behaviour for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
        if(config.idleKick > 0) then
            message = message .. ". You will be disconnected in "
            local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
            if(diff > 1) then
                message = message .. diff .. " minutes"
            else
                message = message .. "one minute"
            end

            message = message .. " if there is no change in your actions until then."
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
    end

    return true
end
They stay online cuz Player::canLogout() function in player.cpp make it impossible if they have CONDITION_INFIGHT
void Player::sendPing() call this function and if player ping no response its gonna try to logout them, if you want to change that you need to edit this canLogout func or sendping func, just make sure you do not let players with skulls just exit game to logout.
 
They stay online cuz Player::canLogout() function in player.cpp make it impossible if they have CONDITION_INFIGHT
void Player::sendPing() call this function and if player ping no response its gonna try to logout them, if you want to change that you need to edit this canLogout func or sendping func, just make sure you do not let players with skulls just exit game to logout.
I managed to solve this problem (thanks @Roddet ), what happened: I used the flag for the player to be able to report bugs using CTRL + Z. This caused the player to have an anti idle flag. I removed the flag from the player and now they log out normally, the problem is that they can no longer report bugs using CTRL + Z.

I take a look into sources to see anything, but i not find a permission issue (i want all players can report bug), there's some funcions:

protocolgame.cpp
C++:
void ProtocolGame::parseBugReport(NetworkMessage& msg)
{
    std::string comment = msg.getString();
    addGameTaskWithPlayer(player->getName(), &Game::playerReportBug, player->getID(), comment);
}

game.cpp
C++:
bool Game::playerReportBug(uint32_t playerId, std::string comment)
{
    Player* player = getPlayerByID(playerId);
    if(!player || player->isRemoved())
        return false;

    if(!player->hasFlag(PlayerFlag_CanReportBugs))
        return false;

    CreatureEventList reportBugEvents = player->getCreatureEvents(CREATURE_EVENT_REPORTBUG);
    for(CreatureEventList::iterator it = reportBugEvents.begin(); it != reportBugEvents.end(); ++it)
        (*it)->executeReportBug(player, comment);

    return true;
}

C++:
uint32_t CreatureEvent::executeReportBug(Player* player, const std::string& comment)
{
    //onReportBug(cid, comment)
    if(m_interface->reserveEnv())
    {
        ScriptEnviroment* env = m_interface->getEnv();
        if(m_scripted == EVENT_SCRIPT_BUFFER)
        {
            env->setRealPos(player->getPosition());
            std::stringstream scriptstream;

            scriptstream << "local cid = " << env->addThing(player) << std::endl;
            scriptstream << "local comment = " << comment << std::endl;

            if(m_scriptData)
                scriptstream << *m_scriptData;

            bool result = true;
            if(m_interface->loadBuffer(scriptstream.str()))
            {
                lua_State* L = m_interface->getState();
                result = m_interface->getGlobalBool(L, "_result", true);
            }

            m_interface->releaseEnv();
            return result;
        }
        else
        {
            #ifdef [B]DEBUG_LUASCRIPTS[/B]
            char desc[35];
            sprintf(desc, "%s", player->getName().c_str());
            env->setEvent(desc);
            #endif

            env->setScriptId(m_scriptId, m_interface);
            env->setRealPos(player->getPosition());

            lua_State* L = m_interface->getState();
            m_interface->pushFunction(m_scriptId);

            lua_pushnumber(L, env->addThing(player));
            lua_pushstring(L, comment.c_str());

            bool result = m_interface->callFunction(2);
            m_interface->releaseEnv();
            return result;
        }
    }
    else
    {
        std::clog << "[Error - CreatureEvent::executeReportBug] Call stack overflow." << std::endl;
        return 0;
    }
}
[/code

I was set up this flag for players: 17592186044416
 
Back
Top