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
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 config = {
{runa = 2268, cena_za_sztuke = 255, jaki_bp = 5926},
{runa = 2273, cena_za_sztuke = 255, jaki_bp = 2002},
{runa = 2293, cena_za_sztuke = 255, jaki_bp = 1999},
{runa = 2313, cena_za_sztuke = 255, jaki_bp = 2001},
{runa = 2274, cena_za_sztuke = 255, jaki_bp = 2002},
{runa = 2278, cena_za_sztuke = 255, jaki_bp = 5949}
}
for _, v in pairs(config) do
if msgcontains(msg, getItemNameById(v.runa)) then
selfSay('Do you want buy '..getItemNameById(v.runa)..' for '..v.cena_za_sztuke * 20 ..'?', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if doPlayerRemoveMoney(cid, v.cena_za_sztuke * 20) then
local bp = doPlayerAddItem(cid, v.jaki_bp, 1)
for i = 1, 20 do
doAddContainerItem(bp, v.runa, 1)
end
selfSay('Here you are.', cid)
return true
else
selfSay('You do not have enough money.', cid)
return true
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())