• 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+backpack system trade

Tested on TFS 1.0.

Add to data/events/scripts/player.lua
Code:
local buyableItems = {
--[itemid] = price
[2595] = 15,
[1988] = 20
}

Replace onLook Event in data/events/scripts/player.lua
Code:
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
For:
Code:
    local price = buyableItems[thing:getId()]
    if price then
        self:sendTextMessage(MESSAGE_INFO_DESCR, description .. " It is worth " .. price .. " gold.")
    else
        self:sendTextMessage(MESSAGE_INFO_DESCR, description)
    end

Add to onMoveItem Event in data/events/scripts/player.lua
Code:
    local counter = getTileItemById(toPosition, 1617)
    if counter.uid ~= 0 then
        local itemid = item:getId()
        local price = buyableItems[itemid]
        if price then
            if self:getMoney() >= price then
                self:removeMoney(buyableItems[itemid])
                self:addItem(itemid)
                self:sendTextMessage(22,"You bought " .. item:getArticle() .." " .. item:getName() .. " for " .. price .. " gold.")
            else
                self:sendTextMessage(22,"You don't have enough gold to buy the " .. item:getName() .. ".")
            end
        else
            self:sendTextMessage(22,"" .. item:getName() .. " is not buyable.")
        end
        return false
    end

Video Demo:
http://puu.sh/tbBKg/36a9e1be21.mp4
 
I actually just now noticed that from the video, very interesting.

I assume the only way to do that is to edit the source though.
 
I could try something with unmoveable backpacks or other containers, but with NPCs it seems unlikely.

Sorry for the double post.
 
im creating this and want adapt to "attack npc bp" but how send "working" bp to player, player dont own or stay near this container
i need place where i can start digging :)
 
Back
Top