Clorens
New Member
- Joined
- Oct 5, 2011
- Messages
- 89
- Reaction score
- 0
Hi for some reason this script is not working..
I want the npc to first ask the player to bring her a red apple, when he does she should give him 10% of his exp for the next level.
After that he can keep going by saying adventure, and she'll tell him to bring her a her old tibia doll.
When he brings it to her, she should reward him with 75% exp.
Atm she just keep asking for more red apples...
And you can't get to the part when she asks you for her old tibia doll...
I want the npc to first ask the player to bring her a red apple, when he does she should give him 10% of his exp for the next level.
After that he can keep going by saying adventure, and she'll tell him to bring her a her old tibia doll.
When he brings it to her, she should reward him with 75% exp.
Atm she just keep asking for more red apples...
And you can't get to the part when she asks you for her old tibia doll...
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 = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'adventure')) then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
setPlayerStorageValue(cid, storage, 5)
talkState[talkUser] = 1
elseif (getPlayerStorageValue(cid, storage) == 5) then
selfSay('You\'ve got my red apple?', cid)
talkState[talkUser] = 1
elseif (getPlayerStorageValue(cid, storage) == 5) then
selfSay('Go get my old tibia doll!', cid)
talkState[talkUser] = 1
elseif (getPlayerStorageValue(cid, endstorage) == 1) then
selfSay('Thanks alot, this bring back memories. I don\'t need any help anymore.', cid)
talkState[talkUser] = 1
elseif (getPlayerStorageValue(cid, storage) == 4) and doPlayerRemoveItem(cid, 6579, 1) then
selfSay('Oh my god! you did it, I can\'t believe it. Here are you reward!', cid)
doPlayerAddPercentLevel(cid, 75)
setPlayerStorageValue(cid, endstorage, 1)
talkState[talkUser] = 1
end
---------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 5)) then
if doPlayerRemoveItem(cid, 2674, 1) then
setPlayerStorageValue(cid,storage,5)
doPlayerAddPercentLevel(cid, 1)
selfSay('Thank you. Talk to me again to continue the quest.', cid)
talkState[talkUser] = 0
else
selfSay('Go and bring me the red apple.', cid)
end
---------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser]) == 1 then
if(getPlayerStorageValue(cid,storage) == 2) then
setPlayerStorageValue(cid,storage,3)
selfSay('Good luck, and follow my map!', cid)
talkState[talkUser] = 0
else
return false
end
end
------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())