• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Small bug in my quest NPC

Xexza

New Member
Joined
Sep 3, 2007
Messages
1,053
Reaction score
3
When I ask for lagun permission, he answer correctly, but when I say yes, nothing happens.
Where in the "yes" part did I do wrong?

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 onCdreatureDisappear(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

    queststatus1 = getPlayerStorageValue(cid, 9092)
    queststatus2 = getPlayerStorageValue(cid, 9094)

        if msgcontains(msg, 'lagun permission') then  
    if queststatus1 == 1 then
            selfSay('I got a letter from Talfouk. He wrote that you were coming. So, you need the permission for entering laguna island?')  
    talk_state = 2  
end
        if msgcontains(msg, 'lost talon') then 
talk_state = 7 
    if queststatus2 == 1 then
            selfSay('Did you find my wonderful talon!?') 
    else
    selfSay('Who are you? I only speak to expected visitors.') 
end
------------------------------------------------ confirm yes ------------------------------------------------ 
        elseif msgcontains(msg, 'yes') and talk_state == 2 then 
                selfSay('OK! There is a test that you must pass, in order to show us your strength. Are you ready to hear your mission?') 
                talk_state = 3   
        
        elseif msgcontains(msg, 'yes') and talk_state == 3 then 
                    selfSay('Good, good. Your mission is to bring back my old talon. It was taken from the minotaurs long ago, but just recently I found out where it was hidden. This talon is special, it has been in generation for thousands of years. Do it sounds too scary for you already, or shall I continue my story? ') 
            talk_state = 4                 

        elseif msgcontains(msg, 'yes') and talk_state == 4 then 
                    selfSay('Bravery. All I know is that they are hiding it somewhere on the minotaur hills. The hills are located north east of Tharzuk. Are you sure you are brave enough for this mission? ') 
            talk_state = 5                 

        elseif msgcontains(msg, 'yes') and talk_state == 5 then 
                    selfSay('Excellent, I expect to see you back soon with my valuable talon. Say lost talon when you have it. ') 
           setPlayerStorageValue(cid, 9094, 1)

        elseif msgcontains(msg, 'yes') and talk_state == 7 then 
                    selfSay('Thank you so much. You have proven both lojality and strength. I will now send a letter to Talfouk, then he will give you the travelship-bless to the lagun islands.') 
           setPlayerStorageValue(cid, 9091, 1)
end
------------------------------------------------ confirm no ------------------------------------------------ 
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then 
            selfSay('Ok, you are not brave enough..') 
            talk_state = 0  
    return true 
end
return 1
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Wait, Ima rewrite it all in a min.
PHP:
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 onCdreatureDisappear(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

    local queststatus1 = getPlayerStorageValue(cid, 9092)
    local queststatus2 = getPlayerStorageValue(cid, 9094)

        if msgcontains(msg, 'lagun permission') then  
		if queststatus1 == 1 then
            selfSay('I got a letter from Talfouk. He wrote that you were coming. So, you need the permission for entering 

laguna island?')  
    talk_state = 2  
end
        elseif msgcontains(msg, 'lost talon') then  
		if queststatus2 == 1 then
            selfSay('Did you find my wonderful talon?!')
		talk_state = 7 
    else
    selfSay('Who are you? I only speak to expected visitors.') 
end
------------------------------------------------ confirm yes ------------------------------------------------ 
        elseif msgcontains(msg, 'yes') and talk_state == 2 then 
                selfSay('OK! There is a test that you must pass, in order to show us your strength. Are you ready to hear 

your mission?') 
                talk_state = 3   
        
        elseif msgcontains(msg, 'yes') and talk_state == 3 then 
                    selfSay('Good, good. Your mission is to bring back my old talon. It was taken from the minotaurs long 

ago, but just recently I found out where it was hidden. This talon is special, it has been in generation for thousands of 

years. Do it sounds too scary for you already, or shall I continue my story? ') 
            talk_state = 4                 

        elseif msgcontains(msg, 'yes') and talk_state == 4 then 
                    selfSay('Bravery. All I know is that they are hiding it somewhere on the minotaur hills. The hills are 

located north east of Tharzuk. Are you sure you are brave enough for this mission? ') 
            talk_state = 5                 

        elseif msgcontains(msg, 'yes') and talk_state == 5 then 
                    selfSay('Excellent, I expect to see you back soon with my valuable talon. Say lost talon when you have 

it. ') 
           setPlayerStorageValue(cid, 9094, 1)

        elseif msgcontains(msg, 'yes') and talk_state == 7 then 
                    selfSay('Thank you so much. You have proven both lojality and strength. I will now send a letter to 

Talfouk, then he will give you the travelship-bless to the lagun islands.') 
           setPlayerStorageValue(cid, 9091, 1)
------------------------------------------------ confirm no ------------------------------------------------ 
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then 
            selfSay('Ok, you are not brave enough..') 
            talk_state = 0   
end
return 1
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Try it.
 
Last edited:
There were some small errors I corrected, after that, it managed to work.
Thanks a lot :)
One thing, am I possible to:
This NPC, he set your storagevalue 1385 if you give him a talon with action id xx.

Do not script it, just let me know if its possible and maybe give me the function.
 
There were some small errors I corrected, after that, it managed to work.
Thanks a lot :)
One thing, am I possible to:
This NPC, he set your storagevalue 1385 if you give him a talon with action id xx.

Do not script it, just let me know if its possible and maybe give me the function.

Yes it's possible to make an npc like that
 
well it's easy

Code:
getPlayerStorageValue(cid,10001)
if ANSWERS == -1 then
Questions here
[COLOR="Red"]DONT FORGET TO ADD AN PART WHEN HE ANSWERS ALL RIGHT IT SETS HIS STORAGEVALUE TO 1[/COLOR]
else
selfSay('You have already completed the questions'))
 
Back
Top