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

Custom quest NPC

Kedor

New Member
Joined
Mar 3, 2008
Messages
263
Reaction score
0
Location
Poland, Gdynia
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 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)
    -- 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

	ring = getPlayerStorageValue(cid,14334)

if msgcontains(msg, 'staff') and ring == -1 or msgcontains(msg, 'food') and ring == -1 then
		selfSay('If you will bring me 5 breads i will give you my staff. I can\'t use it since i am to weak even to walk. Please bring me them.')

elseif msgcontains(msg, 'staff') and ring == 1 or msgcontains(msg, 'food') and ring == 1 then
		selfSay('I don\'t have anythink more. As you can see i am beggar, and i will take all breads you have. Do you want give them to me?')
	talk_state = 2




elseif msgcontains(msg, 'bread') and ring == -1 then
	if getPlayerItemCount(cid,2689) >= 5 then
	selfSay('I can give you my staff for 5 breads. Do you want?')
talk_state = 1

elseif msgcontains(msg, 'bread') and ring == -1 then
	if getPlayerItemCount(cid,2689) < 5 then
	selfSay('I can accept all amount of breads but you need to have 5 of them to get my staff.')
	elseif msgcontains(msg, 'bread') and ring == 1 then
	selfSay('Thanks for breads.')
end
end

	
	elseif talk_state == 1 and msgcontains(msg, 'yes') then	
	if getPlayerItemCount(cid,2689) >= 5 then
	if doPlayerTakeItem(cid,2689,5) == 0 then	
	selfSay('Man! I don\'t know how to thank you. Here is your "reward". I don\'t have nothink more. Hope it will be usefull for you.')
	doPlayerAddItem(cid, 6107, 1)
	setPlayerStorageValue(cid,14334,1)
	talk_state = 0	
end

		elseif talk_state == 1 and msgcontains(msg, 'no') then		
		selfSay('I will die without it but thats okey for me.')
		
		
		talk_state = 0
			


end

elseif talk_state == 2 and msgcontains(msg, 'yes') then	
	local count = getPlayerItemCount(cid,2689)
	if doPlayerTakeItem(cid,2689,count) == 0 then
	selfSay('Thanks for ' .. count .. ' breads. I will never forget it. Here. I found it in forest.')
	doPlayerAddItem(cid, 2130, 1)
	setPlayerStorageValue(cid,14334,1)
	talk_state = 0	
end
		elseif talk_state == 2 and msgcontains(msg, 'no') then		
		selfSay('You are so sassy. You will pay me for it.')
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HITBYFIRE)
		doCreatureAddHealth(cid, -50)
		doSendAnimatedText(getPlayerPosition(cid),50,TEXTCOLOR_ORANGE)
		
		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.


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

and when i got the 5 breads :P and i say "no" he dont answer anythink.. like the
Code:
        elseif talk_state == 1 and msgcontains(msg, 'no') then        
        selfSay('I will die without it but thats okey for me.')
        
        
        talk_state = 0
isnt working :P any1 can fix it?
 
Back
Top