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

Idle.lua problems

vzoreid

Member
Joined
Jun 16, 2014
Messages
61
Reaction score
21
Hello
i need help with the idle.lua script since it wont kick AFK players who are in trainers with their client closed. If someone can handle me a working idle script i would appreciate it alot. this is the idle.lua script im using right now but its all messed up i think =S , i hope someone can help me out here =) thanks!.

Code:
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 = "You have been idle 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 you are still idle"
        end

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

    return true
end
 
Last edited by a moderator:
i just tryed that out but didn't work out well...it still doesn't kick afk players.I have no idea on how to fix this =S thanks anyway!
Also i set the idlekicktime to 15 mins in the config.lua and removed all NoLogOut zones and still it wont work.
 
mm im not sure if i added it correctly D: here are my creaturescripts.xml and login.lua

Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
   <event type="login" name="PlayerLogin" event="script" value="login.lua"/>

   <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
   <event type="receivemail" name="Mail" event="script" value="mail.lua"/>
   <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
   <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
   <event type="think" name="Idle" event="script" value="idle.lua"/>
   <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
   <event type="login" name="Hi!" script="loginserver.lua"/>
   <event type="death" name="inquisitionPortals" script="teleports_inquisition.lua"/>

</creaturescripts>

Code:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000
function onLogin(cid)
    if(InitShopComunication == 0) then
        local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
        InitShopComunication = eventServ
    end
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "Ushuriel")
    registerCreatureEvent(cid, "Zugurosh")
    registerCreatureEvent(cid, "Madareth")
    registerCreatureEvent(cid, "Golgordan")
    registerCreatureEvent(cid, "Annihilon")
    registerCreatureEvent(cid, "Hellgorak")
        registerCreatureEvent(cid, "idle")
    return TRUE
end
Code:
function sql_communication(parameters)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getPlayerByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
               local received_item = 0
               local full_weight = 0
               if add_item_type == 'container' then
                   container_weight = getItemWeightById(container_id, 1)
                    if isItemRune(itemtogive_id) == TRUE then
                        items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                   full_weight = items_weight + container_weight
               else
                   full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    if isItemRune(itemtogive_id) == TRUE then
                        full_weight = getItemWeightById(itemtogive_id, 1)
                    else
                        full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    end
               end
               local free_cap = getPlayerFreeCap(cid)
               if full_weight <= free_cap then
                   if add_item_type == 'container' then
                       local new_container = doCreateItemEx(container_id, 1)
                       local iter = 0
                       while iter ~= container_count do
                           doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                           iter = iter + 1
                       end
                       received_item = doPlayerAddItemEx(cid, new_container)
                   else
                       local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                       received_item = doPlayerAddItemEx(cid, new_item)
                   end
                   if received_item == RETURNVALUE_NOERROR then
                       doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                       db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                   else
                       doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                   end
               else
                   doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
               end
           end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
end
 
