DiegoRulez
Member
To talk to this NPC requires the storage ( 55101 ) . Would this rule be maintained and that it remove the item ( 2347 ) and add storage ( 55102 ) .
Change item (2347) for storage (55102)
Sorry bad english.
Change item (2347) for storage (55102)
Sorry bad english.
Code:
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 greet(cid)
talkState[cid] = 0
return true
end
function getNpcName()
return getCreatureName(getNpcId())
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
if msgcontains(msg, "bye") or msgcontains(msg, "goodbye") then
selfSay("Good bye, " .. getCreatureName(cid) .. "!", cid)
npcHandler:releaseFocus(cid)
return true
elseif getPlayerStorageValue(cid, 55101) < 1 then
selfSay("Sorry, I'm busy.", cid)
return true
elseif msgcontains(msg, "passage") then
selfSay("If you want to enter our fortress you have to become one of us and fight the Efreet. So, are you willing to do so?", cid)
elseif msgcontains(msg, "yes") then
selfSay("Are you sure? You pledge loyalty to king Gabel, who is... you know. And you are willing to never ever set foot on Efreets' territory, unless you want to kill them? Yes?", cid)
elseif msgcontains(msg, "yeah") then
if getPlayerStorageValue(cid, 55102) == -1 then
selfSay("Oh. Ok. Welcome then. You may pass. And don't forget to kill some Efreets, now and then.", cid)
setPlayerStorageValue(cid, 55102, 1)
else
selfSay("You already have my permission.", cid)
end
-- talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())