Ir para conteúdo

Featured Replies

Postado

Versão: Otx 2.8 (8.60 tfs 0.3.7)

 

Está dando erro no executável porém não sei como resolver =/

 

[Warning - The Oracle] NpcSystem:
oracle - Call without any npcHandler instance.

UXH1Zxc.png

 

O Npc não teleporta o player e fica repetindo a cidade para escolher.

 

Estou utilizando esse script (pois pelas config, ele envia os itens para o Depot do personagem):

 

Spoiler

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
function onPlayerEndTrade(cid)              npcHandler:onPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)          npcHandler:onPlayerCloseChannel(cid)        end


--///////////////////////////START SCRIPT(oracle)///////////////////////////--
function oracle(cid, message, keywords, parameters, node)
	local npcHandler = parameters.npcHandler
	if(npcHandler == nil) then
		print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'oracle - Call without any npcHandler instance.')
		return false
	end

	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local cityNode, vocationNode = node:getParent():getParent(), node:getParent()
	local params = {
		['vocation'] = vocationNode:getParameters().vocation,
		['town'] = cityNode:getParameters().town,
		['premium'] = cityNode:getParameters().premium or false,
		['items'] = vocationNode:getParameters().items or nil
	}

	if(params['town'] ~= nil and params['vocation'] ~= nil) then
		if(getPlayerLevel(cid) < parameters.level) then
			npcHandler:say('You must first reach level {' .. parameters.level .. '}!', cid)
		elseif(getPlayerVocation(cid) > 0) then
			npcHandler:say('Sorry, you already have a vocation!', cid)
		elseif(params['premium'] and not isPremium(cid)) then
			npcHandler:say('Sorry, this town is reserved only for premium players!', cid)
		else
			doPlayerSetVocation(cid, params['vocation'])
			doPlayerSetTown(cid, params['town'])
			if(params['items'] ~= nil) then
				local parcel, time = doCreateItemEx(2595), os.time()
				local label, target = doAddContainerItem(parcel, 2599), getCreatureName(cid)

				doItemSetAttribute(label, "text", target .. "\n" .. getTownName(params['town']))
				doItemSetAttribute(label, "date", time)
				doItemSetAttribute(label, "writer", getCreatureName(getNpcId()))

				for _, item in ipairs(params['items']) do
					if(type(item[2]) == 'string') then
						local tmp = doCreateItemEx(item[1])

						doItemSetAttribute(tmp, "text", item[2])
						doItemSetAttribute(tmp, "date", time)
						doItemSetAttribute(tmp, "writer", getCreatureName(getNpcId()))

						doAddContainerItemEx(parcel, tmp)
					else
						doAddContainerItem(parcel, item[1], item[2] or 1)
					end
				end

				doPlayerSendMailByName(target, parcel, params['town'])
			end

			local tmp, temple = getThingPosition(cid), getTownTemplePosition(params['town'])
			npcHandler:say('SO BE IT!', cid)
			doTeleportThing(cid, temple)

			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(temple, CONST_ME_TELEPORT)
		end
	else
		npcHandler:resetNpc(cid)
		error('Player: ' .. getCreatureName(cid) .. ', Params: ' .. table.serialize(params))
	end
	return true
end

function greetCallback(cid)
local player = Player(cid)

	if(getPlayerLevel(cid) == getConfigValue('rookLevelToLeaveRook')) then
		return true
    elseif(getPlayerLevel(cid) < getConfigValue('rookLevelToLeaveRook')) then
		npcHandler:say('COME BACK WHEN YOU GROW UP, CHILD!')
		npcHandler:resetNpc(cid)
		return false
	elseif(getPlayerLevel(cid) > getConfigValue('rookLevelToLeaveRook')) then
		npcHandler:say(player:getName() .. ', I CAN\'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.')
		npcHandler:resetNpc(cid)
		return false
	end
end

local yesNode = KeywordNode:new({'yes'}, oracle, {level = getConfigValue('rookLevelToLeaveRook')})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Then what vocation do you want to become?'})

local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What city do you wish to live in? {Thais}, {Carlin}, {Venore}, {Kazordoon} or {Ab\'Dendriel}?'})
	local node2 = node1:addChildKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 2, text = 'Thais, eh? So what vocation do you wish to become? {Sorcerer}, {druid}, {paladin} or {knight}?'})
		local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, items = {{2190,1},{7620,1},{7618,1}}, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, items = {{2182,1},{7620,1},{7618,1}}, onlyFocus = true, text = 'Are you sure that a druid is what you wish to become? This decision is irreversible!'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, items = {{2389,5},{7620,1},{7618,1}}, onlyFocus = true, text = 'A ranged marksman. Are you sure? This decision is irreversible!'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
		node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, items = {{8602,1},{2439,1},{8601,1},{7620,1},{7618,1}}, onlyFocus = true, text = 'A mighty warrior. Is that your final decision? This decision is irreversible!'})
			node3:addChildKeywordNode(yesNode)
			node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then come back when you are ready.'})

--///////////////////////////END SCRIPT(oracle)///////////////////////////--

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

 

Editado por Weslley Kiyo (veja o histórico de edições)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo