• 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 SELLER ITEMS

dfsuno

New Member
Joined
Jun 20, 2021
Messages
20
Reaction score
2
Good morning Otland community, could you help me with a npc I need to sell the items x items not for money,and add how many loads the item will have when selling it, it only appears with one.

excuse me, my english is terrible.
I add the npc

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 shopWindow = {}
    local keys = {
         {id = 7869, buy = 500, name = "knight sword training ", actionid = 1443},
         {id = 7880, buy = 200, name = "knight club training ", actionid = 1443},
         {id = 7875, buy = 500, name = "knight axe training ", actionid = 1443},
       {id = 7864, buy = 500, name = "Paladin training ", actionid = 1443},
       {id = 7773, buy = 500, name = "Druid training ", actionid = 1443},
       {id = 7754, buy = 500, name = "Sorcerer training ", actionid = 1443},

    }

    local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
         if doPlayerRemoveMoney(cid, shopWindow[item].Price) then
             local thing = doPlayerAddItem(cid, shopWindow[item].ID, 1)
             doItemSetAttribute(thing, 'aid', shopWindow[item].Actionid)
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought a "..shopWindow[item].KeyName.." for "..shopWindow[item].Price.." gold.")
         else
             selfSay("You don't have enough money.", cid)
         end
         return true
    end


    function creatureSayCallback(cid, type, msg)
         if not npcHandler:isFocused(cid) then
             return false
         end

         if msgcontains(msg, 'trade') then
             for var, item in pairs(keys) do
                 shopWindow[item.id] = {ID = item.id, Price = item.buy, KeyName = item.name, Actionid = item.actionid}
             end
             openShopWindow(cid, keys, onBuy, onSell)
         end
         return true
    end

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

thanks to all.

I USE tfs 4
 
Back
Top