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

item seller tfs v1.2

Hahstudios

New Member
Joined
Mar 11, 2010
Messages
49
Solutions
3
Reaction score
1
im trying to get this item sller to work not made by me but idk how to do it :/ any help would be appreciated.

Lua:
[LIST=1]
[*]-- rest of config (item prices) is under function, paste there your items list from npc
[*]local config = {
[*]    price_percent = 90, -- how many % of shop price player receive when sell by 'item seller'
[*]    cash_to_bank = true -- try to send cash automaticly to bank account (try to put in bp and  then send to bank)
[*]}
[*]

[*]shopModule = {shopItems = {}}
[*]function shopModule:new()
[*]    local obj = {}
[*]    setmetatable(obj, self)
[*]    self.__index = self
[*]    return obj
[*]end
[*]

[*]function shopModule:addSellableItem(names, itemid, cost, realName)
[*]    if(self.shopItems[itemid] == nil) then
[*]        self.shopItems[itemid] = {sellPrice = -1}
[*]    end
[*]    self.shopItems[itemid].sellPrice = cost
[*]end
[*]

[*]function shopModule:addBuyableItemContainer(names, container, itemid, cost, subType, realName) end
[*]function shopModule:addBuyableItem(names, itemid, cost, subType, realName) end
[*]

[*]function onUse(cid, item, fromPosition, itemEx, toPosition)
[*]    msg = ""
[*]    if(shopModule.shopItems[itemEx.itemid] ~= nil) then
[*]        count = 1
[*]        if(itemEx.type > 1 and isItemStackable(itemEx.itemid)) then
[*]            count = itemEx.type
[*]        end
[*]        cash = math.ceil(shopModule.shopItems[itemEx.itemid].sellPrice * count / 100 * config.price_percent)
[*]        doRemoveItem(itemEx.uid)
[*]        msg = 'You sold ' .. count .. ' ' .. getItemNameById(itemEx.itemid) .. ' for ' .. cash .. ' gold coins'
[*]        if(cash > 0) then
[*]            doPlayerAddMoney(cid, cash)
[*]            if(config.cash_to_bank) then
[*]                doPlayerDepositMoney(cid, cash)
[*]                msg = msg .. ' (cash auto transfered to bank account or drop on floor)'
[*]            end
[*]        end
[*]        doSendAnimatedText(fromPosition, "$$$", TEXTCOLOR_LIGHTBLUE)
[*]    else
[*]        msg = getItemNameById(itemEx.itemid) .. " is not sellable item"
[*]    end
[*]    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg .. '.')
[*]    return false
[*]end
[*]

[*]-- here paste your list of items from NPC lua file
[*]shopModule:addSellableItem({'steel boots', 'steel boots'},               2645, 30000,   'steel boots')
[*]shopModule:addSellableItem({'golden boots', 'golden boots'},             2646, 400000,   'golden boots')
[*]shopModule:addSellableItem({'crocodile boots', 'crocodile boots'},       3982, 1000,    'crocodile boots')
[*]shopModule:addSellableItem({'pirate boots', 'pirate boots'},             5462, 5000,    'pirate boots')
[*]shopModule:addSellableItem({'fur boots', 'fur boots'},                   7457, 2000,    'fur boots')
[*]shopModule:addSellableItem({'terra boots', 'terra boots'},               7886, 5000,    'terra boots')
[*]shopModule:addSellableItem({'magma boots', 'magma boots'},               7891, 7000,    'magma boots')
[*]shopModule:addSellableItem({'glacier shoes', 'glacier shoes'},           7892, 3000,    'glacier shoes')
[*]shopModule:addSellableItem({'lighting boots', 'lighting boots'},         7893, 7000,    'lighting boots')
[*]shopModule:addSellableItem({'lighting boots', 'lighting boots'},         2197, 500,    'stone skin amulet')
[/LIST]


my error is:
funcion "" does not exist.
 
remove
[*], [/list],
    1. and put only 1 space in between shopModule:addSellableItem({'steel boots', 'steel boots'}, 2645, 30000, 'steel boots')
 
These are the problems I see;

You call shopModule but that isn't the correct class, it's ShopModule.
Lua:
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

You modify? the function, but you don't overwrite it, so either use the full function or re-call the function by calling ShopModule:addSellableItem(...)

Not even sure why you wanna modify the function, what I would do is to add the code I wrote above, remove your function and restart the server.
If you wanna do any modifications for the server do it here insted; forgottenserver/modules.lua at 33d074fe1cb28d7f094e0e6896ada65d9cd472a2 · otland/forgottenserver · GitHub
 
well i dont particularly wanna modify the function what im trying to do is make a single item u use the item (right click) and it pulls up a shop.
then you can sell items to it so instead of running back to town to sell items you can do it on the fly.
 
well i dont particularly wanna modify the function what im trying to do is make a single item u use the item (right click) and it pulls up a shop.
then you can sell items to it so instead of running back to town to sell items you can do it on the fly.

This adds a sellable item for -1 gp?
It dosn't give the "real" shop value or w/e

You want that use an action script, NPC codes does not "listen" to right clicks.
But if you wanna be able to sell all the items you have ~ then you still wanna use an action script that opens up an NPC trade (if posible) where you can sell the items, but changing one NPC won't help / work.
You would have to call the NPC functions from the libs from the action script.
 
Back
Top