Abre o arquivo 050-function.lua que está dentro da pasta data/lib e adicione no fim do arquivo:
function doPlayerCountItems(cid, items) -- by Vodka
local items = type(items) == "table" and items or {items}
for i = 1, table.maxn(items) do
if getPlayerItemCount(cid, items[i]) <= 0 then
return false
end
end
return true
end
NPC:
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 talkState = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local list = {111,222,333,444,555,666,777} -- id dos itens
local pos = {x=160, y=54, z=7} -- para onde ele vai
if(msgcontains(msg, 'TRAVEL') or msgcontains(msg, 'travel')) then
selfSay("Para viajar comigo você ter os 7 items,você tem eles? {yes} ", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "yes") and talkState[talkUser] >= 1)then
if doPlayerCountItems(cid, list) then
selfSay("Boa viagem!.", cid)
doTeleportThing(cid, pos)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
else
selfSay("desculpe,mas você não tem os itens!", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())