Donio
Banned User
Hey, im wondering how I can delete the "You can only do this one time" thing, not the text but so you can do the quest twice or three times.. Below you can see my script
Code:
local t, Topic = {
items = {
{5953, 1},
{2148, 1},
},
reward = {5785, 1},
storage = 100,
level = 500
}, {}
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") and Topic[cid] ~= 1) 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 the " .. 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("Thanks, enter the teleporter to get to the reward room!", 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 fellow adventurer!", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())