• 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 1.X+ How can I kick IP: 0.0.0.0.

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
461
Solutions
11
Reaction score
340
Location
gamelaot.sytes.net
If the player logs out using (Exit), the IP changes to 0.0.0.0. How can I kick this IP automatically after 5 seconds?
Tfs 1.2

23:05 You see Marko (Level 717). He is a druid.
Health: 3715 / 3735, Mana: 910 / 21310.
Position: 3088, 3046, 7
IP: 0.0.0.0.
He has killed: [27] Player
He has died: [45] Times

Damage Character [+%-1].
He has a bounty of -1 gold coins.
 
onLogout creaturescript and from there you remove a player. If onLogout isn't triggered by exit, then you must go to sources and make edits there. Dont use this - Game.getOnlinePlayer().
 
go to globalevents/scripts and create exitlogout.lua and add
Lua:
    function onThink(interval, lastExecution)
        for _, player in pairs(Game.getPlayers()) do
            if not player then
                return false
            end
        local ip = Game.convertIpToString(player:getIp())
        local nameP = player:getName()
            if player:getIp() == 0 and player:getSkull() == SKULL_NONE and Tile(player:getPosition()):hasFlag(TILESTATE_NOLOGOUT) then
                print(nameP, ip) -- write name and Ip player was kicked
                player:remove()
            end
        end
            return true
    end

then add this on globalevents.xml
XML:
<globalevent name="Exit Logout" interval="60000" script="exitlogout.lua"/>

tell me how it goes!
Regards :)
 
tell me how it goes!
I added that script and it does not work and there are no errors
To make sure of that I did interval="5000"
Maybe theres a better way idk my brain is currently 90% dedek
Once im home I can help u if no one did
Thank you man, I think I will wait for you xD
onLogout creaturescript and from there you remove a player. If onLogout isn't triggered by exit, then you must go to sources and make edits there. Dont use this - Game.getOnlinePlayer().
Thank you but why not use Game.getOnlinePlayer().
I think this would be simple
If you have a better solution than the source, let me know
 
try.

globalevents.
Lua:
function onThink(interval, lastExecution)
    local players = Game.getPlayers()
    for _, player in ipairs(players) do
        if player:getIp() == "0.0.0.0" then
            player:sendCancelMessage("You have been disconnected from the server.")
            player:remove()
        end
    end
    return true
end
 
Last edited:

Check here if hasLostConnection is true, that means the player character is in game but the actual player is no longer connected, either because they lost internet connection or simply used Exit while in fight for example.
Personally I created new event that is triggered by this, actually helpful.
C++:
    if (hasLostConnection) {
        g_events->eventPlayerOnLostConnection(this);
    }
 
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/exitlogout.lua:eek:nThink
data/globalevents/scripts/exitlogout.lua:2: attempt to call field 'getOnlinePlayers' (a nil value)
stack traceback:
[C]: in function 'getOnlinePlayers'
data/globalevents/scripts/exitlogout.lua:2: in function <data/globalevents/scripts/exitlogout.lua:1>
[Error - GlobalEvents::think] Failed to execute event: Exit Logout
 
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/exitlogout.lua:eek:nThink
data/globalevents/scripts/exitlogout.lua:2: attempt to call field 'getOnlinePlayers' (a nil value)
stack traceback:
[C]: in function 'getOnlinePlayers'
data/globalevents/scripts/exitlogout.lua:2: in function <data/globalevents/scripts/exitlogout.lua:1>
[Error - GlobalEvents::think] Failed to execute event: Exit Logout
I updated the post. Take a look. I think what Oen posted is a better solution.
 
I updated the post. Take a look. I think what Oen posted is a better solution.
It doesn't work and there is no error Thank you for the help
Sometime my brain turns off for real i should stop with lua
Do whatever you want. Thank you for trying to help me
Check here if hasLostConnection is true, that means the player character is in game but the actual player is no longer connected, either because they lost internet connection or simply used Exit while in fight for example.
Personally I created new event that is triggered by this, actually helpful.
In fact, my mind is a little off and I didn't understand you well
I searched for hasLostConnection This is what I found
C++:
void Player::sendPing()
{
    int64_t timeNow = OTSYS_TIME();

    bool hasLostConnection = false;
    if ((timeNow - lastPing) >= 5000) {
        lastPing = timeNow;
        if (client) {
            client->sendPing();
        } else {
            hasLostConnection = true;
            if (g_config.getBoolean(ConfigManager::STOP_ATTACK_AT_EXIT)) {
                setAttackedCreature(nullptr);
            }
        }
    }

    int64_t noPongTime = timeNow - lastPong;
    if ((hasLostConnection || noPongTime >= 7000) && attackedCreature && attackedCreature->getPlayer()) {
        if (g_config.getBoolean(ConfigManager::STOP_ATTACK_AT_EXIT)) {
        setAttackedCreature(nullptr);
        }
    }

    if (noPongTime >= 60000 && canLogout()) {
        if (g_creatureEvents->playerLogout(this)) {
            if (client) {
                client->logout(true, true);
            } else {
                g_game.removeCreature(this, true);
                g_game.addMagicEffect(getPosition(), CONST_ME_POFF);
            }
        }
    }
    if (canLogout() && !hasCondition(CONDITION_INFIGHT) && !client) {
        g_game.removeCreature(this, true);
        g_game.addMagicEffect(getPosition(), CONST_ME_POFF);
    }

}
Where do I add your code?
 
Back
Top