• 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+ Can't buy NPC items

CastorFlynn

Member
Joined
Aug 29, 2021
Messages
88
Reaction score
8
I created an NPC that sells some items, among them some VIP items (custom). But these VIPs I can't trade. I noticed that I can't look at these items in the trade window either.

What could be limiting this? In SPR and OTB they don't have the "Ignore Look" option checked.

TFS 1.3
 
This vip itens are new sprites or duplicate ones? If they are, you also have to use item editor to include them.
 
Can you see this itens in game and use them properly? Also post the NPC script so I can check.

Yes, the items are in-game, fully functional.

In this example, I can look at the first and last item of the list and can buy them, but the 3 in the middle I can't look or buy.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Seller" script="Seller.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="130" head="39" body="0" legs="0" feet="0" addons="3" />
    <parameters>
        <parameter key="module_shop" value="1" />
        <parameter key="shop_buyable" value="
vip ring,21252,500;
vip blade,30019,100;
vip macer,30017,100;
vip wand,30023,100;
vip backpack,30032,100;" />
        <parameter key="shop_sellable" value="
            colourful feather,12470,110;
            empty potion flask,7634,5;" />
    </parameters>
</npc>

item.xml
XML:
    <item id="21252" article="a" name="vip ring">
        <attribute key="weight" value="10" />
        <attribute key="slotType" value="ring" />
        <attribute key="armor" value="10" />
        <attribute key="healthGain" value="10" />
        <attribute key="healthTicks" value="1000" />
        <attribute key="manaGain" value="20" />
        <attribute key="manaTicks" value="1000" />
        <attribute key="absorbPercentAll" value="5" />
        <attribute key="description" value="(health +10/1s, mana +20/1s)." />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30019" article="a" name="vip blade">
        <attribute key="weight" value="1000" />
        <attribute key="defense" value="40" />
        <attribute key="attack" value="52" />
        <attribute key="weaponType" value="sword" />
        <attribute key="skillSword" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30017" article="a" name="vip macer">
        <attribute key="weight" value="1000" />
        <attribute key="defense" value="40" />
        <attribute key="attack" value="52" />
        <attribute key="weaponType" value="club" />
        <attribute key="skillClub" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30023" article="a" name="vip wand">
        <attribute key="weight" value="3500" />
        <attribute key="weaponType" value="wand" />
        <attribute key="absorbPercentAll" value="2" />
        <attribute key="range" value="5" />
        <attribute key="magiclevelpoints" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
        <item id="30032" article="a" name="vip backpack">
        <attribute key="weight" value="1800" />
        <attribute key="containerSize" value="36" />
        <attribute key="slotType" value="backpack" />
    </item>
 
Yes, the items are in-game, fully functional.

In this example, I can look at the first and last item of the list and can buy them, but the 3 in the middle I can't look or buy.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Seller" script="Seller.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="130" head="39" body="0" legs="0" feet="0" addons="3" />
    <parameters>
        <parameter key="module_shop" value="1" />
        <parameter key="shop_buyable" value="
vip ring,21252,500;
vip blade,30019,100;
vip macer,30017,100;
vip wand,30023,100;
vip backpack,30032,100;" />
        <parameter key="shop_sellable" value="
            colourful feather,12470,110;
            empty potion flask,7634,5;" />
    </parameters>
</npc>

item.xml
XML:
    <item id="21252" article="a" name="vip ring">
        <attribute key="weight" value="10" />
        <attribute key="slotType" value="ring" />
        <attribute key="armor" value="10" />
        <attribute key="healthGain" value="10" />
        <attribute key="healthTicks" value="1000" />
        <attribute key="manaGain" value="20" />
        <attribute key="manaTicks" value="1000" />
        <attribute key="absorbPercentAll" value="5" />
        <attribute key="description" value="(health +10/1s, mana +20/1s)." />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30019" article="a" name="vip blade">
        <attribute key="weight" value="1000" />
        <attribute key="defense" value="40" />
        <attribute key="attack" value="52" />
        <attribute key="weaponType" value="sword" />
        <attribute key="skillSword" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30017" article="a" name="vip macer">
        <attribute key="weight" value="1000" />
        <attribute key="defense" value="40" />
        <attribute key="attack" value="52" />
        <attribute key="weaponType" value="club" />
        <attribute key="skillClub" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
    <item id="30023" article="a" name="vip wand">
        <attribute key="weight" value="3500" />
        <attribute key="weaponType" value="wand" />
        <attribute key="absorbPercentAll" value="2" />
        <attribute key="range" value="5" />
        <attribute key="magiclevelpoints" value="3" />
        <attribute key="showattributes" value="1" />
    </item>
        <item id="30032" article="a" name="vip backpack">
        <attribute key="weight" value="1800" />
        <attribute key="containerSize" value="36" />
        <attribute key="slotType" value="backpack" />
    </item>