Last edited by a moderator:
i use Alissow Server, version 0.4.1 (Alissow) and this is my config.lua:
Code:
-- The Thyrania Server Config

    -- Account manager
    accountManager = true
    namelockManager = true
    newPlayerChooseVoc = true
    newPlayerSpawnPosX = 1599
    newPlayerSpawnPosY = 1597
    newPlayerSpawnPosZ = 6
    newPlayerTownId = 1
    newPlayerLevel = 8
    newPlayerMagicLevel = 2
    generateAccountNumber = false

    -- Unjustified kills
    -- NOTE: *Banishment and *BlackSkull variables are >summed up<
    -- (dailyFragsToRedSkull + dailyFragsToBanishment) with their
    -- *RedSkull equivalents.
    -- Auto banishing works only if useBlackSkull set to negative.
    -- advancedFragList is not advised if you use huge frags
    -- requirements.
    redSkullLength = 1 * 24 * 60 * 60
    blackSkullLength = 3 * 24 * 60 * 60
    dailyFragsToRedSkull = 10
    weeklyFragsToRedSkull = 20
    monthlyFragsToRedSkull = 30
    dailyFragsToBlackSkull = dailyFragsToRedSkull
    weeklyFragsToBlackSkull = weeklyFragsToRedSkull
    monthlyFragsToBlackSkull = monthlyFragsToRedSkull
    dailyFragsToBanishment = dailyFragsToRedSkull
    weeklyFragsToBanishment = weeklyFragsToRedSkull
    monthlyFragsToBanishment = monthlyFragsToRedSkull
    blackSkulledDeathHealth = 40
    blackSkulledDeathMana = 0
    useBlackSkull = faLse
    useFragHandler = true
    advancedFragList = false

    -- Banishments
    -- violationNameReportActionType 1 = just a report, 2 = name lock, 3 = player banishment
    -- killsBanLength works only if useBlackSkull option is disabled.
    notationsToBan = 3
    warningsToFinalBan = 4
    warningsToDeletion = 5
    banLength = 7 * 24 * 60 * 60
    killsBanLength = 7 * 24 * 60 * 60
    finalBanLength = 30 * 24 * 60 * 60
    ipBanishmentLength = 1 * 24 * 60 * 60
    broadcastBanishments = true
    maxViolationCommentSize = 200
    violationNameReportActionType = 2
    autoBanishUnknownBytes = false

    -- Battle
    -- NOTE: showHealingDamageForMonsters inheritates from showHealingDamage.
    -- loginProtectionPeriod is the famous Tibia anti-magebomb system.
    -- deathLostPercent set to nil enables manual mode.
    worldType = "pvp"
    protectionLevel = 20
    pvpTileIgnoreLevelAndVocationProtection = true
    pzLocked = 1 * 60 * 1000
    huntingDuration = 60 * 1000
    criticalHitChance = 7
    criticalHitMultiplier = 1
    displayCriticalHitNotify = false
    removeWeaponAmmunition = false
    removeWeaponCharges = false
    removeRuneCharges = true
    whiteSkullTime = 7 * 60 * 1000
    noDamageToSameLookfeet = false
    showHealingDamage = false
    showHealingDamageForMonsters = false
    fieldOwnershipDuration = 5 * 1000
    stopAttackingAtExit = true
    oldConditionAccuracy = false
    loginProtectionPeriod = 10 * 1000
    deathLostPercent = 10
    stairhopDelay = 1 * 800
    pushCreatureDelay = 1 * 800
    deathContainerId = 1987
    gainExperienceColor = 215
    addManaSpentInPvPZone = true
    squareColor = 0
    allowFightback = true

    -- Connection config
    worldId = 0
    ip = "destynaonline.no-ip.org"
    bindOnlyConfiguredIpAddress = false
    loginPort = 7171
    gamePort = 7172
    adminPort = 7171
    statusPort = 7171
    loginTries = 10
    retryTimeout = 5 * 1000
    loginTimeout = 60 * 1000
    maxPlayers = 100
    motd = "Bienvenido a Eternia"
    displayOnOrOffAtCharlist = false
    onePlayerOnlinePerAccount = true
    allowClones = false
    serverName = "Eternia Online"
    loginMessage = "Bienvenido a Eternia Evolution!"
    statusTimeout = 5 * 60 * 1000
    replaceKickOnLogin = true
    forceSlowConnectionsToDisconnect = false
    loginOnlyWithLoginServer = false
    premiumPlayerSkipWaitList = true

    -- Deathlist
    deathListEnabled = true
    deathListRequiredTime = 1 * 60 * 1000
    deathAssistCount = 19
    maxDeathRecords = 5

    -- Guilds
    ingameGuildManagement = true
    levelToFormGuild = 20
    premiumDaysToFormGuild = 0
    guildNameMinLength = 4
    guildNameMaxLength = 20

    -- Highscores
    highscoreDisplayPlayers = 15
    updateHighscoresAfterMinutes = 1

    -- Houses
    buyableAndSellableHouses = true
    houseNeedPremium = true
    bedsRequirePremium = true
    levelToBuyHouse = 50
    housesPerAccount = 0
    houseRentAsPrice = false
    housePriceAsRent = false
    housePriceEachSquare = 1000
    houseRentPeriod = "never"
    houseCleanOld = 0
    guildHalls = false

    -- Item usage
    timeBetweenActions = 200
    timeBetweenExActions = 1000
    checkCorpseOwner = true
    hotkeyAimbotEnabled = true
    maximumDoorLevel = 500

    -- Map
    -- NOTE: storeTrash costs more memory, but will perform alot faster cleaning.
    -- useHouseDataStorage usage may be found at README.
    mapName = "Evolutions"
    mapAuthor = "Universal"
    randomizeTiles = true
    useHouseDataStorage = false
    storeTrash = true
    cleanProtectedZones = true
    mailboxDisabledTowns = "-1"

    -- Startup
    -- NOTE: defaultPriority works only on Windows and niceLevel on *nix
    -- coresUsed are seperated by comma cores ids used by server process,
    -- default is -1, so it stays untouched (automaticaly assigned by OS).
    defaultPriority = "high"
    niceLevel = 5
    coresUsed = "-1"
    optimizeDatabaseAtStartup = true
    removePremiumOnInit = true
    confirmOutdatedVersion = false

    -- Muted buffer
    maxMessageBuffer = 999
    bufferMutedOnSpellFailure = false

    -- Miscellaneous
    -- NOTE: promptExceptionTracerErrorBox works only with precompiled support feature,
    -- called "exception tracer" (__EXCEPTION_TRACER__ flag).
    -- monsterLootMessage 0 to disable, 1 - only party, 2 - only player, 3 - party or player (like Tibia's)
    dataDirectory = "data/"
    allowChangeOutfit = true
    allowChangeColors = true
    allowChangeAddons = true
    disableOutfitsForPrivilegedPlayers = false
    bankSystem = true
    saveGlobalStorage = true
    displaySkillLevelOnAdvance = false
    spellNameInsteadOfWords = false
    emoteSpells = true
    promptExceptionTracerErrorBox = true
    storePlayerDirection = false
    monsterLootMessage = 3
    monsterLootMessageType = 25
    separateViplistPerCharacter = false

    -- Ghost mode
    ghostModeInvisibleEffect = false
    ghostModeSpellEffects = true

    -- Limits
    idleWarningTime = 14 * 60 * 1000
    idleKickTime = 15 * 60 * 1000
    expireReportsAfterReads = 1
    playerQueryDeepness = 2
    maxItemsPerPZTile = 0
    maxItemsPerHouseTile = 0

    -- Premium-related
    freePremium = true
    premiumForPromotion = true

    -- Blessings
    -- NOTE: blessingReduction* regards items/containers loss.
    -- eachBlessReduction is how much each bless reduces the experience/magic/skills loss.
    blessingOnlyPremium = true
    blessingReductionBase = 30
    blessingReductionDecreament = 5
    eachBlessReduction = 8

    -- Rates
    -- NOTE: experienceStages configuration is located in data/XML/stages.xml.
    -- rateExperienceFromPlayers 0 to disable.
    experienceStages = true
    rateExperience = 30.0
    rateExperienceFromPlayers = 2
    rateSkill = 30.0
    rateMagic = 10.0
    rateLoot = 4.0
    rateSpawn = 1

    -- Monster rates
    rateMonsterHealth = 1.0
    rateMonsterMana = 1.0
    rateMonsterAttack = 1.0
    rateMonsterDefense = 1.0

    -- Experience from players
    -- NOTE: min~Threshold* set to 0 will disable the minimum threshold:
    -- player will gain experience from every lower leveled player.
    -- max~Threshold* set to 0 will disable the maximum threshold:
    -- player will gain experience from every higher leveled player.
    minLevelThresholdForKilledPlayer = 0.9
    maxLevelThresholdForKilledPlayer = 1.1

    -- Stamina
    -- NOTE: Stamina is stored in miliseconds, so seconds are multiplied by 1000.
    -- rateStaminaHits multiplies every hit done a creature, which are later
    -- multiplied by player attack speed.
    -- rateStaminaGain is divider of every logged out second, eg:
    -- 60000 / 3 = 20000 milliseconds, what gives 20 stamina seconds for 1 minute being logged off.
    -- rateStaminaThresholdGain is divider for the premium stamina.
    -- staminaRatingLimit* is in minutes.
    rateStaminaLoss = 1
    rateStaminaGain = 3
    rateStaminaThresholdGain = 12
    staminaRatingLimitTop = 41 * 60
    staminaRatingLimitBottom = 14 * 60
    rateStaminaAboveNormal = 1.5
    rateStaminaUnderNormal = 0.5
    staminaThresholdOnlyPremium = true

    -- Party
    -- NOTE: experienceShareLevelDifference is float number.
    -- experienceShareLevelDifference is highestLevel * value
    experienceShareRadiusX = 30
    experienceShareRadiusY = 30
    experienceShareRadiusZ = 1
    experienceShareLevelDifference = 2 / 3
    extraPartyExperienceLimit = 20
    extraPartyExperiencePercent = 5
    experienceShareActivity = 2 * 60 * 1000

    -- Global save
    -- NOTE: globalSaveHour means like 03:00, not that it will save every 3 hours,
    -- if you want such a system please check out data/globalevents/globalevents.xml.
    globalSaveEnabled = false
    globalSaveHour = 1
    shutdownAtGlobalSave = true
    cleanMapAtGlobalSave = false

    -- Spawns
    deSpawnRange = 2
    deSpawnRadius = 50

    -- Summons
    maxPlayerSummons = 2
    teleportAllSummons = false
    teleportPlayerSummons = false

    -- Status
    ownerName = "Universal"
    ownerEmail = "[email protected]"
    url = ""
    location = "Chile"
    displayGamemastersWithOnlineCommand = false

    -- Logs
    -- NOTE: This kind of logging does not work in GUI version.
    -- For such, please compile the software with __GUI_LOGS__ flag.
    adminLogsEnabled = false
    displayPlayersLogging = true
    prefixChannelLogs = ""
    runFile = ""
    outLogName = ""
    errorLogName = ""
    truncateLogsOnStartup = false
 
Last edited by a moderator:
You can look in configmanager.cpp for config options incase it's called different in your server (or in doc, CONFIG_HELP, if your server has that).
 
mm i don't know how to do that, but recently i checked on my server and now it won't even kick normal afk players at temple or somewhere else neither =S and its pretty much pointless to keep ongoing with my server if i can't fix the idle problems since i'll just get banned again at otservlist lol.
 
configmanager.cpp is in the source, so you need to download the source of your server (where you downloaded the server, there is often also a link to the source).
But it's also possible that there is a doc folder (under data) with info about your server like TFS has, there you can also find info about your server.

I noticed you use script and event and value in creaturescripts.xml. You server can't use both, so 1 of them is right and the other is wrong.
You can look in an other xml like actions.xml which one your server is actually using.

The idle.lua doesn't kick xlogged players, to get them kicked, you have to make them stop attacking when they xlog, and you can do that in config.lua.
You just need to know how it's called in your server, stopAttackingAtExit is from TFS 0.3/0.4.

To not get banned :
http://otland.net/threads/how-to-not-count-x-logged-players.81370/

If you do this, then it doesn't matter if people are xlogged or not, because it won't count them as online players.
 
okay so i found the CONFIG_HELP , also the idle.lua doesn't kick any players at all now , like players xlogged at temple or somewhere else that ain't attacking. And apparently in the CONFIG_HELP it says that my server is TFS 0.3.6 and not allisow which is the one it says in the console D: so i dunno
there's also a link to download the source but it has expired but i dont know if i should look for the "allisow source or the TFS source" since i dont have any.
I checked the action.xml and i don't know which one im using since for example in the quests it uses scripts , like this one :
<action uniqueid="5009" script="Quest/annichest.lua" />
but in tools it's different , like this one :
<action itemid="2420" event="script" value="tools/machete.lua"/>
so i can't tell which one im really using D: anyways im just trying to not get banned again from otservlist , since as you can see =p this is the first server i made so far. But im guessing i need the source of the server to be able to make it so it doesnt count x logged players , Because i dont know where else to find the status.cpp file :c.
Thanks again for helping me out! i'll try to find which source i need to get this done.
 
Back
Top