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

GlobalEvent [TFS1.3] Kick player after x log or disconnected check 5 min

Gicu

Well-Known Member
Joined
Feb 26, 2011
Messages
187
Reaction score
52
data/globalevents/globalevents.xml
Code:
<globalevent name="Kick Check 5min" interval="300000" script="kick.lua"/>
data/globalevents/kick.lua
Code:
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 then
print(nameP, ip) -- write name and Ip player was kicked
    player:remove()
    end
end
    return true
end

If something is wrong fix me :)
 
@gicu0770
Good to put a check skull to avoid abuse

If i kill a player i can "exit" and caracter will logoff

for me this script is a good way to avoid people afk on trainers, any chance to get this working that way?

I see there could be 3 options to optimize in that way:
  • check if player is in No-Pvp area and if true, start checking player status with onThink
  • do it as a moveevent, that trigger the onThink function if player is step on a tile with AID/UID
  • do the skull check by using player:getSkull(SKULL_NONE)
someone can help me and suggest me which one of the three ways i could make this done? Or maybe leave a code with it :rolleyes:
something like this could work?
Lua:
if player:getIp() == 0 and player:getSkull(SKULL_NONE)
 
Last edited:
bump… @gicu0770, @roriscrave, @theduck how can avoid being kicked if player is skulled, and also, if is on noLogout tiles?
please help! thanks in advance...

Try this bro
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 not Tile(player:getPosition()):hasFlag(TILESTATE_NOLOGOUT) then
                print(nameP, ip) -- write name and Ip player was kicked
                player:remove()
            end
        end
            return true
    end
 
Back
Top