local cfg = {
need_item = {5785, 10, 2160, 10},
storage = 40531,
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local msg = msg:lower()
if msgcontains(msg, 'kefla') then
if getPlayerStorageValue(cid, cfg.storage) < 1 then
if doPlayerRemoveItem(cid, cfg.need_item[1], cfg.need_item[2]) and doPlayerRemoveItem(cid, cfg.need_item[3], cfg.need_item[4])then
selfSay('You just swap '.. cfg.need_item[2] ..' '.. getItemNameById(cfg.need_item[1]) ..' for.', cid)
setPlayerStorageValue(cid, cfg.storage, 1)
else
selfSay('You need '.. cfg.need_item[2] ..' '.. getItemNameById(cfg.need_item[1]) ..'.', cid)
end
else
selfSay('You already did this exchange!', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())