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

Jester Doll Help!!!

Rexanilator

New Member
Joined
Oct 3, 2009
Messages
297
Reaction score
2
I have been working on a npc that trades the 6 parts of jester doll for a jester doll the only issue I dont understand is how to make the npc take the 6 parts of jester doll I have tried a lot of stuff that I thought would work but none of them did so I decided to post here

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
	local cycmsg = 'Enjoy your new Jester Doll!'
	local noimsg = 'You don't have the necessary items to get your Jester Doll!'
	local deny = 'Come back when you want a cool looking doll of me!'
 
 
--------------------MESSAGES------------------------------------------------------------------------------
    if msgcontains(msg, 'help') or msgcontains(msg, 'trade') then
		selfSay('I can trade the 6 jester parts for a cool looking jester doll.', cid)
 
	elseif msgcontains(msg, 'jester doll') then
        selfSay('If you want a jester doll you must have the 6 parts of it with you? Do you want to trade for a awesome jester doll?', cid)
        talkState[talkUser] = 1
 
 
-------------GETTING JESTER DOLL FROM HIM-------------------
 
	-- Jester Doll
	elseif talkState[talkUser] == 1 then
		if msgcontains(msg, 'yes') then
				doPlayerRemoveItem(cid, (9694,1) (9695,1) (9696,1) (9697,1) (9698,1) (9699,1))
				doPlayerAddItem(cid,9693,1)
				selfSay(cycmsg, cid)	
				talkState[talkUser] = 0
			else
				selfSay(noimsg, cid)
			end
		else
			selfSay(deny, cid)
		end
		talkState[talkUser] = 0
	end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and ofc Rep +++ to who helps :)
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local parts = {9694, 9695, 9696, 9697, 9698, 9699}

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') or msgcontains(msg, 'trade') then
		selfSay('I can trade the 6 jester parts for a cool looking jester doll.', cid)
		Topic[cid] = 0
	elseif msgcontains(msg, 'jester doll') then
		selfSay('If you want a jester doll you must have the 6 parts of it with you? Do you want to trade for a awesome jester doll?', cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 then
		if msgcontains(msg, 'yes') then
			for i = 1, #parts do
				if getPlayerItemCount(cid, parts[i]) < 1 then
					return selfSay('You don\'t have the necessary items to get your Jester Doll!', cid)
				end
			end
			for i = 1, #parts do
				doPlayerRemoveItem(cid, parts[i], 1)
			end
			doPlayerAddItem(cid,9693,1)
			selfSay('Enjoy your new Jester Doll!', cid)
		else
			selfSay('Come back when you want a cool looking doll of me!', cid)
		end
		Topic[cid] = 0
	end
end

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