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

TFS 1.X+ Dynamic trade window

Raikou

Active Member
Joined
Jul 18, 2007
Messages
101
Solutions
2
Reaction score
33
I'm trying to make a dynamic trade window, sadly i can't get the window to pop up yet.
The code looks as following:
Lua:
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
local shopModule = ShopModule:new()


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then return false end
    npcHandler:addModule(shopModule)
    local player = Player(cid)
    if msgcontains('trade', msg) then
        print('trade trigger')


        if player:getPawAndFurRank() == 0 then
        print('0 trigger')
            shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 1,'brown backpack')
            shopModule:addBuyableItem({'beach backpack'}, 5949, 20, 1,'beach backpack')
            shopModule:addBuyableItem({'blue backpack'}, 2002, 20, 1,'blue backpack')
            shopModule:addBuyableItem({'brocade backpack'}, 9774, 20, 1,'brocade backpack')
            shopModule:addBuyableItem({'camouflage backpack'}, 3940, 20, 1,'camouflage backpack')
            shopModule:addBuyableItem({'fur backpack'}, 7342, 20, 1,'fur backpack')
            shopModule:addBuyableItem({'golden backpack'}, 2004, 20, 1,'golden backpack')
            shopModule:addBuyableItem({'green backpack'}, 1998, 20, 1,'green backpack')
            shopModule:addBuyableItem({'grey backpack'}, 2003, 20, 1,'grey backpack')
            shopModule:addBuyableItem({'orange backpack'}, 10519, 20, 1,'orange backpack')
            shopModule:addBuyableItem({'purple backpack'}, 2001, 20, 1,'purple backpack')
            shopModule:addBuyableItem({'red backpack'}, 2000, 20, 1,'red backpack')
            --shopModule:addBuyableItem({'yellow backpack'}, 1999, 20, 1,'yellow backpack')
        end
        if player:getPawAndFurRank() >= 1 then   
        print('1 trigger')
            shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 1,'brown backpack')
            shopModule:addBuyableItem({'beach backpack'}, 5949, 20, 1,'beach backpack')
            shopModule:addBuyableItem({'blue backpack'}, 2002, 20, 1,'blue backpack')
            shopModule:addBuyableItem({'brocade backpack'}, 9774, 20, 1,'brocade backpack')
            shopModule:addBuyableItem({'camouflage backpack'}, 3940, 20, 1,'camouflage backpack')
            shopModule:addBuyableItem({'fur backpack'}, 7342, 20, 1,'fur backpack')
            shopModule:addBuyableItem({'golden backpack'}, 2004, 20, 1,'golden backpack')
            shopModule:addBuyableItem({'green backpack'}, 1998, 20, 1,'green backpack')
            shopModule:addBuyableItem({'grey backpack'}, 2003, 20, 1,'grey backpack')
            shopModule:addBuyableItem({'orange backpack'}, 10519, 20, 1,'orange backpack')
            shopModule:addBuyableItem({'purple backpack'}, 2001, 20, 1,'purple backpack')
            shopModule:addBuyableItem({'red backpack'}, 2000, 20, 1,'red backpack')
            shopModule:addBuyableItem({'yellow backpack'}, 1999, 20, 1,'yellow backpack')
            shopModule:addBuyableItem({'pirate backpack'}, 5926, 20, 1,'pirate backpack')
        end
    end


end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

In the serverlog i see this when i request a trade:
Code:
trade trigger
1 trigger
What am I missing?
 
Top