As the title 
The npc will repond but not to 'ticket'
I guess I've done alot wrong as im a LUA beginner.
Sincerely,
Furstwin.
The npc will repond but not to 'ticket'
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- 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.
if(not npcHandler:isFocused(cid)) then
return false
end
local config = {
["normalpot"] = 7636,
["strongpot"] = 7634,
["greatpot"] = 7635
}
if msgcontains(msg, 'job') then
npcHandler:say('I can give you a "lotery ticket" for 100 empty vials.')
elseif msgcontains(msg, 'lottery ticket') then
npcHandler:say('To get a lottery ticket you need 100 vials of different kinds. Say {Ticket} to try your luck')
elseif msgcontains(msg, 'lottery') then
npcHandler:say('To get a lottery ticket you need 100 vials of different kinds. Say {Ticket} to try your luck')
------------------------------------------------ addon ------------------------------------------------
if msgcontains(msg, 'ticket') then
--normal pot
if getPlayerItemCount(cid, config.normalpot) >= 100 then
npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
talk_state = 100
--strong pot
elseif getPlayerItemCount(cid, config.strongpot) >= 100 then
npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
talk_state = 200
--great pot
elseif getPlayerItemCount(cid, config.greatpot) >= 100 then
npcHandler:say('Do you wish to exchange 100 vials for a lottery ticket?')
talk_state = 300
end
else npcHandler:say('You dont have these items!')
end
------------------------------------------------ confirm yes normal pot------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 100 then
talk_state = 0
if getPlayerItemCount(cid,config.normalpot) >= 100 then
if doPlayerTakeItem(cid,config.normalpot) == 100 then
npcHandler:say('Here you are. I wish you the best luck!')
doPlayerAddItem(cid,5957,1)
end
else
npcHandler:say('Sorry, you don\'t have these items.')
end
------------------------------------------------ confirm yes strong pot------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 200 then
talk_state = 0
if getPlayerItemCount(cid,config.strongpot) >= 100 then
if doPlayerTakeItem(cid,config.strongpot) == 100 then
npcHandler:say('Here you are. I wish you the best luck!')
doPlayerAddItem(cid,5957,1)
end
else
npcHandler:say('Sorry, you don\'t have these items.')
end
------------------------------------------------ confirm yes great pot------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 300 then
talk_state = 0
if getPlayerItemCount(cid,cinfig.greatpot) >= 100 then
if doPlayerTakeItem(cid,config.greatpot) == 100 then
npcHandler:say('Here you are. I wish you the best luck!')
doPlayerAddItem(cid,5957,1)
end
else
npcHandler:say('Sorry, you don\'t have these items.')
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 100 and talk_state <= 300) then
npcHandler:say('Ok than.')
talk_state = 0
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())
I guess I've done alot wrong as im a LUA beginner.
Sincerely,
Furstwin.
Last edited: