• 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+ TFS 1.3 Server freeze/shutdown

SorketROrk

Well-Known Member
Joined
Oct 14, 2020
Messages
152
Solutions
1
Reaction score
69
Location
Sweden
Hi,

I noticed that when having my server up for testing it freezes after around 30 min~ and players are disconnected.
When players try to reconnect they get "Connection failed ERROR 10060" I'm trying to solve it but I dont know where to look really...

The server is still "running" and shows no errors when players get disconnected, but are unable to log in after this.. I've tried to log into another account and player and it lets me log in, but after 1-2 sec (walk 1sqm) I get the same freeze and problem as previously..

I dont know whats causing this but would be happy if anyone could hint me in the right direction! :)


Yours,
SRO
 
Any possible scripts that would make life easier and let it look for infinite loops?

Dont know about memory leak :eek: more info is greatly appreciated!
 
Thank you for answering fast :)

But im getting:

Lua:
data/global.lua:189: attempt to index global 'debug' (a boolean value)
 
Thank you for answering fast :)

But im getting:

Lua:
data/global.lua:189: attempt to index global 'debug' (a boolean value)
f you get an error with global debug, some script you have is overriding the debug library which is why you should be careful with variable names.
 
By overriding the debug you mean "Debug" is being used somewhere else?

I did a check on all the files but there are none I could find to cause that... maybe im doing something wrong
So how would I go about to see if something is overriding the debug?
 
I think managed to put the script into action:

possible infinite loop in file @data/npc/lib/npc.lua near line 2

npc.lua
Lua:
-- Including the Advanced NPC System
dofile('data/npc/lib/npcsystem/npcsystem.lua')

function msgcontains(message, keyword)
    local message, keyword = message:lower(), keyword:lower()
    if message == keyword then
        return true
    end

    return message:find(keyword) and not message:find('(%w+)' .. keyword)
end

function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 0
    local item = 0
    if ItemType(itemid):isStackable() then
        if inBackpacks then
            stuff = Game.createItem(backpack, 1)
            item = stuff:addItem(itemid, math.min(100, amount))
        else
            stuff = Game.createItem(itemid, math.min(100, amount))
        end
        return Player(cid):addItemEx(stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
    end

    local a = 0
    if inBackpacks then
        local container, b = Game.createItem(backpack, 1), 1
        for i = 1, amount do
            local item = container:addItem(itemid, subType)
            if table.contains({(ItemType(backpack):getCapacity() * b), amount}, i) then
                if Player(cid):addItemEx(container, ignoreCap) ~= RETURNVALUE_NOERROR then
                    b = b - 1
                    break
                end

                a = i
                if amount > i then
                    container = Game.createItem(backpack, 1)
                    b = b + 1
                end
            end
        end
        return a, b
    end

    for i = 1, amount do -- normal method for non-stackable items
        local item = Game.createItem(itemid, subType)
        if Player(cid):addItemEx(item, ignoreCap) ~= RETURNVALUE_NOERROR then
            break
        end
        a = i
    end
    return a, 0
end

local func = function(cid, text, type, e, pcid)
    if Player(pcid):isPlayer() then
        local creature = Creature(cid)
        creature:say(text, type, false, pcid, creature:getPosition())
        e.done = true
    end
end

function doCreatureSayWithDelay(cid, text, type, delay, e, pcid)
    if Player(pcid):isPlayer() then
        e.done = false
        e.event = addEvent(func, delay < 1 and 1000 or delay, cid, text, type, e, pcid)
    end
end

function doPlayerSellItem(cid, itemid, count, cost)
    local player = Player(cid)
    if player:removeItem(itemid, count) then
        if not player:addMoney(cost) then
            error('Could not add money to ' .. player:getName() .. '(' .. cost .. 'gp)')
        end
        return true
    end
    return false
end

function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
    local player = Player(cid)
    if not player:removeTotalMoney(cost) then
        return false
    end

    for i = 1, count do
        local container = Game.createItem(containerid, 1)
        for x = 1, ItemType(containerid):getCapacity() do
            container:addItem(itemid, charges)
        end

        if player:addItemEx(container, true) ~= RETURNVALUE_NOERROR then
            return false
        end
    end
    return true
end

function getCount(string)
    local b, e = string:find("%d+")
    return b and e and tonumber(string:sub(b, e)) or -1
end

function Player.removeTotalMoney(self, amount)
    local moneyCount = self:getMoney()
    local bankCount = self:getBankBalance()

    if amount <= moneyCount then
        self:removeMoney(amount)
        return true

    elseif amount <= (moneyCount + bankCount) then
        if moneyCount ~= 0 then
            self:removeMoney(moneyCount)
            local remains = amount - moneyCount
            self:setBankBalance(bankCount - remains)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d from inventory and %d gold from bank account. Your account balance is now %d gold."):format(moneyCount, amount - moneyCount, self:getBankBalance()))
            return true
        else
            self:setBankBalance(bankCount - amount)
            self:sendTextMessage(MESSAGE_INFO_DESCR, ("Paid %d gold from bank account. Your account balance is now %d gold."):format(amount, self:getBankBalance()))
            return true
        end
    end
    return false
end

function Player.getTotalMoney(self)
    return self:getMoney() + self:getBankBalance()
end

function isValidMoney(money)
    return isNumber(money) and money > 0
end

function getMoneyCount(string)
    local b, e = string:find("%d+")
    local money = b and e and tonumber(string:sub(b, e)) or -1
    if isValidMoney(money) then
        return money
    end
    return -1
end

function getMoneyWeight(money)
    local gold = money
    local crystal = math.floor(gold / 10000)
    gold = gold - crystal * 10000
    local platinum = math.floor(gold / 100)
    gold = gold - platinum * 100
    return (ItemType(ITEM_CRYSTAL_COIN):getWeight() * crystal) + (ItemType(ITEM_PLATINUM_COIN):getWeight() * platinum) + (ItemType(ITEM_GOLD_COIN):getWeight() * gold)
end

whats wrong?
 
From what I see, it is a totally normal file, if you have not modified this library then as far as I know, in the npc library there are no infinite loops nor recursive functions for infinity
 
Last edited:
Back
Top