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

Cant buy Items from trader (Problem)

Stanos

Veteran OT User
Joined
Jun 12, 2018
Messages
587
Solutions
4
Reaction score
315
Location
Europe
USING TFS 1.2
So people helped me in this forum how to make traders but when i tried to test them i noticed that i can sell my items but when i want to buy them i cant it always shows grey. Code
BTW yes i had gold in my bag.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'cheese'}, 2461, 200, 'cheese')
shopModule:addBuyableItem({'meat'}, 2482, 300, 'meat')

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Can you please post your addSellableItem and addBuyableItem functions from shopmodule files?

Also, are you sure that it's not a client-side error?
 
Can you please post your addSellableItem and addBuyableItem functions from shopmodule files?

Also, are you sure that it's not a client-side error?
Sorry didnt saw notification.
Lua:
    function ShopModule:parseSellable(data)
        for item in string.gmatch(data, "[^;]+") do
            local i = 1

            local name = nil
            local itemid = nil
            local cost = nil
            local realName = nil
            local subType = nil

            for temp in string.gmatch(item, "[^,]+") do
                if i == 1 then
                    name = temp
                elseif i == 2 then
                    itemid = tonumber(temp)
                elseif i == 3 then
                    cost = tonumber(temp)
                elseif i == 4 then
                    realName = temp
                elseif i == 5 then
                    subType = tonumber(temp)
                else
                    print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "Unknown parameter found in sellable items parameter.", temp, item)
                end
                i = i + 1
            end

            if SHOPMODULE_MODE == SHOPMODULE_MODE_TRADE then
                if itemid ~= nil and cost ~= nil then
                    self:addSellableItem(nil, itemid, cost, realName, subType)
                else
                    print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "Parameter(s) missing for item:", itemid, cost)
                end
            else
                if name ~= nil and itemid ~= nil and cost ~= nil then
                    local names = {}
                    names[#names + 1] = name
                    self:addSellableItem(names, itemid, cost, realName, subType)
                else
                    print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "Parameter(s) missing for item:", name, itemid, cost)
                end
            end
        end
    end

    -- Parse a string contaning a set of buyable items.
    function ShopModule:parseBuyableContainers(data)
        for item in string.gmatch(data, "[^;]+") do
            local i = 1

            local name = nil
            local container = nil
            local itemid = nil
            local cost = nil
            local subType = nil
            local realName = nil

            for temp in string.gmatch(item, "[^,]+") do
                if i == 1 then
                    name = temp
                elseif i == 2 then
                    itemid = tonumber(temp)
                elseif i == 3 then
                    itemid = tonumber(temp)
                elseif i == 4 then
                    cost = tonumber(temp)
                elseif i == 5 then
                    subType = tonumber(temp)
                elseif i == 6 then
                    realName = temp
                else
                    print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "Unknown parameter found in buyable items parameter.", temp, item)
                end
                i = i + 1
            end

            if name ~= nil and container ~= nil and itemid ~= nil and cost ~= nil then
                if subType == nil and ItemType(itemid):isFluidContainer() then
                    print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "SubType missing for parameter item:", item)
                else
                    local names = {}
                    names[#names + 1] = name
                    self:addBuyableItemContainer(names, container, itemid, cost, subType, realName)
                end
            else
                print("[Warning : " .. Npc():getName() .. "] NpcSystem:", "Parameter(s) missing for item:", name, container, itemid, cost)
            end
        end
    end
Im not sure is it client sided, cant say anything about it.
 
Back
Top