GM Venom
Active Member
- Joined
- Jan 28, 2013
- Messages
- 145
- Reaction score
- 28
Hello!
I have a problem with my Task System, it doesn't give rewards for completing tasks.
Can someone help me please?
Errors i get in console:
Here is the NPC code:
I have a problem with my Task System, it doesn't give rewards for completing tasks.
Can someone help me please?
Errors i get in console:
Code:
[Warning - Error::Killing in the name of::Tasks config] Bad reward type: exp, reward could not be loaded.
[Warning - Error::Killing in the name of::Tasks config] Bad reward type: money, reward could not be loaded.
Here is the NPC code:
Code:
local tasks =
{
[1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
[2] = {questStarted = 1539, questStorage = 65029, killsRequired = 6666, raceName = "Demons", rewards = {{enable = true, type = "storage", values = {65535, 1}}}}
}
local rankStorage = 32150
local choose = {}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
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(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, "task") then
npcHandler:say("There you can see the following tasks, please tell me the number of the task that you want to do.")
local text = "Number - Name"
for i = 1, table.maxn(tasks) do
text = text .. "\n" .. i .. " - " .. tasks[i].raceName .. (getPlayerStorageValue(cid, tasks[i].questStarted) == 2 and " [Done]" or "")
end
doShowTextDialog(cid, 1811, text)
elseif tasks[tonumber(msg)] then
msg = tonumber(msg)
if getPlayerStorageValue(cid, tasks[msg].questStarted) == 1 then
npcHandler:say("You are already making this task.")
talkState = 0
--return true
end
if getPlayerStorageValue(cid, tasks[msg].questStarted) == 2 then
npcHandler:say("You already finished this task.")
talkState = 0
--return true
end
if tasks[msg].level and getPlayerLevel(cid) < tasks[msg].level then
npcHandler:say("You need level " .. tasks[msg].level .. " or higher to make this task.")
talkState = 0
--return true
end
for k, v in pairs(tasks) do
if getPlayerStorageValue(cid, v.questStarted) == 1 and tasks[msg] ~= k then
npcHandler:say("You are already making a task.")
talkState = 0
--return true
end
end
npcHandler:say("Are you sure that do you want to start the task number " .. msg .. "?. In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ".")
choose[cid] = msg
talkState = 1
elseif msgcontains(msg, "yes") and talkState == 1 then
setPlayerStorageValue(cid, tasks[choose[cid]].questStarted, 1)
npcHandler:say("You have started the task number " .. choose[cid] .. ", remember... in this task you will need to defeat " .. tasks[choose[cid]].killsRequired .. " " .. tasks[choose[cid]].raceName .. ". Good luck!")
talkState = 0
elseif msgcontains(msg, "report") then
for k, v in pairs(tasks) do
if getPlayerStorageValue(cid, v.questStarted) == 1 then
if getPlayerStorageValue(cid, v.questStorage) >= v.killsRequired then
for i = 1, table.maxn(v.rewards) do
if (v.rewards[i].enable) then
if isInArray({"boss", "teleport", 1}, v.rewards[i].type) == TRUE then
doTeleportThing(cid, v.rewards[i].values)
elseif isInArray({"exp", "experience", 2}, v.rewards[i].type) == TRUE then
doPlayerAddExperience(cid, v.rewards[i].values)
elseif isInArray({"item", 3}, v.rewards[i].type) == TRUE then
doPlayerAddItem(cid, v.rewards[i].values[1], v.rewards[i].values[2])
elseif isInArray({"gold", 4}, v.rewards[i].type) == TRUE then
doPlayerAddMoney(cid, v.rewards[i].values)
elseif isInArray({"storage", "stor", 5}, v.rewards[i].type) == TRUE then
setPlayerStorageValue(cid, v.rewards[i].values[1], v.rewards[i].values[2])
elseif isInArray({"points", "rank", 2}, v.rewards[i].type) == TRUE then
setPlayerStorageValue(cid, rankStorage, getPlayerStorageValue(cid, rankStorage) + v.rewards[i].values)
else
print("[Warning - Error::Killing in the name of::Tasks config] Bad reward type: " .. v.rewards[i].type .. ", reward could not be loaded.")
end
end
end
local rank = getPlayerStorageValue(cid, rankStorage)
npcHandler:say("Great!... you have finished the task number " .. k .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.")
setPlayerStorageValue(cid, v.questStarted, 2)
break
else
if getPlayerStorageValue(cid, v.questStorage) == -1 then
setPlayerStorageValue(cid, v.questStorage, 0)
end
npcHandler:say("Current " .. getPlayerStorageValue(cid, v.questStorage) .. " " .. v.raceName .. " killed, you need to kill " .. v.killsRequired .. ".")
break
end
end
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: