• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC sells items for items?

hejd12345

New Member
Joined
Apr 11, 2012
Messages
255
Reaction score
1
Location
Sweden
Is it possible to make a NPC that sells items for other items? I want to have a Umbral item NPC like RL Tibia and if I take the "Crude Umbral Blade" for an example it costs "1 Dream Matter and 20 Cluster of Solaces".

Crude Umbral Blade id: 22398
Dream Matter id: 22397
Cluster of Solace id: 22396

So does anyone have a NPC script that can sell this blade for 1 Dream Matter and 20 Clusters?
 
Which server do you use and can you give a conversation example how it will look like when you talk to the npc?
It also should work with more items right?
 
Which server do you use and can you give a conversation example how it will look like when you talk to the npc?
It also should work with more items right?
Using TFS 1.0
Me-Hi
NPC-Hello PLAYERNAME! I can sell you Umbral items in exchange for some special goods...
Me-Trade
NPC-Take a good look at my goods...

And the trade chat openes.

But I do not know if it is possible to use the Trade window because you are going to trade items for items.
So it could look like this:

Me-Hi
NPC-Hello PLAYERNAME! I can sell you Umbral items in exchange for some special goods...
Me-crude umbral blade
NPC-It would cost you one Dream Matter and 25 Cluster of Solaces...
Me-yes
NPC-There you go

And yes it should work for all the Umbral items.
 
But if that is impossible maybe you can make like chests which only can be opened one by one because it should only be possible to open the weapon chest "Umbral Blade" if you have opened the weapon chest "Crude Umbral Blade" first.
Maybe it is possible make the some doors "take" the items required and then they make it possible to open the next weapon chest?

Edit: Nvm, here is what I am looking for either using NPCs or doors/chest or whatever...(Not including the "Failing part")
Creating
To create a crude umbral piece - blade, slayer, axe, chopper, mace, hammer, bow, crossbow, or spellbook -, bring Eruaran a Dream Matter and 20 Clusters of Solace. You can choose any weapon type, no matter your vocation. You won't lose your dream matter any longer if failing, just your clusters.

Improving
The improving step depends on the item you bring. Unlike the first step, no dream matter is required here. Only your crude umbral piece and 75 Clusters of Solace are required to improve your item to umbral state. The chance of failing is higher here, and if so you will lose either your crude piece and keep your cluster or keep your weapon but lose all the required clusters.

Transformation
The transformation step is the most valuable one and will take some effort, but the outcome is tremendous. Bring your umbral equipment piece and 150 Clusters of Solace in order to transform them to master state. If you are unlucky the following things may occur: You lose your umbral item and keep all clusters or your umbral item is downgraded to a crude umbral item and you lose half amount of your cluster (75).
 
Last edited:
Well here is the npc as you requested it at first, didn't see the new posts.
If you want it different, make a conversation example again, so I can see exactly how you want it.
Code:
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 c = {
   ["crude umbral blade"] = {
     id = 22398,
     items = {
       {id = 22397, count = 1},
       {id = 22396, count = 20}
     }
   },
   ["something else"] = {
     id = 2112,
     items = {
       {id = 2674, count = 1},
       {id = 2675, count = 10}
     }
   }
}



local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, getItemDescriptions(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

     local player = Player(cid)
     local x = c[msg:lower()]
     if x then
         selfSay("It will cost you "..getItemsFromTable(x.items).."...", cid)
         talkState[talkUser] = 1
         xmsg = msg
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         x = c[xmsg:lower()]
         local n = 0
         for z = 1, #x.items do
             if player:getItemCount(x.items[z].id) >= x.items[z].count then
                 n = n + 1
             end
         end
         if n == #x.items then
             for r = 1, #x.items do
                 player:removeItem(x.items[r].id, x.items[r].count)
             end
             selfSay("There you go.", cid)
             player:addItem(x.id, 1)
         else
             selfSay("You don't have the items.", cid) 
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         selfSay("Ok then.", cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top