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

npc exchange problem

carre

Advanced OT User
Joined
Apr 23, 2013
Messages
881
Solutions
1
Reaction score
160
Location
Sweden
Hi otland my lovely community

I got some small problems when exchanging items on NPC.

Screenshot_2.png
I said pick and I got a small axe and don't work
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Al Dee" script="al dee.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="97" body="77" legs="87" feet="115" addons="2" />
    <parameters>
        <parameter key="module_keywords" value="1" />
        <parameter key="message_greet" value="Hello, hello, |PLAYERNAME|! Please come in, look, and buy! I'm a specialist for all sorts of {tools}. Just ask me for a {trade} to see my offers! You can also ask me for general {hints} about the game or  about each {citizen} of the isle."/>
        <parameter key="message_farewell" value="Bye, bye |PLAYERNAME|."/>
        <parameter key="message_walkaway" value="Bye, bye."/>
        <parameter key="message_sendtrade" value="Take a look in the trade window to your left."/>
        <parameter key="keywords" value="name;job;offer;wares;help;information;tools;citizen;equipment;backpack;rope;shovel;torch;weapon;armor;shield;fishing;monster;dungeon;merchant;sewer;vital;rat;king;potion;food;cookie;blueberry;blueberries;club;money;gold;premium;bank;wares;academy;temple;rookgaard;main;tibia;furniture;al dee;amber;billy;carlos;cipfried;dallheim;dixi;hyacinth;lee'delle;lily;loui;norma;obi;paulie;santiago;seymour;oracle;tom;willie;zerbrus;zirella;worm;bone;how are you;" />
            <parameter key="keyword_reply1" value="My name is Al Dee, but you can call me Al. Can I interest you in a {trade}?" />
            <parameter key="keyword_reply2" value="I'm a merchant. Just ask me for a {trade} to see my offers." />
            <parameter key="keyword_reply3" value="Just ask me for a {trade} to see my offers." />
            <parameter key="keyword_reply4" value="Just ask me for a {trade} to see my offers." />
            <parameter key="keyword_reply5" value="If you need general {equipment}, just ask me for a {trade}. I can also provide you with some general {hints} about the game." />
            <parameter key="keyword_reply6" value="If you need general {equipment}, just ask me for a {trade}. I can also provide you with some general {hints} about the game." />
            <parameter key="keyword_reply7" value="As an adventurer, you should always have at least a {backpack}, a {rope}, a {shovel}, a {weapon}, an {armor} and a {shield}." />
            <parameter key="keyword_reply8" value="If you tell me the name of a citizen, I'll tell you what I know about him or her." />
            <parameter key="keyword_reply9" value="As an adventurer, you should always have at least a {backpack}, a {rope}, a {shovel}, a {weapon}, an {armor} and a {shield}." />
            <parameter key="keyword_reply10" value="Yes, I am selling that. Simply ask me for a {trade} to view all my offers." />
            <parameter key="keyword_reply11" value="Yes, I am selling that. Simply ask me for a {trade} to view all my offers." />
            <parameter key="keyword_reply12" value="Yes, I am selling that. Simply ask me for a {trade} to view all my offers." />
            <parameter key="keyword_reply13" value="No thank you. I can already overstock the market with torches." />
            <parameter key="keyword_reply14" value="Oh, I'm sorry, but I don't deal with weapons. That's {Obi}'s or {Lee'Delle}'s business. I could offer you a {pick} in exchange for a {small axe} if you should happen to own one." />
            <parameter key="keyword_reply15" value="Armor and shields can be bought at {Dixi}'s or at {Lee'Delle}'s. Dixi runs that shop near {Obi}'s." />
            <parameter key="keyword_reply16" value="Armor and shields can be bought at {Dixi}'s or at {Lee'Delle}'s. Dixi runs that shop near {Obi}'s." />
            <parameter key="keyword_reply17" value="I sell fishing rods and worms if you want to fish. Simply ask me for a {trade}." />
            <parameter key="keyword_reply18" value="If you want to challenge monsters in the {dungeons}, you need some {weapons} and {armor} from the local {merchants}." />
            <parameter key="keyword_reply19" value="If you want to explore the dungeons such as the {sewers}, you have to equip yourself with the vital stuff I am selling. It's {vital} in the deepest sense of the word." />
            <parameter key="keyword_reply20" value="To view the offers of a merchant, simply talk to him or her and ask for a {trade}. They will gladly show you their offers and also the things they buy from you." />
            <parameter key="keyword_reply21" value="Oh, our sewer system is very primitive - it's so primitive that it's overrun by {rats}. But the stuff I sell is safe from them. Just ask me for a {trade} to see it!" />
            <parameter key="keyword_reply22" value="Well, vital means - necessary for you to survive!" />
            <parameter key="keyword_reply23" value="Rats plague our {sewers}. You can sell fresh rat corpses to {Tom} the tanner." />
            <parameter key="keyword_reply24" value="The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!" />
            <parameter key="keyword_reply25" value="Sorry, I don't sell potions. You should visit {Lily} for that." />
            <parameter key="keyword_reply26" value="Hmm, the best address to look for food might be {Willie} or {Billy}. {Carlos} also has some snacks for sale." />
            <parameter key="keyword_reply27" value="If you want to find someone who may want to buy your cookies, you should meet {Lily}." />
            <parameter key="keyword_reply28" value="Blueberries grow on bushes. They're quite common in Tibia. Just pick them from a bush if you need a snack!." />
            <parameter key="keyword_reply29" value="Blueberries grow on bushes. They're quite common in Tibia. Just pick them from a bush if you need a snack!." />
            <parameter key="keyword_reply30" value="No, I don't want that." />
            <parameter key="keyword_reply31" value="Well, no gold, no deal. Earn gold by fighting {monsters} and picking up the things they carry. Sell it to {merchants} to make profit!" />
            <parameter key="keyword_reply32" value="Well, no gold, no deal. Earn gold by fighting {monsters} and picking up the things they carry. Sell it to {merchants} to make profit!" />
            <parameter key="keyword_reply33" value="As a premium adventurer you have many advantages. You really should check them out!." />
            <parameter key="keyword_reply34" value="A bank is quite useful. You can deposit your money safely there. This way you don't have to carry it around with you all the time. You could also invest your money in my {wares}!" />
            <parameter key="keyword_reply35" value="Just ask me for a {trade} to see my offers." />
            <parameter key="keyword_reply36" value="The big building in the centre of Rookgaard. They have a library, a training centre, a {bank} and depots. {Seymour} is the teacher there." />
            <parameter key="keyword_reply37" value="The monk {Cipfried} takes care of our temple. He can heal you if you're badly injured or poisoned." />
            <parameter key="keyword_reply38" value="On the island of Rookgaard you can gather important experiences to prepare yourself for {mainland}." />
            <parameter key="keyword_reply39" value="Have you ever wondered what that 'main' is people are talking about? Well, it's a big continent full of adventures!" />
            <parameter key="keyword_reply40" value="One day I will return to the continent as a rich, a very rich man!" />
            <parameter key="keyword_reply41" value="Do you want to decorate your house? Well I don't sell that, ask {Norma}." />
            <parameter key="keyword_reply42" value="Yep, that's me. Smart of you to notice that!." />
            <parameter key="keyword_reply43" value="She's currently recovering from her travels in the {academy}. It's always nice to chat with her!" />
            <parameter key="keyword_reply44" value="This is a local farmer. If you need fresh {food} to regain your health, it's a good place to go. He's only trading with {premium} adventurers though." />
            <parameter key="keyword_reply45" value="His bar is at the {premium} side of the village. He doesn't like to deal with other kind of people." />
            <parameter key="keyword_reply46" value="He is just an old monk. However, he can heal you if you are badly injured or poisoned." />
            <parameter key="keyword_reply47" value="Some call him a hero. He protects the town from {monsters}." />
            <parameter key="keyword_reply48" value="She's {Obi}'s granddaughter and deals with {armors} and {shields}. Her shop is south west of town, close to the {temple}." />
            <parameter key="keyword_reply49" value="He mostly stays by himself. He's a hermit outside of town - good luck finding him." />
            <parameter key="keyword_reply50" value="If you are a {premium} adventurer, you should check out Lee'Delle's shop. She lives in the western part of town, just across the bridge." />
            <parameter key="keyword_reply51" value="She sells health {potions} and antidote potions. Also, she buys {blueberries} and {cookies} in case you find any." />
            <parameter key="keyword_reply52" value="No idea who that is." />
            <parameter key="keyword_reply53" value="She used to sell equipment, then she had a small bar, now she has a {furniture} shop. Talks about changing her name to 'Mary' and such, strange girl." />
            <parameter key="keyword_reply54" value="He sells {weapons}. His shop is south west of town, close to the {temple}." />
            <parameter key="keyword_reply55" value="He's the local {bank} clerk." />
            <parameter key="keyword_reply56" value="He dedicated his life to {fishing}. Such a boring {job}." />
            <parameter key="keyword_reply57" value="Seymour is a teacher running the {academy}. He has many important {information} about Tibia." />
            <parameter key="keyword_reply58" value="Just an useless stone statue now." />
            <parameter key="keyword_reply59" value="He's the local tanner. You could try selling fresh corpses or leather to him." />
            <parameter key="keyword_reply60" value="This is a local farmer. If you need fresh {food} to regain your health, it's a good place to go. However, many monsters also carry food such as meat or cheese. Or you could simply pick {blueberries}." />
            <parameter key="keyword_reply61" value="Some call him a hero. He protects the town from {monsters}." />
            <parameter key="keyword_reply62" value="Poor old woman, her son {Tom} never visits her." />
            <parameter key="keyword_reply63" value="I have enough worms myself and don't want any more. Use them for fishing." />
            <parameter key="keyword_reply64" value="You better put that bone back there where you dug it out." />
            <parameter key="keyword_reply65" value="I'm fine. I'm so glad to have you here as my customer." />
        <parameter key="module_shop" value="1" />
        <parameter key="shop_buyable" value="
        backpack,1988,10;
        bag,1987,5;
        bucket,2005,4,0;
        broom,2324,12;
        fire bug,5468,200;
        fishing rod,2580,150;
        hammer,2557,80;
        hoe,2552,15;
        pitchfork,2548,25;
        rake,2549,20;
        rope,2120,50;
        saw,2558,95;
        scythe,2550,12;
        shovel,2554,10;
        torch,2050,2;
        trap,2578,200;
        watch,2036,50;
        worm,3976,1;" />
        <parameter key="shop_sellable" value="
        fishing rod,2580,30;
        rope,2120,8;
        shovel,2554,2" />
    </parameters>
</npc>
Post automatically merged:

Code:
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

npcHandler:addModule(FocusModule:new())
 
you need some code in your lua part, it is empty that is why it is not working 😄 take this as example:
Omg did not notice it :(
Only thought xml would do the job.
Post automatically merged:

you need some code in your lua part, it is empty that is why it is not working 😄 take this as example:
Thanks
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState, xmsg = {}, {}

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 items = {
   ["warlord sword"] = {
     payitems = {
       {id = 6500, count = 100},
       {id = 2400, count = 1},
     },
     rewarditem = 2408
   },
   ["spellbook of dark mysteries"] = {
     payitems = {
       {id = 6500, count = 100},
       {id = 8903, count = 1},
     },
     rewarditem = 8918
   },
   ["royal crossbow"] = {
     payitems = {
       {id = 6500, count = 100},
       {id = 5803, count = 1},
     },
     rewarditem = 8851
   }
}

local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, getItemInfo(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
     end
     return text
end

function creatureSayCallback(cid, type, msg)

     if not npcHandler:isFocused(cid) then
         return false
     end

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     if msgcontains(msg, "weapons") then
         selfSay("You can trade yourself a {warlord sword}, {spellbook of dark mysteries} and {royal crossbow}.", cid)
         talkState[talkUser] = 1
     elseif items[msg:lower()] and talkState[talkUser] == 1 then
         local x = items[msg:lower()]
         local info = getItemInfo(x.rewarditem)
         selfSay("Do you want to exchange "..getItemsFromTable(x.payitems).." for "..info.article.." "..info.name.."?", cid)
         talkState[talkUser] = 2
         xmsg[cid] = msg
     elseif msgcontains(msg, "yes") and items[xmsg[cid]:lower()] and talkState[talkUser] == 2 then
         local x, n = items[xmsg[cid]:lower()], 0
         for c = 1, #x.payitems do
             if getPlayerItemCount(cid, x.payitems[c].id) >= x.payitems[c].count then
                 n = n + 1
             end
         end
         if n == #x.payitems then
             for r = 1, #x.payitems do
                 doPlayerRemoveItem(cid, x.payitems[r].id, x.payitems[r].count)
             end
             doPlayerAddItem(cid, x.rewarditem, 1)
             selfSay("Great, here is your "..xmsg[cid]..".", cid)
         else
             selfSay("You don't have all items, you need "..getItemsFromTable(x.payitems)..".", cid)
         end
         talkState[talkUser] = 0
         xmsg[cid] = ""
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Post automatically merged:

Post automatically merged:

Now I get this problem when I try to say yes to pick.
Screenshot_2.pngScreenshot_3.png
Post automatically merged:

Solved
I just made some messy code.
 
Last edited:
Back
Top