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

Lua How can i prevent this error

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,054
Solutions
5
Reaction score
62
Not sure how this happens but i assume its because maybe there is item that doesnt exist in the traders? But tracking it is just wild
Lua Script Error: [Npc interface]
(Unknown scriptfile)
data/npc/lib/npcsystem/modules.lua:1017: [ShopModule.onSell] items[itemid] == nil
stack traceback:
[C]: at 0x5555556bbdc0
[C]: in function 'error'
data/npc/lib/npcsystem/modules.lua:1017: in function 'callbackOnSell'
data/npc/lib/npcsystem/npchandler.lua:272: in function 'processModuleCallback'
data/npc/lib/npcsystem/npchandler.lua:476: in function 'onSell'
data/npc/lib/npcsystem/modules.lua:1080: in function <data/npc/lib/npcsystem/modules.lua:1080>
 
Data/npc/lib/npcsystem/modules.lua
Go to line 1017

Do an if statement to check before that line:
LUA:
if not items[itemid] then
    print(“Player “..Player(cid):getName().. “ tried to sell an invalid item”)
return false
end
 
Last edited:
Data/npc/lib/npcsystem/modules.lua
Go to line 1017

Do an if statement to check before that line:
LUA:
if not items[itemid] then
    print(“Player “..Player(cid):getName().. “ tried to sell an invalid item”)
return false
end
I already have
LUA:
        if shopItem == nil then
            error("[ShopModule.onSell] items[itemid] == nil")
            return false
        end
which doesnt help me in any way to locate the issue
 
Yeah well without an item I’d you have two ways too solve it. Check every shop npcs items and make sure the items exist or do what I said and print the player that tried to sell the item and try to talk to them. So try what I suggested instead of saying what you are doing that isn’t helping.

Unless you want the bad solution of just removing the error so players can get free gold or something maybe.
 
Yeah well without an item I’d you have two ways too solve it. Check every shop npcs items and make sure the items exist or do what I said and print the player that tried to sell the item and try to talk to them. So try what I suggested instead of saying what you are doing that isn’t helping.

Unless you want the bad solution of just removing the error so players can get free gold or something maybe.
i just went trough all npc trader item ids and all of those items exist in items.xml so hella confusion, isnt it possible to add some sort of prints that catches exact nil item?
 
if the itemid is nil it makes it a lot harder to get the actual problem item. You can mess around in npc.cpp

npcscriptinterface::luaDoSellItem
Or
npcscriptinterface::luaOpenShopWindow

Add as many logs as you can. In OpenShopWindow you can log all the items being sent and make sure none of the values are corrupt.

Usually a problem like this is because the sellable item wasn’t added correctly (missing a parameter) in the npc .lua file.

I don’t imagine you are using itemids that break the limit of uint64_t.
 
if the itemid is nil it makes it a lot harder to get the actual problem item. You can mess around in npc.cpp

npcscriptinterface::luaDoSellItem
Or
npcscriptinterface::luaOpenShopWindow

Add as many logs as you can. In OpenShopWindow you can log all the items being sent and make sure none of the values are corrupt.

Usually a problem like this is because the sellable item wasn’t added correctly (missing a parameter) in the npc .lua file.

I don’t imagine you are using itemids that break the limit of uint64_t.
when you mentioned the uint64 bit maybe my uses 8bit and item id is higher then 8bit can support? Where can i check that?
 
when you mentioned the uint64 bit maybe my uses 8bit and item id is higher then 8bit can support? Where can i check that?
If you can only handle 8 bits I don’t think the server would work at all.

Your OS determines what you can support. X64 or x86. If you can only do 8bits I think you could only have like 255 items total
 
Back
Top