TFS 1.X+ Npc dont sell new items clone with itemEditor

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
hello, the npc doesn't sell cloned items with item editor, i'm using tfs 1.5 drowngrade 8.6.
they appear perfectly, but when trying to buy them, nothing happens

if I put items that are not cloned, it sells them perfectly.

Some alternative? maybe tell the npc, buy exercise staff? mention to the npc what item you want to buy
Sin título.png
 
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
You need to increase the item ID range at items.cpp in your source, they won't work either with Hotkeys
exactly, it doesn't work with hotkeys either.

I was already reviewing the source code, I can't find the range of items id, how should the range appear?
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,397
Solutions
245
Reaction score
4,308
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
here:

and:
In theory have reserved for 30000 items, or am I wrong?

and my last cloned item has the id: 13204

_items guardados.png

or should I change the value of 30000, for what number should I change it?
 
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
no, you shouldn't change it, I thought you had more items

the issue seems to be elsewhere
Who knows where the problem will be, the normal functional items.
They only have a problem with npc and client hotkeys.

Im tested with otcv8 and official client
Any idea?
 
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
Have you tried to make the script through . lua? instead of xml
yes i have this npc:

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 function getTable(player)
    local itemsList = {
        {name="apprentice exercise sword", id=13188, buy=250000, subType = 500},
        {name="superior exercise sword", id=13187, buy=900000, subType = 1800},
        {name="expert exercise sword", id=13186, buy=8000000, subType = 14400},
        
        {name="apprentice exercise axe", id=13192, buy=250000, subType = 500},
        {name="superior exercise axe", id=13191, buy=900000, subType = 1800},
        {name="expert exercise axe", id=13190, buy=8000000, subType = 14400},       

        {name="apprentice exercise club", id=13196, buy=250000, subType = 500},
        {name="superior exercise club", id=13195, buy=900000, subType = 1800},
        {name="expert exercise club", id=13194, buy=8000000, subType = 14400},           

        {name="apprentice exercise bow", id=13201, buy=250000, subType = 500},
        {name="superior exercise bow", id=13203, buy=900000, subType = 1800},
        {name="expert exercise bow", id=13204, buy=8000000, subType = 14400},   
        
        {name="apprentice exercise staff", id=13200, buy=250000, subType = 500},
        {name="superior exercise staff", id=13199, buy=900000, subType = 1800},
        {name="expert exercise staff", id=13198, buy=8000000, subType = 14400}
        
        
}

    local tomes = {
        {
            -- 3 tomes
        {name="lizard weapon rack kit", id=11126, buy=500}
        },
        {
            -- 9 tomes
        {name="bone shoulderplate", id=11321, sell=150},
        {name="broken draken mail", id=12616, sell=340},
        {name="broken halberd", id=11335, sell=100},
        {name="Broken Slicer", id=12617, sell=120},
        {name="cursed shoulder spikes", id=11327, sell=320},
        {name="drachaku", id=11308, sell=10000},
        {name="draken boots", id=12646, sell=40000},
        {name="draken wristbands", id=12615, sell=430},
        {name="drakinata", id=11305, sell=10000},
        {name="Elite Draken Mail", id=12607, sell=50000},
        {name="guardian boots", id=11240, sell=35000},
        {name="high guard's shoulderplates", id=11333, sell=130},
        {name="sais", id=11306, sell=16500},
        {name="spiked iron ball", id=11325, sell=100},
        {name="twiceslicer", id=12613, sell=28000},
        {name="twin hooks", id=11309, buy=1100, sell=500},
        {name="wailing widow's necklace", id=11329, sell=3000},
        {name="warmaster's wristguards", id=11322, sell=200},
        {name="zaoan armor", id=11301, sell=14000},
        {name="zaoan halberd", id=11323, buy=1200, sell=500},
        {name="zaoan helmet", id=11302, sell=45000},
        {name="zaoan legs", id=11304, sell=14000},
        {name="zaoan shoes", id=11303, sell=5000},
        {name="zaoan sword", id=11307, sell=30000},
        {name="zaogun's shoulderplates", id=11331, sell=150}
        }
}

    if player:getStorageValue(Storage.TheNewFrontier.TomeofKnowledge) >= 3 then
        -- 3 tomes
        for i = 1, #tomes[1] do
            itemsList[#itemsList] = tomes[1][i]
        end
    end

    if player:getStorageValue(Storage.TheNewFrontier.TomeofKnowledge) >= 9 then
        -- 9 tomes
        for i = 1, #tomes[2] do
            itemsList[#itemsList] = tomes[2][i]
        end
    end

    return itemsList
end

local function setNewTradeTable(table)
    local items, item = {}
    for i = 1, #table do
        item = table[i]
        items[item.id] = {itemId = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = item.subType, realName = item.name}
    end
    return items
end

local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks)
    local player = Player(cid)
    local items = setNewTradeTable(getTable(player))
    local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
    if not backpack or backpack:getEmptySlots(true) < 1 then
        player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
        return false
    end
    if not ignoreCap and player:getFreeCapacity() < ItemType(items[item].itemId):getWeight(amount) then
        return player:sendTextMessage(MESSAGE_FAILURE, 'You don\'t have enough cap.')
    end
    if not player:removeMoneyNpc(items[item].buyPrice * amount) then
        selfSay("You don't have enough money.", cid)
    else
        player:addItem(items[item].itemId, amount, true, subType)
        return player:sendTextMessage(MESSAGE_TRADE, 'Bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
    end
    return true
end

local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks)
    local player = Player(cid)
    local items = setNewTradeTable(getTable(player))
    if items[item].sellPrice and player:removeItem(items[item].itemId, amount) then
        player:addMoney(items[item].sellPrice * amount)
        return player:sendTextMessage(MESSAGE_TRADE, 'Sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.')
    else
        selfSay("You don't have item to sell.", cid)
    end
    return true
end

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

    if msgcontains(msg, "trade") then
        local player = Player(cid)
        local items = setNewTradeTable(getTable(player))
        openShopWindow(cid, getTable(player), onBuy, onSell)
        npcHandler:say("Of course, just browse through my wares.", cid)
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello, |PLAYERNAME| and welcome to my little forge.')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

any other way to do it in lua? that only sell items with charges.
 

bpm91

Premium User
Premium User
Joined
May 23, 2019
Messages
342
Solutions
5
Reaction score
26
try using it like this, the difference is that you put your items there

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400, 'magic lightwand')

shopModule:addBuyableItemContainer({'backpack of animate dead rune'}, 2001, 2316, 7520, 1, 'backpack of animate dead rune')
shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')





npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
523
Solutions
1
Reaction score
39
try using it like this, the difference is that you put your items there

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400, 'magic lightwand')

shopModule:addBuyableItemContainer({'backpack of animate dead rune'}, 2001, 2316, 7520, 1, 'backpack of animate dead rune')
shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')





npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

this is with your script, but nothing happens, still the same

Post automatically merged:

what if you try to debug the npc while selling so you can -maybe- obtain the items ids and if the values are set, idk.
I don't know how to do a good debug, could you give me an example of what to put in the npc?
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,561
Solutions
50
Reaction score
1,170
Location
Arica - Chile
well you are not debugging so
Weird Al My Work Here Is Done GIF by Adult Swim
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,561
Solutions
50
Reaction score
1,170
Location
Arica - Chile
this is with your script, but nothing happens, still the same

Post automatically merged:


I don't know how to do a good debug, could you give me an example of what to put in the npc?
adding a shit ton of prints here
you might need to obtain the item id, if the item id is being passed, if the item is being added, etc

you can also add some prints and try to see what you get here
 
Top