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

Help with this NPC rep+ rep+ rep+

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
165
Reaction score
13
Location
Sweden
Im having trouble with my quest npcs. Only one of them responds, wich is the last one I added or the first one I speak to.
So there must be something I missed. Can anyone help me? rep+


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {0}
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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            local cid = cid or 0
            local nid = getNpcCid()
            addEvent(say, delay, param)


        end
    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 quest = 76669
local reward = 70000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'mission') then
    delayedSay("Great, a valentuer. I need you to slay 200 dragons for me. And then, we might be able to take out those dragon lords. Well, can you slay 200 dragons for me?", 100, cid) 
    talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
    delayedSay("Please come back for a reward.", 10, cid)
    
    elseif(getPlayerStorageValue(cid, quest) == 3) then --pirates
    delayedSay("200 dragons, allready? You're a true dragon slayer. Here's your reward as I promised.", 100, cid)
		doPlayerAddItem(cid,2160,30)
        	doPlayerAddExp(cid, 1000000)
		if getPlayerSex(cid) == 0 then
		doPlayerAddOutfit(cid, 142, 2)
	else
		doPlayerAddOutfit(cid, 134, 2)
		doPlayerSendTextMessage(cid,22,"You have been rewarded with the warrior addon!")
        	setPlayerStorageValue(cid, quest, 4)
end
        	   
    
elseif(getPlayerStorageValue(cid, quest) == 4) then
    delayedSay("You have done enough for me I will soon plan our attack!", 100, cid)

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
    delayedSay("Great! I'll reward you greatly {ok}?.", 100, cid)
    talkState[talkUser]= 3
    elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
    delayedSay("Okay, Hurry up!", 100, cid)
    setPlayerStorageValue(cid, quest, 2)

end
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 talkState = {0}
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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            local cid = cid or 0
            local nid = getNpcCid()
            addEvent(say, delay, param)


        end
    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 quest = 66669
local reward = 80000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'mission') then
    delayedSay("Could you possibly help me clean up down here and kill 30 rotworms?", 100, cid) 
    talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
    delayedSay("Please come back for a reward.", 10, cid)
    
    elseif(getPlayerStorageValue(cid, quest) == 3) then --pirates
    delayedSay("Great, here you have a reward.", 100, cid)
		doPlayerAddItem(cid,2195,1)
		doPlayerAddItem(cid,2160,2)
        	doPlayerAddExp(cid, 250000)
        	setPlayerStorageValue(cid, quest, 4)

elseif(getPlayerStorageValue(cid, quest) == 4) then
    delayedSay("	I dont need any help at the moment.", 100, cid)

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
    delayedSay("Ok, use this to heal {ok}?.", 100, cid)
    talkState[talkUser]= 3
    elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
	doPlayerAddItem(cid,2273,25)
	delayedSay("Okay, Hurry up!", 100, cid)
	setPlayerStorageValue(cid, quest, 2)

end
end

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

local talkState = {}
local quest = 76669
local reward = 70000
	
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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		npcHandler:say("Great! I'll reward you greatly {ok}?.", cid)
		talkState[talkUser] = 2
	elseif msgcontains(msg, "ok") and talkState[talkUser] == 2 then
		npcHandler:say("Okay, Hurry up!", cid)
		setPlayerStorageValue(cid, quest, 2)
		talkState[talkUser] = 0
	elseif msgcontains(msg, "mission") then
		local str = getPlayerStorageValue(cid, quest)
		if(str < 2) then
			npcHandler:say("Great, an adventurer. I need you to slay 200 dragons for me. And then, we might be able to take out those dragon lords. Well, can you slay 200 dragons for me?", cid) 
			talkState[talkUser] = 1
			return true
		elseif(str == 2) then
			npcHandler:say("Please come back for a reward.", cid)
		elseif(str == 3) then
			npcHandler:say("200 dragons, already? You're a true dragon slayer! As I promised, here's your reward.", cid)
			doPlayerAddItem(cid, 2160, 30)
			doPlayerAddExp(cid, 10000)
			doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 142 or 134, 2)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been rewarded with the warrior addon!")
			setPlayerStorageValue(cid, quest, 4)
		elseif(str == 4) then
			npcHandler:say("You have done enough for me, I will soon plan our attack!", cid)
		end
		talkState[talkUser] = 0
	end
	return TRUE
end

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