Try to change to this script instead and see if it works:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NPC Name" script="script file.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="574" head="0" body="132" legs="96" feet="0" addons="2" />
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I sell precious ..." />
        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!" />
    </parameters>
</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 voices = { {text = "Sell VIP itens! Have a look!"} }
npcHandler:addModule(VoiceModule:new(voices))

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

shopModule:addBuyableItem({'Iron Pick'}, 27809, 100, 'Iron Pick')


shopModule:addSellableItem({'Small Stone'}, 27871, 12, 'Small Stone')




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

    local player = Player(cid)
    local vocationId = player:getVocation():getId()
    local items = {
        [1] = 2190,
        [2] = 2182,
        [5] = 2190,
        [6] = 2182
    }

--this part we can ignore for now --
    if msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand') then
        if table.contains({1, 2, 5, 6}, vocationId) then
            if player:getStorageValue(PlayerStorageKeys.firstRod) == -1 then
                selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your adventure?', cid)
                npcHandler.topic[cid] = 1
            else
                selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif msgcontains(msg, 'yes') then
        if npcHandler.topic[cid] == 1 then
            player:addItem(items[vocationId], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            player:setStorageValue(PlayerStorageKeys.firstRod, 1)
        end
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
        selfSay('Ok then.', cid)
        npcHandler.topic[cid] = 0
    end

    return true
end

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

Let me know if it works, it is the one I use on my server. I don't remember who create it. The owner please let me know so I can put the credits
 
Try to change to this script instead and see if it works:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NPC Name" script="script file.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="574" head="0" body="132" legs="96" feet="0" addons="2" />
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I sell precious ..." />
        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!" />
    </parameters>
</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 voices = { {text = "Sell VIP itens! Have a look!"} }
npcHandler:addModule(VoiceModule:new(voices))

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

shopModule:addBuyableItem({'Iron Pick'}, 27809, 100, 'Iron Pick')


shopModule:addSellableItem({'Small Stone'}, 27871, 12, 'Small Stone')




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

    local player = Player(cid)
    local vocationId = player:getVocation():getId()
    local items = {
        [1] = 2190,
        [2] = 2182,
        [5] = 2190,
        [6] = 2182
    }

--this part we can ignore for now --
    if msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand') then
        if table.contains({1, 2, 5, 6}, vocationId) then
            if player:getStorageValue(PlayerStorageKeys.firstRod) == -1 then
                selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your adventure?', cid)
                npcHandler.topic[cid] = 1
            else
                selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif msgcontains(msg, 'yes') then
        if npcHandler.topic[cid] == 1 then
            player:addItem(items[vocationId], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            player:setStorageValue(PlayerStorageKeys.firstRod, 1)
        end
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
        selfSay('Ok then.', cid)
        npcHandler.topic[cid] = 0
    end

    return true
end

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

Let me know if it works, it is the one I use on my server. I don't remember who create it. The owner please let me know so I can put the credits

Unfortunately the same thing happened. It's strange that I don't see anything wrong with item.xml, or with SPR/Dat or item.otb. I compared some items that work with those that don't, and the check boxes are the same.
 
Unfortunately the same thing happened. It's strange that I don't see anything wrong with item.xml, or with SPR/Dat or item.otb. I compared some items that work with those that don't, and the check boxes are the same.
I can't figure it out either. Look at a example of weapon on object build from my server

1633971995775.png
 
I can't figure it out either. Look at a example of weapon on object build from my server

View attachment 62714

With the exception of the last 4 options on the right that my OB doesn't have, both the items that I can look and trade and those that I can't are with the same pattern, marked:
Common, MultiUse, Pickable.

Remembering that I can't look at the look only in the trade window. In game the item is totally normal.
Post automatically merged:

Did you replaced items.otb in your items folder with the new one you created?
Yes, they have the same Object Build options checked.

And all the items are normal within the game, just this trade issue in the NPC window.
 
Back
Top