Hey, I wanted to know how I would be able to edit a npc script to make quest chains possible. I am currently using this script (source: http://otland.net/f132/npc-who-checks-amount-storages-159464/index2.html) and it looks like this:
LUA Code:
I would really love it if I could get some help. Thanks
LUA Code:
LUA:
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
lvl,stor,n = 30,9745474,0
if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
selfSay('Oh, did you do your missions?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerLevel(cid) >= lvl) then
if getPlayerStorageValue(cid, stor) == -1 then setPlayerStorageValue(cid, stor, 0) end
for i= 7000,7200 do
if getPlayerStorageValue(cid, i) >= 1 then
n = n+1
end
end
if n >= (getPlayerStorageValue(cid, stor)+5) then
npcHandler:say("Nice.", cid)
doPlayerAddExp(cid, 5000)
setPlayerStorageValue(cid, stor, getPlayerStorageValue(cid, stor)+5)
talkState[talkUser] = 0
else
selfSay('you must finish at least 5 quest.', cid)
end
else
selfSay('You have to be level '..lvl, cid)
end
elseif (msgcontains(msg, 'no') and talkState[talkUser] >= 1) then
talkState[talkUser] = 0
selfSay('Then not!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I would really love it if I could get some help. Thanks
Last edited by a moderator: