Moj mistrz
Monster Creator
Hello. Need help with NPC, can someone repair him ?
Thanks.
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local exp = formula * formula2
local formula2 = getPlayerItemCount(cid, 10531)
local level = getPlayerLevel(cid)
local formula = (level * 30)
if msgcontains(msg, 'midnight shard') then
selfSay('Do you want change all of midnight shards for experience?')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
selfSay('Are you really sure?')
talk_state = 2
elseif msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, formula2) == 0 then
selfSay('Thank you very much! Ill give you '..exp..' experience for returning it!')
doPlayerAddExp(cid, formula)
doSendMagicEffect(getPlayerPosition(cid), 14)
doSendAnimatedText(getPlayerPosition(cid), formula, TEXTCOLOR_WHITE)
talk_state = 3
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
selfSay('Good bye. |PLAYERNAME|!')
talk_state = 0
end
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thanks.