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

Bugged Npc ?

Lucenzo

The Way You Move :)
Joined
Jan 29, 2011
Messages
363
Reaction score
14
Location
UK
Heya :)


LUA:
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

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'offer') then
		selfSay('You can here change some items for {warrior sweat}, {magic sulphur}, {enchanted chicken wing}, {spirit container}.', cid)

elseif msgcontains(msg, 'spider silk yarn') then
				if getPlayerItemCount(cid,5879) >= 10 then
					selfSay('Did you bring me 10 giant spider silks?', cid)
					talk_state = 4
				else
					selfSay('I need {10 giant spider silks}, to give you spider silk yarn. Come back when you have them.', cid)
					talk_state = 0
				end
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if getPlayerItemCount(cid,5879) >= 10 then
					if doPlayerRemoveItem(cid,5879,10) == TRUE then
						doPlayerAddItem(cid,5886,1)
						selfSay(done, cid)
					end
				else
				selfSay(item, cid)
				end

		elseif msgcontains(msg, 'warrior\'s sweat') then
			if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
				selfSay('Did you bring me the 4 warrior helmets?', cid)
				talk_state = 10
			else
				selfSay('I need a {4 warrior helmet\'s}, to give you the warrior sweat. Come back when you have them.', cid)
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 10 then
			talk_state = 0
			if getPlayerItemCount(cid,2475) >= 4 then
					if doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE then
						doPlayerAddItem(cid,5885,1)
										selfSay(done, cid)
					end

			else
				selfSay(item, cid)
			end

elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
selfSay('Did you bring me 3 fire swords?', cid)
talk_state = 5
else
selfSay('I need {3 fire sword\'s}, to give you the magic sulpher. Come back when you have them.', cid)
talk_state = 0
end

		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if getPlayerItemCount(cid,2392) >= 3 then
					if doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE then
						doPlayerAddItem(cid,5904,1)
										selfSay(done, cid)
				end
			else
				selfSay(item, cid)
			end

		elseif msgcontains(msg, 'enchanted chicken wing') then
			if getPlayerItemCount(cid,2195) >= 1 then
				selfSay('Did you bring me boots of haste?', cid)
				talk_state = 6
			else
				selfSay('I need {boots of haste}, to give you the enchanted chicken wing. Come back when you have them.', cid)
				talk_state = 0
			end

		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if getPlayerItemCount(cid,2195) >= 1 then
					if doPlayerRemoveItem(cid,2195,1) == TRUE then
						doPlayerAddItem(cid,5891,1)
										selfSay(done, cid)
					end
			else
				selfSay(item, cid)
			end

		elseif msgcontains(msg, 'spirit container') then
			if getPlayerItemCount(cid,2498) >= 2 then
				selfSay('Did you bring me the 2 Royal Helmets?', cid)
				talk_state = 10
			else
				selfSay('I need a {2 Royal Helmet\'s}, to give you the Spirit Container. Come back when you have them.', cid)
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 10 then
			talk_state = 0
			if getPlayerItemCount(cid,2498) >= 2 then
					if doPlayerRemoveItem(cid,2498,2) == TRUE then
						doPlayerAddItem(cid,5884,1)
										selfSay(done, cid)
					end

			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('So Leave, LEAVE ME NOW!')
            talk_state = 0
        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())

When i ask for "Spirit Container" and the npc asks me if i have 2 royal helmets, = yes then it responds
Code:
20:09 Haroun: You do not have the required items.

What can be wrong with this one?


Thanks in Advance x x
 
Try now.
Code:
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
 
item = 'You do not have the required items.'
done = 'Here you are.'
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
 
		if msgcontains(msg, 'offer') then
		selfSay('You can here change some items for {warrior sweat}, {magic sulphur}, {enchanted chicken wing}, {spirit container}.', cid)
 
elseif msgcontains(msg, 'spider silk yarn') then
				if getPlayerItemCount(cid,5879) >= 10 then
					selfSay('Did you bring me 10 giant spider silks?', cid)
					talk_state = 4
				else
					selfSay('I need {10 giant spider silks}, to give you spider silk yarn. Come back when you have them.', cid)
					talk_state = 0
				end
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if getPlayerItemCount(cid,5879) >= 10 then
					if doPlayerRemoveItem(cid,5879,10) == TRUE then
						doPlayerAddItem(cid,5886,1)
						selfSay(done, cid)
					end
				else
				selfSay(item, cid)
				end
 
		elseif msgcontains(msg, 'warrior\'s sweat') then
			if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
				selfSay('Did you bring me the 4 warrior helmets?', cid)
				talk_state = 20
			else
				selfSay('I need a {4 warrior helmet\'s}, to give you the warrior sweat. Come back when you have them.', cid)
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 20 then
			talk_state = 0
			if getPlayerItemCount(cid,2475) >= 4 then
					if doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE then
						doPlayerAddItem(cid,5885,1)
										selfSay(done, cid)
					end
 
			else
				selfSay(item, cid)
			end
 
elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
selfSay('Did you bring me 3 fire swords?', cid)
talk_state = 5
else
selfSay('I need {3 fire sword\'s}, to give you the magic sulpher. Come back when you have them.', cid)
talk_state = 0
end
 
		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if getPlayerItemCount(cid,2392) >= 3 then
					if doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE then
						doPlayerAddItem(cid,5904,1)
										selfSay(done, cid)
				end
			else
				selfSay(item, cid)
			end
 
		elseif msgcontains(msg, 'enchanted chicken wing') then
			if getPlayerItemCount(cid,2195) >= 1 then
				selfSay('Did you bring me boots of haste?', cid)
				talk_state = 6
			else
				selfSay('I need {boots of haste}, to give you the enchanted chicken wing. Come back when you have them.', cid)
				talk_state = 0
			end
 
		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if getPlayerItemCount(cid,2195) >= 1 then
					if doPlayerRemoveItem(cid,2195,1) == TRUE then
						doPlayerAddItem(cid,5891,1)
										selfSay(done, cid)
					end
			else
				selfSay(item, cid)
			end
 
		elseif msgcontains(msg, 'spirit container') then
			if getPlayerItemCount(cid,2498) >= 2 then
				selfSay('Did you bring me the 2 Royal Helmets?', cid)
				talk_state = 10
			else
				selfSay('I need a {2 Royal Helmet\'s}, to give you the Spirit Container. Come back when you have them.', cid)
				talk_state = 0
			end
		elseif msgcontains(msg, 'yes') and talk_state == 10 then
			talk_state = 0
			if getPlayerItemCount(cid,2498) >= 2 then
					if doPlayerRemoveItem(cid,2498,2) == TRUE then
						doPlayerAddItem(cid,5884,1)
										selfSay(done, cid)
					end
 
			else
				selfSay(item, cid)
			end
 
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('So Leave, LEAVE ME NOW!')
            talk_state = 0
        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())
 
LUA:
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

local item = 'You do not have the required items.'
local done = 'Here you are.'
local t = {}

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'offer') then
		selfSay('I can exchange some items for {warrior\'s sweat}, {magic sulphur}, {enchanted chicken wing} and {spirit container}.', cid)
	elseif msgcontains(msg, 'silk') then
		if getPlayerItemCount(cid, 5879) >= 10 then
			selfSay('Did you bring me 10 giant spider silks?', cid)
			t[cid] = 1
		else
			selfSay('I need {10 giant spider silks} to give you a spider silk yarn. Come back when you have them.', cid)
			t[cid] = nil
		end
	elseif msgcontains(msg, 'sweat') then
		if getPlayerItemCount(cid, 2475) >= 4 then
			selfSay('Did you bring me the 4 warrior helmets?', cid)
			t[cid] = 2
		else
			selfSay('I need {4 warrior helmets} to give you a flask of warrior\'s sweat. Come back when you have them.', cid)
			t[cid] = nil
		end
	elseif msgcontains(msg, 'sulphur') then
		if getPlayerItemCount(cid, 2392) >= 3 then
			selfSay('Did you bring me 3 fire swords?', cid)
			t[cid] = 3
		else
			selfSay('I need {3 fire swords} to give you a magic sulphur. Come back when you have them.', cid)
			t[cid] = nil
		end
	elseif msgcontains(msg, 'wing') then
		if getPlayerItemCount(cid, 2195) ~= 0 then
			selfSay('Did you bring me a pair of boots of haste?', cid)
			t[cid] = 4
		else
			selfSay('I need a pair of {boots of haste} to give you an enchanted chicken wing. Come back when you have it.', cid)
			t[cid] = nil
		end
	elseif msgcontains(msg, 'spirit') then
		if getPlayerItemCount(cid, 2498) >= 2 then
			selfSay('Did you bring me the 2 royal helmets?', cid)
			t[cid] = 5
		else
			selfSay('I need {2 royal helmets} to give you the a spirit container. Come back when you have them.', cid)
			t[cid] = nil
		end
	elseif t[cid] then
		if msgcontains(msg, 'yes') then
			if t[cid] == 1 then
				if doPlayerRemoveItem(cid, 5879, 10) then
					doPlayerAddItem(cid, 5886, 1)
					selfSay(done, cid)
				else
					selfSay(item, cid)
				end
			elseif t[cid] == 2 then
				if doPlayerRemoveItem(cid,2475,4) then
					doPlayerAddItem(cid,5885,1)
					selfSay(done, cid)
				else
					selfSay(item, cid)
				end
			elseif t[cid] == 3 then
				if doPlayerRemoveItem(cid,2392,3) then
					doPlayerAddItem(cid,5904,1)
					selfSay(done, cid)
				else
					selfSay(item, cid)
				end
			elseif t[cid] == 4 then
				if doPlayerRemoveItem(cid,2195,1) then
					doPlayerAddItem(cid,5891,1)
					selfSay(done, cid)
				else
					selfSay(item, cid)
				end
			elseif t[cid] == 5 then
				if doPlayerRemoveItem(cid,2498,2) then
					doPlayerAddItem(cid,5884,1)
					selfSay(done, cid)
				else
					selfSay(item, cid)
				end
			end
		else
			selfSay('So leave, LEAVE ME NOW!', cid)
		end
		t[cid] = nil
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Thank you both :) x x x

Take care :L

@Still seems that the npc keeps responding "no items blabla" :L ? x x
 
Last edited:
Back
Top