• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

quest npc

Ziggy

Member
Joined
Aug 11, 2007
Messages
49
Reaction score
6
Here is my quest npc

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	

if msgcontains(msg, 'backpack') then


	if getPlayerItemCount(cid, 3960) == 1 then
	if getPlayerStorageValue(cid, 20002) == 2 then
			doPlayerRemoveItem(cid, 3960, 1)
			doPlayerAddItem(cid, 2687, 10)
			doPlayerSetStorageValue(cid, 20002, 3)
			talkState[talkUser] = 1

		elseif getPlayerStorageValue(cid, storage) == 1 then
			doPlayerSendCancel(cid, "You do not have my backpack!")
		
		elseif getPlayerStorageValue(cid, storage) == 3 then
			doPlayerSendCancel(cid, "You have already traded this item.")
		
		end
		else doPlayerSendCancel(cid, "You do not have my backpack!")
	end
end
return true
end	

npcHandler:addModule(FocusModule:new())

for some reason he does not reply to the word backpack, what is wrong with him?
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local storage = 20002

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, 'backpack') then
		local v = getPlayerStorageValue(cid, storage)
		if v == 1 then
			npcHandler:say('You do not have my backpack!', cid)
		elseif v == 2 then
			if doPlayerRemoveItem(cid, 3960, 1) then
				doPlayerAddItem(cid, 2687, 10)
				doPlayerSetStorageValue(cid, storage, 3)
			else
				npcHandler:say('You do not have my backpack!', cid)
			end
		elseif v == 3 then
			npcHandler:say('You have already traded this item.', cid)
		end
	end
	return true
end	

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Thank you so much, I have been toiling over this for the longest time, rep to you
 
Back
Top