• 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!

NPC does not respond.

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
308
Location
Poland
Hello everyone, i want a npc that gives you mission and let you pass first magic door (needed to make mission and get quest reward) and if you make mission then he'll gives you pass to next magic door. I've maked this npc, but he is not responding. Idk what i did wrong. Im noob in scripting. Sorry for my bad english.

Here is script:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end


        if msgcontains(msg, 'help') then
        selfSay('Lucien are thief i tell you, he stole my alchemists formulas, could you help return it?')
        talk_state = 1
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            selfSay('Please go to his hidden spot near spike sword quest and find my {alchemists formulas}.')
        doPlayerSetStorageValue(cid,58755, 1)
                talk_state = 2
        elseif msgcontains(msg, 'alchemists formulas') and getPlayerItemCount(cid,9733) >= 1 and getPlayerStorageValue(cid,54558) == -1 then
            if doPlayerTakeItem(cid,9733,1) == 0 then
            selfSay('Thank you very much! Now you can use magic door near spike sword quest!')
                    setPlayerStorageValue(cid,54558,1)
            doSendMagicEffect(getPlayerPosition(cid), 27)
                    talk_state = 3

        elseif msgcontains(msg, 'alchemists formulas') and talk_state == 2 and getPlayerStorageValue(cid,54558) == 1 then
            selfSay('You have already done mission for me! If you want missions ask Randalf in Venore for a mission.')
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
            selfSay('Good Bye. |PLAYERNAME|! Take care of yourself. ')
            talk_state = 0
        end
end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}

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
	elseif msgcontains(msg, 'help') then
		npcHandler:say('Lucien is thief, I\'m telling you! He stole my alchemists formulas, could you please help me by return them?', cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 and msgcontains(msg, 'yes') then
		npcHandler:say('Please go to his hidden spot near spike sword quest and find my {alchemists formulas}.', cid)
		doPlayerSetStorageValue(cid, 58755, 1)
		Topic[cid] = 0
	elseif msgcontains(msg, 'alchemist') and msgcontains(msg, 'formula') and getPlayerStorageValue(cid,54558) < 1 and doPlayerRemoveItem(cid, 9733, 1) == TRUE then
		npcHandler:say('Thank you very much! Now you can use magic door near spike sword quest!', cid)
		setPlayerStorageValue(cid,54558,1)
		doSendMagicEffect(getThingPos(cid), 27)
	elseif msgcontains(msg, 'alchemist') and msgcontains(msg, 'formula')and getPlayerStorageValue(cid,54558) == 1 then
		npcHandler:say('You have already done mission for me! If you want missions ask Randalf in Venore for a mission.', cid)
	elseif Topic[cid] == 1 then
		npcHandler:say('Good bye, ' .. getCreatureName(cid) .. '! Take care of yourself.', cid)
		Topic[cid] = 0
		npcHandler:releaseFocus(cid)
	end
	return true
end

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