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

Solved addBuyableItem Problem

Lucas Durais

New Member
Joined
Jan 13, 2017
Messages
40
Reaction score
1
Hello guys

I'm trying to make my npc only sell some items if the player have one storage.
I've tried a lot of different ways and none of them worked for me...

In my last attempt I did as it follows:

Code:
local function greetCallback(cid)
     if getPlayerStorageValue(cid, Storage.Quest.Rank) >= 1 then
       local shopModule = ShopModule:new()
       npcHandler:addModule(shopModule)
       shopModule:addSellableItem({'item name'}, 2460, 120, 'item name that appears')
       shopModule:addBuyableItem({'item name'}, 2460, 120, 'item name that appears')
     end
     return true
   end

The problem is that if I have more then 1 item in my container, it will sell all of them, and if I buy 1x item, I will actually buy 2x items..

I have no idea of what the problem is and how I can get this npc working with storages...

Thanks!!
 
Hello guys

I'm trying to make my npc only sell some items if the player have one storage.
I've tried a lot of different ways and none of them worked for me...

In my last attempt I did as it follows:

Code:
local function greetCallback(cid)
     if getPlayerStorageValue(cid, Storage.Quest.Rank) >= 1 then
       local shopModule = ShopModule:new()
       npcHandler:addModule(shopModule)
       shopModule:addSellableItem({'item name'}, 2460, 120, 'item name that appears')
       shopModule:addBuyableItem({'item name'}, 2460, 120, 'item name that appears')
     end
     return true
   end

The problem is that if I have more then 1 item in my container, it will sell all of them, and if I buy 1x item, I will actually buy 2x items..

I have no idea of what the problem is and how I can get this npc working with storages...

Thanks!!

Lua:
shopModule:addBuyableItem({'item name'}, 2460, 120, 1, 'item name that appears')

You forgot the count variable that comes after the price.
 
I've already tried to do that...

The function actually doesn't have a count parameter.. This is how it is:

Code:
function ShopModule:addSellableItem(names, itemid, cost, realName, itemSubType)
 
I've already tried to do that...

The function actually doesn't have a count parameter.. This is how it is:

Code:
function ShopModule:addSellableItem(names, itemid, cost, realName, itemSubType)

Well what TFS version are you using, please read the rules..
In that case it's most likely a bug in your NPC libs, try to update them if you are using 1.x or find a working one if you are using 0.x.
 
except it does
itemSubType

Code:
local function greetCallback(cid)
     if getPlayerStorageValue(cid, Storage.RathletonQuest.CommonerRank) < 1 then
       local shopModule = ShopModule:new()
       npcHandler:addModule(shopModule)
       shopModule:addSellableItem({'brass helmet'}, 2460, 120, 'brass helmet', 1)
       shopModule:addBuyableItem({'brass helmet'}, 2460, 120, 'brass helmet', 1)
     end
     return true
   end

As you can see, I placed the itemSubtType parameter as "1"... the npc keeps selling 2x items and buying 2x items instead of 1x

Solved by myself with some tables... thanks anyway
 
Last edited by a moderator:
Code:
local function greetCallback(cid)
     if getPlayerStorageValue(cid, Storage.RathletonQuest.CommonerRank) < 1 then
       local shopModule = ShopModule:new()
       npcHandler:addModule(shopModule)
       shopModule:addSellableItem({'brass helmet'}, 2460, 120, 'brass helmet', 1)
       shopModule:addBuyableItem({'brass helmet'}, 2460, 120, 'brass helmet', 1)
     end
     return true
   end

As you can see, I placed the itemSubtType parameter as "1"... the npc keeps selling 2x items and buying 2x items instead of 1x

Solved by myself with some tables... thanks anyway

Please don't double post, edit your posts insted, I merged them but think about it in the future.
And why didn't you post the thing you did to solve it? It might help someone else.
 
Back
Top