This my NewbieQuest! Peoples need to find 50 worms and bring them to Ned to get a fishing rod for 20gp. Ned buys also worms.
Tested with ForgottenServer 0.2.2
fisherman.lua
ned.xml
inXML/quests.xml add this
i hope you like it
thx you and farewell Virgel
Tested with ForgottenServer 0.2.2
fisherman.lua
Code:
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, 'quest') or msgcontains(msg, 'quests') or msgcontains(msg, 'mission') or msgcontains(msg, 'worms') or msgcontains(msg, 'rod') or msgcontains(msg, 'fishing rod') then
if getPlayerStorageValue(cid, 10002) == -1 then
selfSay('Hey, if you bring me 50 Worms for free i will sell you an fishing rod for 20gp. Is this okay for you?')
talk_state = 1642
elseif getPlayerStorageValue(cid, 10002) == 1 then
selfSay('Got 50 worms for me?.')
talk_state = 1643
elseif getPlayerStorageValue(cid, 10002) == 2 then
selfSay('Do you wish to buy a fishing rod for 20gp now?')
talk_state = 1644
elseif getPlayerStorageValue(cid, 10002) == 3 then
selfSay('I have no fishing rods left sorry.')
talk_state = 0
end
elseif talk_state == 1642 then
if msgcontains(msg, 'yes') then
selfSay('Thank you. Please look in you QuestLog for more information.')
setPlayerStorageValue(cid, 10002, 1)
elseif msgcontains(msg, 'no') then
selfSay('Then not.')
end
elseif talk_state == 1643 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(cid,3976) >= 50 then
doPlayerRemoveItem(cid, 3976, 50)
selfSay('Thank you. I will sell you 1 fishing rod for 20gp.')
setPlayerStorageValue(cid, 10002, 2)
else
selfSay('Sorry, you dont have so many.')
end
elseif msgcontains(msg, 'no') then
selfSay('Maybe later.')
end
elseif talk_state == 1644 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid, 20) then
doPlayerAddItem(cid, 2580, 1)
selfSay('Here you are!.')
setPlayerStorageValue(cid, 10002, 3)
else
selfSay('Sorry, you dont have enough money.')
end
elseif msgcontains(msg, 'no') then
selfSay('Maybe later.')
end
talk_state = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
<npc name="Ned" script="data/npc/scripts/fisherman.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="128" head="20" body="30" legs="40" feet="50" addons="0"/>
<parameters>
<parameter key="module_shop" value="1" />
<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell fishing rods(150gp) and i buy worms(1gp)." />
<parameter key="shop_sellable" value="worm,3976,1" />
<parameter key="shop_buyable" value="fishing rod,2580,150" />
</parameters>
</npc>
Code:
<quest name="A favour for a fishing rod[LvL1]" startstorageid="10002" startstoragevalue="1">
<mission name="Bring Ned 50 Worms" storageid="10002" startvalue="1" endvalue="3">
<missionstate id="1" description="Ned is a fisherman, but hes out of worms. If you bring him 50 worms he will sell you a fishing rod for 20gp." />
<missionstate id="2" description="Ned was very happy about your help. You can now buy the fishing rod for 20gp. " />
<missionstate id="3" description="Mission Completed." />
</mission>
</quest>
thx you and farewell Virgel
Last edited by a moderator: