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

Exchanging NPC

klinggels

New Member
Joined
Feb 22, 2009
Messages
11
Reaction score
0
I made a exchange npc but i want it to give a bag with items but when i tried the npc disapeared.
Anyone can help me fix it?

Here is epic.lua :

Code:
local talk_state = 0

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

function creatureSayCallback(cid, type, msg)


     if msgcontains(msg, 'epic') then
              if getPlayerItemCount(cid,2089,1) then
                    if doPlayerRemoveItem(cid,2089,1) == 1 then
                              selfSay('Here is your rewards! .')
                              doPlayerAddItem(cid,1987,1)
      <inside>
        <item id="7418"/>
        <item id="7433"/>
        <item id="6534"/>
        <item id="7424"/>
        <item id="2184"/>
        <item id="7431"/>
     </inside>
                    end
              else
                    selfSay('I am sorry then!. ')
                    talk_state = 0
              end
     elseif msgcontains(msg, 'no') then
              selfSay('Ok.. Good bye then!!')
              talk_state = 0
     end

return true
end

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

Code:
local talk_state = 0

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

function creatureSayCallback(cid, type, msg)


     if msgcontains(msg, 'epic') then
              if getPlayerItemCount(cid,2089,1) then
                    if doPlayerRemoveItem(cid,2089,1) == 1 then
                              selfSay('Here is your rewards! .')

        bp = doPlayerAddItem(cid,9774,1)
        doAddContainerItem(bp,9955,1)
        doAddContainerItem(bp,9969,1)
	doAddContainerItem(bp,6579,1)
	doAddContainerItem(bp,6528,1)
	doAddContainerItem(bp,8850,1)
	doAddContainerItem(bp,8901,1)

                    end
              else
                    selfSay('I am sorry then!. ')
                    talk_state = 0
              end
     elseif msgcontains(msg, 'no') then
              selfSay('Ok.. Good bye then!!')
              talk_state = 0
     end

return true
end

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



And Global.lua
function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
if doPlayerRemoveMoney(cid, cost) == TRUE then
for i = 1, count do
local container = doCreateItemEx(containerid, 1)
for x = 1, getContainerCapById(containerid) do
doAddContainerItem(container, itemid, charges)
end
doPlayerAddItemEx(cid, container, 1)
end
return LUA_NO_ERROR
end
return LUA_ERROR
end
 
Back
Top