Ecstacy
Mothafuckaaa
Hey,
I need some help on this npc script.
the begin works but when my topic[cid] == 1 then it doesn't do anything else.
I need some help on this npc script.
the begin works but when my topic[cid] == 1 then it doesn't do anything else.
Code:
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
function creatureSayCallback(cid, type, msg)
local Topic = {}
if msgcontains(msg,'help') then
local v = getPlayerStorageValue(cid,100)
if v < 1 then
npcHandler:say('Finally someone who is able to help.. you do gain bad reputation though, are you sure?',cid)
Topic[cid] = 1
elseif v == 1 then
npcHandler:say('Have you got the key yet?',cid)
Topic[cid] = 3
elseif v == 2 then
npcHandler:say('I don\'t need any moe help..',cid)
Topic[cid] = 0
npcHandler:releaseFocuse(cid)
end
elseif Topic[cid] == 1 then
if msgcontains(msg,'yes') then
npcHandler:say('Ok, good.. could you get me the key from the barrel outside the jail?',cid)
Topic[cid] = 2
else
npcHandler:say('Oh, I see... goodbye..',cid)
Topic[cid] = 0
npcHandler:releaseFocus(cid)
end
elseif Topic[cid] == 2 then
if msgcontains(msg,'yes') then
npcHandler:say('Ok.. talk to me when you get the key.',cid)
Topic[cid] = 0
setPlayerStorageValue(cid,100,1)
npcHandler:releaseFocus(cid)
else
npcHandler:say('Oh, I see... goodbye then..',cid)
Topic[cid] = 0
npcHandler:releaseFocus(cid)
end
elseif Topic[cid] == 3 then
if msgcontains(msg,'yes') then
if doRemoveItem(cid,2087,1) then
npcHandler:say('good god.. thank you! once the time is right, I\'ll leave here!',cid)
doPlayerAddExperience(cid,500)
doPlayerSendTextMessage(cid,19,'[Quest] You gained 500 experience points.')
Topic[cid] = 0
setPlayerStorageValue(cid,100,2)
else
npcHandler:say('You don\'t have it yet..., go get it!',cid)
Topic[cid] = 0
npcHandler:releaseFocuse(cid)
end
else
npcHandler:say('Oh, I see... goodbye then..',cid)
Topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Argh, goodbye..")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye..")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())