Jaed Le Raep
★Gaeming★
- Joined
- Sep 3, 2007
- Messages
- 1,296
- Reaction score
- 441
Hey guys, I'm having a problem with this script. Whenever I get to Creston and get the quest, everything works out (the quest log and etc is coded in the quests.xml), but when I say stockade, the npc doesn't respond. Not sure why, so I'm hoping you can help. As far as greeting and the NPC getting you to say Creston, that is handled in the NPC's xml file. This is a sloppy script template I've had since 2010, so besides helping me troubleshoot the issue, could you also help clean it up?
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 storage = 8000
if(msgcontains(msg, 'Creston')) then
if(getPlayerStorageValue(cid, storage) < 1) then
npcHandler:say("Yer\' gonna go there and get me {10 cheese}, {25 fishes}, and {50 lumps of dough}. Once yer do, you\'ll have some standing in my crew. {Before you leave, go ask Jenkins for} {your belongings}.", cid)
addEvent(doPlayerSendTextMessage, 500, cid, MESSAGE_INFO_DESCR, "New Quest: Awaken")
addEvent(doPlayerSendTextMessage, 500, cid, MESSAGE_INFO_DESCR, "New Objective: Earn Your Standing")
setPlayerStorageValue(cid, storage, 1)
talkState[talkUser] = 0
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Get yer' ass to Creston, you still haven't gotten our stockade!", cid)
talkState[talkUser] = 0
elseif(getPlayerStorageValue(cid, storage) >= 2) then
npcHandler:say("Ready to head back to Creston?", cid)
talkState[talkUser] = 2
end
if(msgcontains(msg, 'Stockade')) then
if (getPlayerStorageValue(cid, storage) == 1) and doPlayerRemoveItem(cid, 11210, 5) == true then
setPlayerStorageValue(cid, storage, 3)
doPlayerAddItem(cid, 2345)
doPlayerAddExp(cid, 50)
addEvent(doPlayerSendTextMessage, 500, cid, MESSAGE_INFO_DESCR, "Objective Complete: Earn Your Standing")
npcHandler:say("Yer' now one of us! Let me know when you want to go to Creston.", cid)
else
npcHandler:say("Go and get the rest of what we need for the stockade!", cid)
talkState[talkUser] = 0
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
npcHandler:say("Get ready to sail to Creston!", cid)
talkState[talkUser] = 0
else
npcHandler:say("Let me know when ye's be ready!", cid)
talkState[talkUser] = 0
end
return TRUE
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: