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

Game freezes when loot is being sold by mass quantity in backpacks to NPC

Serene

Premium User
Premium User
Joined
Mar 3, 2016
Messages
40
Solutions
2
Reaction score
20
Hello Otland friends, I have a problem in my server that I believe is a recurrence in majority of TFS, however I believe that not a lot of people know about this bug, or else it would've been fixed. I didnt find any topic regarding this, thats why I'm posting here.

When a player sell loot to the NPC and this loot is divided within many backpacks (by many i mean a lot ranging from thousands) the server begins to freeze and lag constantly. I believe that this forces the server to search a lot within these backpacks of loot.


I tried resolving this by placing an exhaust on the sale to the NPC however it did not help, it still feezes.
 
Well who is going to sell thousands of items at a time? Lol and how the hell does someone have that much cap,

My server is of highexp and the lag happens when the player sells in stack of 100 and these items are separated from thousands backpacks.
 
Hmm, well it is also probably because it really is too many items. Lol, can't you limit it? To like 5 thousand items only? Or 1 thousand to be safer?
 
Hmm, well it is also probably because it really is too many items. Lol, can't you limit it? To like 5 thousand items only? Or 1 thousand to be safer?

If I could do that, to sell the items in smaller quantities, would solve the problem. But I don't know how to do it. For example, limiting the sell in a quantity of 10 items would solve the problem.

sorry for my english
 
If I could do that, to sell the items in smaller quantities, would solve the problem. But I don't know how to do it. For example, limiting the sell in a quantity of 10 items would solve the problem.

sorry for my english
use the actual shop window so they can only sell 100 at a time.
 
use the actual shop window so they can only sell 100 at a time.

It is precisely this window that runs the npc. If they sell 100 at a time with a lot of backpacks and items in the backpack the freeze happens

Remember that this happens when the player is selling about 1000 identical items separated into more than 500 backpacks, I found this bug today. Yes, it is rare that a player go do this, but there is the possibility of anyone lag the server if they discover this bug.

EDIT: As I said, If there was the possibility of limit the sale of items in a 10 stacks on max, then the problem would be solved.
 
Last edited:
There is one way to see what luas are running whenever your server lags/crashes
Go into your servergame>data>lib> create a new .lua
now put this
Code:
local ignore = {"=%[C%]", "@data/lib/.+"}
function isInPatternArray(str, array)
  for i, x in pairs(array) do
     if str:match(x) then
       return true
     end
   end

   return false
end

debug.sethook(function()
   local info = debug.getinfo(2)
   if info and info.source and not isInPatternArray(info.source, ignore) then
     if info.source == "=[C]" then
       print(info.name or "=[C]")
     else
       print(info.source)
     end
   end
end, "c")
After you put that run the server again, and go into the npc and sell items. if it bugs/crashes it will tell you which .luas are being runned when you sell your items and you will see the cause of your problem
 
There is one way to see what luas are running whenever your server lags/crashes
Go into your servergame>data>lib> create a new .lua
now put this
local ignore = {"=%[C%]", "@data/lib/.+"}
function isInPatternArray(str, array)
for i, x in pairs(array) do
if str:match(x) then
return true
end
end

return false
end

debug.sethook(function()
local info = debug.getinfo(2)
if info and info.source and not isInPatternArray(info.source, ignore) then
if info.source == "=[C]" then
print(info.name or "=[C]")
else
print(info.source)
end
end
end, "c")
After you put that run the server again, and go into the npc and sell items. if it bugs/crashes it will tell you which .luas are being runned when you sell your items and you will see the cause of your problem


Thank You, Eddie.

This script seems to me to be quite useful, however the server nor starts with him.

It begins a infinite loop of loading just as it arrives at part of the npcs,

here's the screenshot

Do you think may have some relation with my problem?

Mlr4clJ.jpg
 
Could you enter your server after you opened the .exe? Becasue it is going to spam a lot of stuff even after the server has opened, get yourself a backpack, /i a lot of x100 items to sell and go to the npc, sell them all and then check your .exe, you will see the .luas runned there. Then it will tell you the luas that are being bugged after you sell the x100s of items
 
Could you enter your server after you opened the .exe? Becasue it is going to spam a lot of stuff even after the server has opened, get yourself a backpack, /i a lot of x100 items to sell and go to the npc, sell them all and then check your .exe, you will see the .luas runned there. Then it will tell you the luas that are being bugged after you sell the x100s of items

Unfortunately the server does not start with script. Its is that loop before starting,
 
Last edited:
Try to do like that

Code:
       <parameter key="shop_buyable" value="
            stone skin amulet, 2197, 500, 5;"

maybe try to add ,5; in every item you got
 
Last edited by a moderator:
Here is a hint...


Code:
-- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.
    function NpcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
        local callback = self:getCallback(CALLBACK_ONBUY)
        if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
            if(self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
                --
            end
        end
    end

Code:
-- Handles onSell events. If you wish to handle this yourself, use the CALLBACK_ONSELL callback.
    function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
        local callback = self:getCallback(CALLBACK_ONSELL)
        if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
            if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
                --
            end
        end
    end
 
Back
Top