I'm using TFS .3 alpha 2 & the NPC talks and answers questions and does all that good stuff, but when it gets to where he's suppose to give the reward it wont work, but everything works perfectly up till there! Any help/advice/opinions/fixes/whatever would be greatly appreciated! Thanks in advance
The NPC:
Actions for that NPC that don't seem to want to work:
The NPC:
Code:
<?xml version="1.0"?>
<npc name="Amher" script="data/npc/scripts/amher.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150" />
<look type="134" head="0" body="19" legs="19" feet="19"/>
<parameters>
<parameter key="message_greet" value="Greetings. Dam its cold this Liner is junk." />
<parameter key="message_farewell" value="Bye, and take care!" />
<parameter key="message_placedinqueue" value="Your time will come |PLAYERNAME|..." />
<parameter key="message_walkaway" value="Come back soon!" />
<parameter key="message_idletimeout" value="Please do not waste my time..." />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="timber jack;link gear;broke;smith;jacket;reward" />
<parameter key="keyword_reply1" value="Hows that old fool doing." />
<parameter key="keyword_reply2" value="He Broke that gear again." />
<parameter key="keyword_reply3" value="Just smith up a new 1 but youll need the Forumula." />
<parameter key="keyword_reply4" value="Tell you what Ill give you the forumula for a new liner for my Jacket." />
<parameter key="keyword_reply5" value="I want the liner like Marshall has." />
<parameter key="keyword_reply6" value="You bring me a new Liner and ill give you the forumula and some EXP." />
</parameters>
</npc>
Code:
-- start configuration
local keyword = 'liner' --what must the player say to get involved into the conversation
local reqItemCount = 1 -- how many items the player needs
local reqItemID = 2651 -- what is the item ID of the item needed
local experience = 5000000 -- how much experience will the player get
local givenItemCount = 1 -- how many items will the player get (the count of givenItemID)
local givenItemID = 5956 -- which item will the player get
local storageValue = 9995 -- must be a UNIQUE storage value!!!
-- end configuration
if reqItemCount == 1 then
subfix = ''
else
subfix = 's'
end
if givenItemCount == 1 then
subfix2 = ''
else
subfix2 = 's'
end
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, keyword) then
if getPlayerItemCount(cid,reqItemID) >= reqItemCount then
selfSay('Did you bring me '..reqItemCount..' '..getItemName(reqItemID)..subfix..'?')
talkState = 1
else
selfSay('Come back when you have '..reqItemCount..' '..getItemName(reqItemID)..subfix..'.')
end
elseif msgcontains(msg, 'yes') and talkState == 1 then
if getPlayerItemCount(cid,reqItemID) >= reqItemCount then
if getPlayerStorageValue(cid,storageValue) ~= 1 then
if doPlayerTakeItem(cid,reqItemID,reqItemCount) == 0 then
doPlayerAddExp(cid,experience)
doPlayerAddItem(cid,givenItemID,givenItemCount)
selfSay('Here you are, '..experience..' experience points and '..givenItemCount..' '..getItemName(givenItemID)..subfix2..'.')
setPlayerStorageValue(cid,storageValue, 1)
doSendMagicEffect(getPlayerPosition(cid),11)
end
else
selfSay('Sorry, but you already brought be the item I requested.')
end
else
selfSay('Sorry, you do not have the item.')
end
talkState = 0
elseif msgcontains(msg, 'no') and talkState == 1 then
selfSay('Ok than.')
talkState = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())