projsa
New Member
- Joined
- Aug 31, 2012
- Messages
- 19
- Reaction score
- 1
Hey there fellows!
I have some troubles with my Task NPC. I think everything's working except for when I turn in the mission.
When I turn in the mission, I'm assigned a new task and everything, and I'm supposed to get a reward for the completed mission. But that is not the case. I do not get the reward for some reason.
I'd really appreciate all help I can get!
Here's the code:
Thanks in advance!
/Projsa
I have some troubles with my Task NPC. I think everything's working except for when I turn in the mission.
When I turn in the mission, I'm assigned a new task and everything, and I'm supposed to get a reward for the completed mission. But that is not the case. I do not get the reward for some reason.
I'd really appreciate all help I can get!
Here's the code:
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
-- CFG
local configA = {
reward = true,
experience = true,
skill = true,
door = true,
missions = 6 -- Must be more than 1 and under 7 missions (6)
}
local rewardE = {{2160, 1}, {2160, 3}} -- item, count
local experienceE = 480000 -- exp
local skillE = {{4, 1}, {5, 2}} -- skillid, count
local mission = {
-- Info about what to kill for every mission. [1] = first mission and [2] second mission and so on...
[1] = "You have to kill 50 Dragons, 20 Dragon Lords.",
[2] = "You have to kill 4 Wyrms and 9 Demons.",
[3] = "This time you must slay 6 Demodras and 9 Dragon Lords.",
[4] = "You have to kill 40 Vampires and 60 Ghouls.",
[5] = "You have to kill 40 Behemoths and 40 Wyverns.",
[6] = "You have to kill 30 Juggernauts and 10 Cyclops."
}
local Cmissions = {
-- {monsterStorage1, monsterstorage2} (Must be the same in creaturescripts)
[1] = {586, 587}, -- Enter empty storages
[2] = {588, 589},
[3] = {590, 591},
[4] = {592, 593},
[5] = {594, 595},
[6] = {596, 597}
}
local questStorage = 598 -- Enter empty storage (Must be the same in creaturescripts)
local questMission = 599 -- Enter empty storage
local doorStorage = 600 -- Enter empty storage (Must be the same in actions)
-- Don't touch --
local getStorage = getPlayerStorageValue(cid, questStorage)
local getMission = getPlayerStorageValue(cid, questMission)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
if(getStorage < 0) then
if(getMission < 0) then
if(configA.missions >= 0) then
selfSay('You are on your first task. You want to continue?', cid)
talkState[talkUser] = 1
end
end
elseif(getStorage == 1) then
selfSay("You're not done with your task yet. Your mission is to kill 50 Dragons, 20 Dragon Lords in case you forgot. Come back to me when you are done.", cid)
talkState[talkUser] = 0
elseif(getStorage == 2) then
setPlayerStorageValue(cid, questStorage, 3)
setPlayerStorageValue(cid, questMission, 1)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 1) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[1], rewardE[2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[1], skillE[2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 3) then
if(getMission == 1) then
if(configA.missions >= 1) then
selfSay('You are on your second task. You want to continue?', cid)
talkState[talkUser] = 2
end
end
elseif(getStorage == 4) then
selfSay("You aren't done with your task yet. You have to kill 4 Wyrms and 9 Demons. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 5) then
setPlayerStorageValue(cid, questStorage, 6)
setPlayerStorageValue(cid, questMission, 2)
selfSay("There you are! Talk to me again for more information!", cid)
[removed code here, they are the same as above, just more missions with basicly the same information (can't exceed 10.000 words when posting a message here in OTLand)]
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thanks in advance!
/Projsa