Donio
Banned User
Hello, a quest in my server isnt rly working.. basicly the players dont get the boots they should when they leave the required items.. here is the script:
Does anyone see anythnig wrong here?
Code:
local t, Topic = {
items = {
{2195, 1},
{8265, 1},
{5468, 1},
},
reward = {9933, 1},
storage = 100,
level = 150
}, {}
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)
if not npcHandler:isFocused(cid) then
return false
elseif msgcontains(msg, "yes") or msgcontains(msg, "quest") then
if getPlayerStorageValue(cid, t.storage) < 1 then
local v, i = "", 0
for _, k in ipairs(t.items) do
i = i + 1
v = v .. (i == #t.items and #t.items ~= 1 and " and" or i > 1 and "," or "") .. (k[2] > 1 and (i == 1 and k[2] or " " .. k[2]) or (getItemInfo(k[1]).article == "" and "" or (i > 1 and " " .. getItemInfo(k[1]).article or getItemInfo(k[1]).article))) .. (i == 1 and getItemInfo(k[1]).article == "" and "" or " ") .. (k[2] > 1 and not isInArray({624, 688}, getItemInfo(k[1]).slotPosition) and getItemInfo(k[1]).plural or getItemInfo(k[1]).name)
end
npcHandler:say("I need you to bring me " .. v .. ", do you have " .. (#t.items < 2 and t.items[1][2] < 2 and not isInArray({624, 688}, getItemInfo(t.items[1][1]).slotPosition) and "it" or "them") .. " with you?", cid)
Topic[cid] = 1
else
npcHandler:say("You can only make this quest this one time!", cid)
Topic[cid] = 0
end
elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
if getPlayerLevel(cid) >= t.level then
local v, h = "", true
for _, k in ipairs(t.items) do
if getPlayerItemCount(cid, k[1]) < k[2] then
h = false
break
end
end
if h then
for _, k in ipairs(t.items) do
doPlayerRemoveItem(cid, k[1], k[2] or 1)
end
doPlayerAddItem(cid, t.reward[1], t.reward[2] or 1)
setPlayerStorageValue(cid, t.storage, 1)
npcHandler:say("Here are your brand-new crafted firewalker boots, Enjoy!", cid)
else
npcHandler:say("You do not have the required items.", cid)
end
else
npcHandler:say("You MUST be level " .. t.level .. ", get lost!", cid)
end
Topic[cid] = 0
elseif Topic[cid] == 1 then
Topic[cid] = 0
npcHandler:say("Good bye, do not tell anyone about my secret place!", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Does anyone see anythnig wrong here?