I'm using The Forgotten Server - Version 0.2.13 (Mystic Spirit). and I set up to test a script of quest. It's a quest of the type you kill X creature and return for reward.
NPC loads fine, everything seems to load fine.
When I get quest, and I start to kill the creature I see this error in concole for each creature I kill:
Script follows:
For test porpuses I give you the NPC script too:
I think that if I could change the function "onDeath" or something like this, it would work. But I really don't know how could I replace or fix it.
Thanks in advance!!
NPC loads fine, everything seems to load fine.
When I get quest, and I start to kill the creature I see this error in concole for each creature I kill:
[14/08/2012 13:28:49] Lua Script Error: [CreatureScript Interface]
[14/08/2012 13:28:49] data/creaturescripts/scripts/task/rotworm task.luanDeath
[14/08/2012 13:28:50] data/creaturescripts/scripts/task/rotworm task.lua:4: attempt to index local 'deathList' (a number value)
[14/08/2012 13:28:50] stack traceback:
[14/08/2012 13:28:50] [C]: in function '__index'
[14/08/2012 13:28:50] data/creaturescripts/scripts/task/rotworm task.lua:4: in function <data/creaturescripts/scripts/task/rotworm task.lua:3>
Script follows:
Code:
local storage = 5555
function onDeath(cid, corpse, deathList)
local killer = deathList[1]
local monster = getCreatureName(cid)
local rotworm = getPlayerStorageValue(killer, storage)
if ((monster:lower() == 'rotworm') and not isInArray({-1, 10}, rotworm)) then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You need to kill '.. 10 - rotworm ..' rotworm.')
setPlayerStorageValue(killer, storage, rotworm + 1)
elseif rotworm == 10 then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed enough rotworm. Come back and talk to NPC for a possible reward.')
end
return true
end
For test porpuses I give you the NPC script too:
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local quest = 5555
if msgcontains(msg, 'task') or msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
if (getPlayerStorageValue(cid, quest) == -1) then
selfSay("Heh... If I want you to do a task? Sure... Can you kill 10 rotmwors for me?{Yes}? {No}?", cid)
talkState[talkUser] = 2
elseif (getPlayerStorageValue(cid, quest) == 11) then
selfSay("Hm... You already helped me a lot, do not need more of you here, thanks!", cid)
talkState[talkUser] = 0
elseif (msgcontains(msg, 'task') or msgcontains(msg, 'mission') or msgcontains(msg, 'quest')) then
if (getPlayerStorageValue(cid, quest) < 10) then
selfSay("Hm... You're already helping me. How many have you killed?", cid)
talkState[talkUser]= 0
elseif (msgcontains(msg, 'task') or msgcontains(msg, 'mission') or msgcontains(msg, 'quest')) then
if (getPlayerStorageValue(cid, quest) == 10) then
selfSay("I see you have completed your task!", cid)
selfSay("You've done well! As a small reward I give you this steel boots!", cid)
doPlayerAddExp(cid, 5000)
doSendAnimatedText(getPlayerPosition(cid), "5000", TEXTCOLOR_WHITE_EXP)
doPlayerAddItem(cid, 2645, 1)
setPlayerStorageValue(cid, quest, 11) -- Finished
end
end
end
elseif (msgcontains(msg, 'yes')) then
selfSay("Okay, good hunt! When you finish come to me and say {complete}. {Bye} for now.", cid)
setPlayerStorageValue(cid, quest, 1)
talkState[talkUser]= 0
elseif (msgcontains(msg, 'no')) and (talkState[talkUser] == 2) then
selfSay("No problem then!", cid)
talkState[talkUser]= 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I think that if I could change the function "onDeath" or something like this, it would work. But I really don't know how could I replace or fix it.
Thanks in advance!!